gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz/gfx demo/papertest.py libcolor/spaces.cxx l...


From: Janne V. Kujala
Subject: [Gzz-commits] gzz/gfx demo/papertest.py libcolor/spaces.cxx l...
Date: Fri, 20 Sep 2002 11:52:34 -0400

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Janne V. Kujala <address@hidden>        02/09/20 11:52:34

Modified files:
        gfx/demo       : papertest.py 
        gfx/libcolor   : spaces.cxx spaces.hxx 
        gfx/librenderables: renderables.py 

Log message:
        Paper color visualization works

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/papertest.py.diff?tr1=1.23&tr2=1.24&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcolor/spaces.cxx.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcolor/spaces.hxx.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/renderables.py.diff?tr1=1.56&tr2=1.57&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/papertest.py
diff -c gzz/gfx/demo/papertest.py:1.23 gzz/gfx/demo/papertest.py:1.24
*** gzz/gfx/demo/papertest.py:1.23      Thu Sep 19 09:01:28 2002
--- gzz/gfx/demo/papertest.py   Fri Sep 20 11:52:33 2002
***************
*** 59,65 ****
          rotatelist(paperzoom)
      if k == "c":
          global cmap
!         cmap = GZZGL.createLABColorMap(100, 100, 100, 100);
          currentScene = ColorMapScene()
        AbstractUpdateManager.setNoAnimation()
  
--- 59,74 ----
          rotatelist(paperzoom)
      if k == "c":
          global cmap
!         x,y = 0,0
!         xs,ys = 200,200
!         pixels = GZZGL.createByteVector(xs*ys*3)
!         pixels.readFromBuffer_ubytes(w.window, "FRONT", x, y, xs, ys, "RGB");
! 
!         print "Read pixels"
!         cmap = GZZGL.createLABColorMap(pixels, xs * ys);
!         currentScene = ColorMapScene()
!       AbstractUpdateManager.setNoAnimation()
!     if k == "C":
          currentScene = ColorMapScene()
        AbstractUpdateManager.setNoAnimation()
  
***************
*** 257,271 ****
  class ColorMapScene:
      def __init__(self):
          self.bgcolor = (0,0,0)
      def key(self, k):
          pass
      def scene(self, vs):
        putnoc(vs, background(self.bgcolor))
  
!       cs1 = vs.coords.affineCoordsys(0, "1", 10, 600, 500, 1, 0, 0, 1)
  
          vs.map.put(cmap, cs1)
!     
  
  class DummyScene:
      def __init__(self):
--- 266,299 ----
  class ColorMapScene:
      def __init__(self):
          self.bgcolor = (0,0,0)
+         self.angle = 0
+         
      def key(self, k):
          pass
+     def mouse(self, ev):
+       if ev.getID() == ev.MOUSE_CLICKED:
+           self.angle = ev.getX()
+           ev.getY()
+             
+           AbstractUpdateManager.chg()
+ 
      def scene(self, vs):
        putnoc(vs, background(self.bgcolor))
  
!       cs1 = vs.coords.affineCoordsys(0, "1", 0, -70*8, 0, 8, 0, 0, 8)
  
+         putnoc(vs, getDListNocoords("""
+             PointSize 1
+             Disable TEXTURE_2D
+             PushMatrix
+             Translate 600 500 100
+         """))
+       rotate(vs, "rot", self.angle, -1, 1, 1)
          vs.map.put(cmap, cs1)
!       poptrans(vs, "rot")
!         putnoc(vs, getDListNocoords("""
!             PopMatrix
!         """))
  
  class DummyScene:
      def __init__(self):
Index: gzz/gfx/libcolor/spaces.cxx
diff -c gzz/gfx/libcolor/spaces.cxx:1.4 gzz/gfx/libcolor/spaces.cxx:1.5
*** gzz/gfx/libcolor/spaces.cxx:1.4     Thu Sep 19 09:01:28 2002
--- gzz/gfx/libcolor/spaces.cxx Fri Sep 20 11:52:33 2002
***************
*** 306,312 ****
      }
  
  
!     unsigned getImageColorMap(char *colorspace, int x, int y, int w, int h, 
unsigned list = 0) { 
        void (*fromRGB)(float [], float []);
  
        if (strcmp(colorspace, "CIELAB") == 0) {
--- 306,312 ----
      }
  
  
!     unsigned getImageColorMap(char *colorspace, unsigned char *pixels, int n, 
unsigned list = 0) { 
        void (*fromRGB)(float [], float []);
  
        if (strcmp(colorspace, "CIELAB") == 0) {
***************
*** 315,348 ****
        fromRGB = RGB709toXYZ;
        }
  
-       float *pixels = new float[w * h * 3];
-       glReadBuffer(GL_FRONT);
-       glReadPixels(x, y, w, h, GL_RGB, GL_FLOAT, pixels);
-       
-       glDrawBuffer(GL_FRONT);
-       glRasterPos2f(0, 0);
-       glDrawPixels(w, h, GL_RGB, GL_FLOAT, pixels);
- 
-       glFinish();
- 
-       glDrawBuffer(GL_BACK);
- 
        if (list == 0) list = glGenLists(1);
        glNewList(list, GL_COMPILE);
        glBegin(GL_POINTS);
!       for (int i = 0; i < w * h * 3; i += 3) {
!       float rgb[3] = { pixels[i], pixels[i+1], pixels[i+2] };
        float v[3];
        fromRGB(rgb, v);
        glColor3fv(rgb);
        glVertex3fv(v);
        cout << "(" 
             << rgb[0]<< "," << rgb[1] << "," << rgb[2] 
             << ")->("
             << v[0] << "," << v[1] << "," << v[2] 
             << ")\n";
        }
        glEnd();
        glEndList();
        delete[] pixels;
        return list;
--- 315,370 ----
        fromRGB = RGB709toXYZ;
        }
  
        if (list == 0) list = glGenLists(1);
        glNewList(list, GL_COMPILE);
        glBegin(GL_POINTS);
!       for (int i = 0; i < n * 3; i += 3) {
!       const float s = 1. / 255;
!       float rgb[3] = { s * pixels[i], s * pixels[i+1], s * pixels[i+2] };
        float v[3];
        fromRGB(rgb, v);
        glColor3fv(rgb);
        glVertex3fv(v);
+       /*
        cout << "(" 
             << rgb[0]<< "," << rgb[1] << "," << rgb[2] 
             << ")->("
             << v[0] << "," << v[1] << "," << v[2] 
             << ")\n";
+       */
        }
        glEnd();
+ 
+       float edge[12][2][3] = {
+       {{ 0, 0, 0 }, { 0, 0, 1 }},
+       {{ 0, 1, 0 }, { 0, 1, 1 }},
+       {{ 1, 0, 0 }, { 1, 0, 1 }},
+       {{ 1, 1, 0 }, { 1, 1, 1 }},
+ 
+       {{ 0, 0, 0 }, { 0, 1, 0 }},
+       {{ 0, 0, 1 }, { 0, 1, 1 }},
+       {{ 1, 0, 0 }, { 1, 1, 0 }},
+       {{ 1, 0, 1 }, { 1, 1, 1 }},
+ 
+       {{ 0, 0, 0 }, { 1, 0, 0 }},
+       {{ 0, 0, 1 }, { 1, 0, 1 }},
+       {{ 0, 1, 0 }, { 1, 1, 0 }},
+       {{ 0, 1, 1 }, { 1, 1, 1 }}
+       };
+ 
+       for (int i = 0; i < 12; i++) {
+       float rgb[3], v[3];
+       glBegin(GL_LINE_STRIP);
+       for (float t = 0; t <= 1; t += 1.0 / 8) {
+         for (int c = 0; c < 3; c++)
+           rgb[c] = edge[i][0][c] * (1 - t) + edge[i][1][c] * t;
+         fromRGB(rgb, v);
+         glColor3fv(rgb);
+         glVertex3fv(v);
+       }
+       glEnd();
+       }
+ 
        glEndList();
        delete[] pixels;
        return list;
Index: gzz/gfx/libcolor/spaces.hxx
diff -c gzz/gfx/libcolor/spaces.hxx:1.2 gzz/gfx/libcolor/spaces.hxx:1.3
*** gzz/gfx/libcolor/spaces.hxx:1.2     Thu Sep 19 09:01:28 2002
--- gzz/gfx/libcolor/spaces.hxx Fri Sep 20 11:52:33 2002
***************
*** 12,18 ****
    
    void drawSlice(char *colorspace, int axis, float value, int mode = 1);
  
!   unsigned getImageColorMap(char *colorspace, int x, int y, int w, int h, 
unsigned list = 0);
  }
  
  #endif
--- 12,18 ----
    
    void drawSlice(char *colorspace, int axis, float value, int mode = 1);
  
!   unsigned getImageColorMap(char *colorspace, unsigned char *pixels, int n, 
unsigned list = 0);
  }
  
  #endif
Index: gzz/gfx/librenderables/renderables.py
diff -c gzz/gfx/librenderables/renderables.py:1.56 
gzz/gfx/librenderables/renderables.py:1.57
*** gzz/gfx/librenderables/renderables.py:1.56  Fri Sep 20 10:52:48 2002
--- gzz/gfx/librenderables/renderables.py       Fri Sep 20 11:52:33 2002
***************
*** 195,203 ****
      "Type": "1",
      "Name" : "LABColorMap",
      "Data" : "CallGL::DisplayList list; ",
!     "Params" : "int x, int y, int w, int h",
      "ParamCode" : """
!                   Color::getImageColorMap("CIELAB", x, y, w, h, list.name);
                """,
      "RenderCode" : """
            glPushMatrix();
--- 195,203 ----
      "Type": "1",
      "Name" : "LABColorMap",
      "Data" : "CallGL::DisplayList list; ",
!     "Params" : "ByteVector pixels, int size",
      "ParamCode" : """
!                   Color::getImageColorMap("CIELAB", pixels, size, list.name);
                """,
      "RenderCode" : """
            glPushMatrix();




reply via email to

[Prev in Thread] Current Thread [Next in Thread]