[gl2ps] Patch to add support for PixelZoom in ps output
Shai Ayal
shaiay at users.sourceforge.net
Mon Nov 30 18:48:34 CET 2009
Hi
I attach below a patch adding support for PixelZoom (set using
glPixelZoom) in postscript images.
Shai
diff --git a/src/gl2ps.c b/src/gl2ps.c
--- a/src/gl2ps.c
+++ b/src/gl2ps.c
@@ -167,6 +167,7 @@
written to the file or not, and 'format' indicates if it is
visible or not */
GLenum format, type;
+ GLfloat zoom_x,zoom_y;
GLfloat *pixels;
} GL2PSimage;
@@ -2424,7 +2425,7 @@
gl2psPrintf("gsave\n");
gl2psPrintf("%.2f %.2f translate\n", x, y);
- gl2psPrintf("%d %d scale\n", width, height);
+ gl2psPrintf("%.2f %.2f scale\n", width*im->zoom_x, height*im->zoom_y);
if(greyscale){ /* greyscale */
gl2psPrintf("/picstr %d string def\n", width);
@@ -5782,7 +5783,7 @@
const void *pixels)
{
int size, i;
- GLfloat pos[4], *piv;
+ GLfloat pos[4], *piv, zoom_x, zoom_y;
GL2PSprimitive *prim;
GLboolean valid;
@@ -5802,6 +5803,8 @@
if(GL_FALSE == valid) return GL2PS_SUCCESS; /* the primitive is culled */
glGetFloatv(GL_CURRENT_RASTER_POSITION, pos);
+ glGetFloatv(GL_ZOOM_X, &zoom_x);
+ glGetFloatv(GL_ZOOM_Y, &zoom_y);
prim = (GL2PSprimitive*)gl2psMalloc(sizeof(GL2PSprimitive));
prim->type = GL2PS_PIXMAP;
@@ -5820,6 +5823,8 @@
prim->data.image = (GL2PSimage*)gl2psMalloc(sizeof(GL2PSimage));
prim->data.image->width = width;
prim->data.image->height = height;
+ prim->data.image->zoom_x = zoom_x;
+ prim->data.image->zoom_y = zoom_y;
prim->data.image->format = format;
prim->data.image->type = type;