diff --git a/Graphics/gl2jpeg.cpp b/Graphics/gl2jpeg.cpp index aca2240c6b96e213374d10f78f853fbb2860a13f..84ed41d18844ef4e01cf212c5e3dce1b78c45ffe 100644 --- a/Graphics/gl2jpeg.cpp +++ b/Graphics/gl2jpeg.cpp @@ -1,14 +1,11 @@ -/* $Id: gl2jpeg.cpp,v 1.2 2000-12-21 10:29:45 geuzaine Exp $ */ +/* $Id: gl2jpeg.cpp,v 1.3 2000-12-28 18:58:20 geuzaine Exp $ */ #include "Gmsh.h" #include "GmshUI.h" -#include "Context.h" #include "jpeglib.h" #include "jerror.h" -extern Context_T CTX ; - void my_output_message (j_common_ptr cinfo){ char buffer[JMSG_LENGTH_MAX]; @@ -18,7 +15,7 @@ void my_output_message (j_common_ptr cinfo){ Msg(DEBUG, "%s", buffer); } -void create_jpeg(FILE *outfile, int width, int height){ +void create_jpeg(FILE *outfile, int width, int height, int quality){ int i; unsigned char *pixels; struct jpeg_compress_struct cinfo; @@ -36,9 +33,11 @@ void create_jpeg(FILE *outfile, int width, int height){ cinfo.input_components = 3; /* # of color components per pixel */ cinfo.in_color_space = JCS_RGB; /* colorspace of input image */ jpeg_set_defaults(&cinfo); - jpeg_set_quality(&cinfo, CTX.print.jpeg_quality, TRUE /* limit to baseline-JPEG values */); + jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */); jpeg_start_compress(&cinfo, TRUE); + glPixelStorei(GL_PACK_ALIGNMENT,1); + glPixelStorei(GL_UNPACK_ALIGNMENT,1); pixels=(unsigned char *)Malloc(height*width*3); glReadPixels(0,0,width,height,GL_RGB,GL_UNSIGNED_BYTE,pixels); diff --git a/Graphics/gl2jpeg.h b/Graphics/gl2jpeg.h index 340ca518041c18e24e6daa82b084755ca0ce5378..7c8f69e480622e23e58db1f4d09b1a887c8a0ed9 100644 --- a/Graphics/gl2jpeg.h +++ b/Graphics/gl2jpeg.h @@ -1,6 +1,7 @@ #ifndef _GL2JPEG_H_ #define _GL2JPEG_H_ -void create_jpeg(FILE *outfile, int width, int height); +void create_jpeg(FILE *outfile, int width, int height, + int quality); #endif diff --git a/Graphics/gl2ppm.cpp b/Graphics/gl2ppm.cpp index 70c6ceb5d42e24d2508b7ab7575fd98492465850..27672f3ae252035defd52e38eca2245300507f76 100644 --- a/Graphics/gl2ppm.cpp +++ b/Graphics/gl2ppm.cpp @@ -1,4 +1,4 @@ -/* $Id: gl2ppm.cpp,v 1.3 2000-12-21 10:29:45 geuzaine Exp $ */ +/* $Id: gl2ppm.cpp,v 1.4 2000-12-28 18:58:20 geuzaine Exp $ */ #include "Gmsh.h" #include "GmshUI.h" @@ -6,7 +6,9 @@ void create_ppm(FILE *outfile, int width, int height){ unsigned char *pixels; int i, row_stride; - + + glPixelStorei(GL_PACK_ALIGNMENT,1); + glPixelStorei(GL_UNPACK_ALIGNMENT,1); pixels=(unsigned char *)Malloc(height*width*3); glReadPixels(0,0,width,height,GL_RGB,GL_UNSIGNED_BYTE,pixels); diff --git a/Graphics/gl2yuv.cpp b/Graphics/gl2yuv.cpp index bf09ded7029ff6cffa65d2771199fdfa4b8f27f2..5a4bb7a848a6ca8013f19de199a5b127b5e9ab05 100644 --- a/Graphics/gl2yuv.cpp +++ b/Graphics/gl2yuv.cpp @@ -1,4 +1,4 @@ -/* $Id: gl2yuv.cpp,v 1.1 2000-12-26 17:40:18 geuzaine Exp $ */ +/* $Id: gl2yuv.cpp,v 1.2 2000-12-28 18:58:20 geuzaine Exp $ */ #include "Gmsh.h" #include "GmshUI.h" @@ -41,9 +41,11 @@ void create_yuv(FILE *outfile, int width, int height){ } /* yuv format assumes even number of rows and columns */ - if(height%2) height--; - if(width%2) width--; + height -= height%2; + width -= width%2; + glPixelStorei(GL_PACK_ALIGNMENT,1); + glPixelStorei(GL_UNPACK_ALIGNMENT,1); pixels=(unsigned char *)Malloc(height*width*3); glReadPixels(0,0,width,height,GL_RGB,GL_UNSIGNED_BYTE,pixels); row_stride = width * 3;