/[gzz]/gzz/gfx/libcolor/spaces.cxx
ViewVC logotype

Diff of /gzz/gfx/libcolor/spaces.cxx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by Vegai, Thu Aug 22 11:08:19 2002 UTC revision 1.4 by jvk, Thu Sep 19 13:01:28 2002 UTC
# Line 305  namespace Color { Line 305  namespace Color {
305        }        }
306      }      }
307    
308    
309        unsigned getImageColorMap(char *colorspace, int x, int y, int w, int h, unsigned list = 0) {
310          void (*fromRGB)(float [], float []);
311    
312          if (strcmp(colorspace, "CIELAB") == 0) {
313            fromRGB = RGBtoLAB;
314          } else if (strcmp(colorspace, "XYZ") == 0) {
315            fromRGB = RGB709toXYZ;
316          }
317    
318          float *pixels = new float[w * h * 3];
319          glReadBuffer(GL_FRONT);
320          glReadPixels(x, y, w, h, GL_RGB, GL_FLOAT, pixels);
321          
322          glDrawBuffer(GL_FRONT);
323          glRasterPos2f(0, 0);
324          glDrawPixels(w, h, GL_RGB, GL_FLOAT, pixels);
325    
326          glFinish();
327    
328          glDrawBuffer(GL_BACK);
329    
330          if (list == 0) list = glGenLists(1);
331          glNewList(list, GL_COMPILE);
332          glBegin(GL_POINTS);
333          for (int i = 0; i < w * h * 3; i += 3) {
334            float rgb[3] = { pixels[i], pixels[i+1], pixels[i+2] };
335            float v[3];
336            fromRGB(rgb, v);
337            glColor3fv(rgb);
338            glVertex3fv(v);
339            cout << "("
340                 << rgb[0]<< "," << rgb[1] << "," << rgb[2]
341                 << ")->("
342                 << v[0] << "," << v[1] << "," << v[2]
343                 << ")\n";
344          }
345          glEnd();
346          glEndList();
347          delete[] pixels;
348          return list;
349        }
350  }  }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26