Changeset 4083 in Sophya for trunk/SophyaPI/PI/pipixmapgen.cc
- Timestamp:
- Oct 4, 2012, 2:26:28 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/pipixmapgen.cc
r4077 r4083 8 8 #include "sopnamsp.h" 9 9 #include "pipixmapgen.h" 10 10 11 11 12 // --------- Methodes de la classe PIPixMap ---------- … … 43 44 // long kind() 44 45 // Retourne le type ("=PIPixmap::ClassId") 45 // void SetPixmap(unsigned char *pix, int sx, int sy, bool refr=true, int ox=0, int oy=0) 46 // Associe un tableau d'index "pix" de taille "sx * sy". 47 // (ox,oy)" définissent l'offset d'affichage. 46 // void SetPixmap(PIPixColIdx *pixidx, int sx, int sy, bool refr=true, int ox=0, int oy=0) 47 // Associe un tableau d'index de couleur "pixidx". (ox,oy)" définissent l'offset d'affichage. 48 48 // Si "refr=true", la méthode "Refresh()" est appelée. 49 49 //-- … … 87 87 { 88 88 pixmap = NULL; 89 nx = ny = 0;89 fgownpmap = false; 90 90 ofx = ofy = 0; 91 91 mPpos[0] = mPpos[0] = 0; … … 99 99 { 100 100 delete cmap; 101 if (fgownpmap && pixmap) delete pixmap; 101 102 } 102 103 103 104 /* --Methode-- */ 104 void PIPixmapGen::SetPixmap( unsigned char *pix, int sx, int sy, bool refr, int ox, int oy)105 void PIPixmapGen::SetPixmap(PIPixColIdx *pixidx, bool refr, int ox, int oy) 105 106 { 106 pixmap = pix; 107 if (pixmap) 108 { 109 if (sx < 0) sx = 0; 110 if (sy < 0) sy = 0; 111 if (ox < 0) ox = 0; 112 if (oy < 0) oy = 0; 113 nx = sx; ny = sy; 114 ofx = ox; ofy = oy; 107 if (fgownpmap && pixmap) delete pixmap; 108 fgownpmap = false; 109 pixmap = pixidx; 110 if (ox < 0) ox = 0; 111 if (oy < 0) oy = 0; 112 ofx = ox; ofy = oy; 113 if (refr) Refresh(); 114 } 115 116 /* --Methode-- */ 117 void PIPixmapGen::SetRGBArray(PIPixRGBArray *rgba, CMapId cmapid, bool refr, int ox, int oy) 118 { 119 if (rgba == NULL) return; 120 int quantum = 8; 121 if (cmapid == CMAP_RGB216) quantum = 6; 122 else if (cmapid == CMAP_RGB4096) quantum = 16; 123 else cmapid = CMAP_RGB512; 124 SetColMapId(cmapid, false); 125 PIPixColIdx * pixc = new PIPixColIdx; 126 pixc->AllocateByte(rgba->XSize(), rgba->YSize()); 127 for(int j=0; j<rgba->YSize(); j++) 128 for(int i=0; i<rgba->XSize(); i++) { 129 PIPixRGB vv = (*rgba)(i,j); 130 int r = (int)vv.red*quantum/256; 131 int g = (int)vv.green*quantum/256; 132 int b = (int)vv.blue*quantum/256; 133 pixc->GetShort(i,j) = (unsigned short)((b*quantum+g)*quantum+r); 115 134 } 116 else { ofx = ofy = nx = ny = 0; } 117 if (refr) Refresh(); 135 SetPixmap(pixc, refr, ox, oy); 136 fgownpmap = true; 137 return; 118 138 } 119 139
Note:
See TracChangeset
for help on using the changeset viewer.