From 37a5311cdfb1d704785e64c7b6231db96313f439 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Thu, 28 Dec 2000 18:58:20 +0000 Subject: [PATCH] !! GL_PACK_ALIGNMENT + new options --- Graphics/gl2jpeg.cpp | 11 +++++------ Graphics/gl2jpeg.h | 3 ++- Graphics/gl2ppm.cpp | 6 ++++-- Graphics/gl2yuv.cpp | 8 +++++--- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Graphics/gl2jpeg.cpp b/Graphics/gl2jpeg.cpp index aca2240c6b..84ed41d188 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 340ca51804..7c8f69e480 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 70c6ceb5d4..27672f3ae2 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 bf09ded702..5a4bb7a848 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; -- GitLab