[Top][All Lists]
[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: |
Thu, 19 Sep 2002 09:01:28 -0400 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Janne V. Kujala <address@hidden> 02/09/19 09:01:28
Modified files:
gfx/demo : papertest.py
gfx/libcolor : spaces.cxx spaces.hxx
gfx/librenderables: renderables.py
Log message:
Add image color map renderable; does not work, probably because of glX
contexts
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/papertest.py.diff?tr1=1.22&tr2=1.23&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcolor/spaces.cxx.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcolor/spaces.hxx.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/renderables.py.diff?tr1=1.52&tr2=1.53&r1=text&r2=text
Patches:
Index: gzz/gfx/demo/papertest.py
diff -c gzz/gfx/demo/papertest.py:1.22 gzz/gfx/demo/papertest.py:1.23
*** gzz/gfx/demo/papertest.py:1.22 Thu Sep 12 11:48:12 2002
--- gzz/gfx/demo/papertest.py Thu Sep 19 09:01:28 2002
***************
*** 57,63 ****
rotatelist(zoom)
if k == "x":
rotatelist(paperzoom)
!
def dobenchmark(w, vs):
global benchmark
--- 57,67 ----
rotatelist(zoom)
if k == "x":
rotatelist(paperzoom)
! if k == "c":
! global cmap
! cmap = GZZGL.createLABColorMap(100, 100, 100, 100);
! currentScene = ColorMapScene()
! AbstractUpdateManager.setNoAnimation()
def dobenchmark(w, vs):
global benchmark
***************
*** 248,253 ****
--- 252,271 ----
putnoc(vs, getDListNocoords("""
PopAttrib
"""))
+
+
+ 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):
Index: gzz/gfx/libcolor/spaces.cxx
diff -c gzz/gfx/libcolor/spaces.cxx:1.3 gzz/gfx/libcolor/spaces.cxx:1.4
*** gzz/gfx/libcolor/spaces.cxx:1.3 Thu Aug 22 07:08:19 2002
--- gzz/gfx/libcolor/spaces.cxx Thu Sep 19 09:01:28 2002
***************
*** 305,308 ****
--- 305,350 ----
}
}
+
+ unsigned getImageColorMap(char *colorspace, int x, int y, int w, int h,
unsigned list = 0) {
+ void (*fromRGB)(float [], float []);
+
+ if (strcmp(colorspace, "CIELAB") == 0) {
+ fromRGB = RGBtoLAB;
+ } else if (strcmp(colorspace, "XYZ") == 0) {
+ 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;
+ }
}
Index: gzz/gfx/libcolor/spaces.hxx
diff -c gzz/gfx/libcolor/spaces.hxx:1.1 gzz/gfx/libcolor/spaces.hxx:1.2
*** gzz/gfx/libcolor/spaces.hxx:1.1 Tue Aug 6 11:14:33 2002
--- gzz/gfx/libcolor/spaces.hxx Thu Sep 19 09:01:28 2002
***************
*** 11,16 ****
--- 11,18 ----
void LABtoRGB(float lab[], float rgb[]);
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
Index: gzz/gfx/librenderables/renderables.py
diff -c gzz/gfx/librenderables/renderables.py:1.52
gzz/gfx/librenderables/renderables.py:1.53
*** gzz/gfx/librenderables/renderables.py:1.52 Wed Sep 18 21:51:34 2002
--- gzz/gfx/librenderables/renderables.py Thu Sep 19 09:01:28 2002
***************
*** 185,190 ****
--- 185,207 ----
},
{
+ "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();
+ coords1.performGL();
+ glCallList(list.name);
+ glPopMatrix();
+ GLERR;
+ """,
+ },
+
+ {
"Type" : "2",
"Name" : "Viewport",
"Data" : "",
- [Gzz-commits] gzz/gfx demo/papertest.py libcolor/spaces.cxx l...,
Janne V. Kujala <=