Changeset 3549 in Sophya for trunk/SophyaPI
- Timestamp:
- Dec 13, 2008, 4:40:33 PM (17 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/pipixutils.cc
r3545 r3549 80 80 PIPixRGBArray::PIPixRGBArray(int sx, int sy) 81 81 { 82 if (sx < 0) sx = 0; 83 if (sy < 0) sy = 0; 84 sx_ = sx; sy_ = sy; 85 size_t sz = sx_*sy_; 86 if (sz>0) rgbpix_ = new PIPixRGB[sz]; 87 else rgbpix_ = NULL; 82 sx_ = sy_ = 0; 83 rgbpix_ = NULL; 84 SetSize(sx, sy); 88 85 } 89 86 … … 100 97 } 101 98 102 int PIPixRGBArray::SaveToFile(const char * filename) 99 void PIPixRGBArray::SetSize(int sx, int sy) 100 { 101 if ((sx == sx_)&&(sy == sy_)) return; 102 if (sx < 0) sx = 0; 103 if (sy < 0) sy = 0; 104 if (rgbpix_) delete[] rgbpix_; 105 sx_ = sx; sy_ = sy; 106 size_t sz = sx_*sy_; 107 if (sz>0) rgbpix_ = new PIPixRGB[sz]; 108 else rgbpix_ = NULL; 109 } 110 111 int PIPixRGBArray::SaveToFile(const char * filename) const 103 112 { 104 113 FILE * fip = fopen(filename,"wb"); … … 121 130 { 122 131 if (rgbpix_) { 123 132 delete[] rgbpix_; 124 133 sx_ = sy_ = 0; 125 134 rgbpix_ = NULL; … … 139 148 size_t sz = sx_*sy_; 140 149 if (sz>0) { 141 142 150 rgbpix_ = new PIPixRGB[sz]; 151 fread((void *)rgbpix_, sizeof(PIPixRGB), sx_*sy_, fip); 143 152 } 144 153 else rgbpix_ = NULL; -
trunk/SophyaPI/PI/pipixutils.h
r3545 r3549 16 16 PIPixColIdx(); 17 17 ~PIPixColIdx(); 18 inline int XSize() { return sx_; }19 inline int YSize() { return sy_; }18 inline int XSize() const { return sx_; } 19 inline int YSize() const { return sy_; } 20 20 21 21 void AllocateByte(int sx, int sy); … … 62 62 ~PIPixRGBArray(); 63 63 64 inline int XSize() { return sx_; } 65 inline int YSize() { return sy_; } 64 void SetSize(int sx, int sy); 65 66 inline int XSize() const { return sx_; } 67 inline int YSize() const { return sy_; } 66 68 67 69 inline PIPixRGB operator()(int i, int j) const … … 70 72 { return rgbpix_[j*sx_+i]; } 71 73 72 int SaveToFile(const char * filename) ;74 int SaveToFile(const char * filename) const ; 73 75 int ReadFrFile(const char * filename); 74 76 -
trunk/SophyaPI/PI/pitherm.cc
r2615 r3549 139 139 void PIThermometer::Draw(PIGraphicGen* g, int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/) 140 140 { 141 if (!IsVisible()) return; 141 142 double delta = (max_-min_); 142 143 if (delta < 1.e-39) delta = 1.e-39; -
trunk/SophyaPI/PI/piwdggen.cc
r3473 r3549 57 57 //-- 58 58 //++ 59 // void PSPrint(PSFile *psf, int ofx=0, int ofy=0)60 // Méthode virtuelle qui doit être redéfinie pour chacune des classes filles.61 // produit une représentation graphique de l'objet en Postscript.62 59 // SetSize(int sx, int sy) 63 60 // Modifie la taille de l'objet. … … 181 178 // int UserFlag() 182 179 // Renvoie la valeur "int" user de l'objet. 180 //-- 181 182 //++ 183 // Titre Export postscript et format RGB 184 //-- 185 //++ 186 // void PSPrint(PSFile *psf, int ofx=0, int ofy=0) 187 // Méthode virtuelle qui doit être redéfinie pour chacune des classes filles. 188 // produit une représentation graphique de l'objet en Postscript. 189 // void ExportToRGB(PIPixRGBArray & rgba) 190 // Méthode virtuelle qui doit être redéfinie pour chaque architecture. 191 // Remplit un tableau PIPixRGBArray le contenu pixels du widget en couleurs RGB. 183 192 //-- 184 193 … … 309 318 } 310 319 320 /* --Methode-- */ 321 void PIWdgGen::ExportToRGB(PIPixRGBArray & rgba) 322 { 323 return; 324 } 325 311 326 //++ 312 327 // Titre Gestion des Draw/Event Handler -
trunk/SophyaPI/PI/piwdggen.h
r3473 r3549 10 10 #include "pimsghandler.h" 11 11 #include "picolist.h" 12 #include "pipixutils.h" 12 13 13 14 #include <string> … … 107 108 virtual bool IfSensitive()=0; 108 109 110 // Pour exporter le contenu d'un widget (dessin vectoriel) en postscript 109 111 virtual void PSPrint(PSFile *psf, int ofx=0, int ofy=0, 110 112 double scale_x=1., double scale_y=1.); 113 // Pour exporter le tableau des pixels du widget en classe PIPixRGBArray 114 // L'implementation par defaut ne fait rien 115 virtual void ExportToRGB(PIPixRGBArray & rgba); 111 116 112 117 // Gestion de copier-coller -
trunk/SophyaPI/PI/piwdgx.cc
r3215 r3549 831 831 } 832 832 833 834 // Pour exporter le tableau des pixels du widget en classe PIPixRGBArray 835 inline void _col2_fcol_(unsigned long & col, unsigned long & fcol) 836 { 837 if (col > 0x00FFFFFF) fcol = 0x01000000; 838 else if (col > 0x0000FFFF) fcol = 0x000010000; 839 else if (col > 0x000000FF) fcol = 0x00000100; 840 else fcol = 1; 841 } 842 /* --Methode-- */ 843 void PIWdgX::ExportToRGB(PIPixRGBArray & rgba) 844 { 845 Display* mdsp = PIXDisplay(); 846 int scr = XDefaultScreen(mdsp); 847 int depth = DefaultDepth(mdsp,scr); 848 Window xw = XtWindow(XtWdg()); 849 unsigned long plane_mask = ~0; // tous les bits a 1 850 XImage * ximg = XGetImage(mdsp, xw, 0, 0, XSize(), YSize(), plane_mask, ZPixmap); 851 //DBG cout << " Resultat XGetImage -> " << hex << ximg << dec << endl; 852 if (ximg == NULL) return; 853 854 unsigned long red,green,blue; 855 unsigned long fred,fgreen,fblue; 856 XColor col; 857 Colormap cmap = XDefaultColormap (mdsp, scr); 858 red = 0x000000FF; 859 green = 0x0000FF00; 860 blue = 0x00FF0000; 861 unsigned short maxrgb = ~0; 862 col.red = maxrgb; col.green = col.blue = 0; 863 if (XAllocColor(mdsp, cmap, &col)) red = col.pixel; 864 col.green = maxrgb; col.red = col.blue = 0; 865 if (XAllocColor(mdsp, cmap, &col)) green = col.pixel; 866 col.blue = maxrgb; col.red = col.green = 0; 867 if (XAllocColor(mdsp, cmap, &col)) blue = col.pixel; 868 _col2_fcol_(red, fred); 869 _col2_fcol_(green, fgreen); 870 _col2_fcol_(blue, fblue); 871 rgba.SetSize(XSize(), YSize()); 872 unsigned long pixel; 873 PIPixRGB rgb; 874 for(int j=0; j<YSize(); j++) 875 for(int i=0; i<XSize(); i++) { 876 pixel = XGetPixel(ximg, i, j); 877 rgb.red = (pixel&red)/fred; 878 rgb.green = (pixel&green)/fgreen; 879 rgb.blue = (pixel&blue)/fblue; 880 rgba(i,j) = rgb; 881 } 882 XDestroyImage(ximg); 883 return; 884 } 833 885 834 886 -
trunk/SophyaPI/PI/piwdgx.h
r3473 r3549 63 63 virtual void SetUnSensitive(); 64 64 virtual bool IfSensitive(); 65 66 // Pour exporter le tableau des pixels du widget en classe PIPixRGBArray 67 virtual void ExportToRGB(PIPixRGBArray & rgba); 65 68 66 69 // Gestion de copier-coller
Note:
See TracChangeset
for help on using the changeset viewer.