Skip to content
Snippets Groups Projects
Commit 37a5311c authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

!! GL_PACK_ALIGNMENT

+ new options
parent 9ec9c1d9
No related branches found
No related tags found
No related merge requests found
/* $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 "Gmsh.h"
#include "GmshUI.h" #include "GmshUI.h"
#include "Context.h"
#include "jpeglib.h" #include "jpeglib.h"
#include "jerror.h" #include "jerror.h"
extern Context_T CTX ;
void my_output_message (j_common_ptr cinfo){ void my_output_message (j_common_ptr cinfo){
char buffer[JMSG_LENGTH_MAX]; char buffer[JMSG_LENGTH_MAX];
...@@ -18,7 +15,7 @@ void my_output_message (j_common_ptr cinfo){ ...@@ -18,7 +15,7 @@ void my_output_message (j_common_ptr cinfo){
Msg(DEBUG, "%s", buffer); 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; int i;
unsigned char *pixels; unsigned char *pixels;
struct jpeg_compress_struct cinfo; struct jpeg_compress_struct cinfo;
...@@ -36,9 +33,11 @@ void create_jpeg(FILE *outfile, int width, int height){ ...@@ -36,9 +33,11 @@ void create_jpeg(FILE *outfile, int width, int height){
cinfo.input_components = 3; /* # of color components per pixel */ cinfo.input_components = 3; /* # of color components per pixel */
cinfo.in_color_space = JCS_RGB; /* colorspace of input image */ cinfo.in_color_space = JCS_RGB; /* colorspace of input image */
jpeg_set_defaults(&cinfo); 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); jpeg_start_compress(&cinfo, TRUE);
glPixelStorei(GL_PACK_ALIGNMENT,1);
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
pixels=(unsigned char *)Malloc(height*width*3); pixels=(unsigned char *)Malloc(height*width*3);
glReadPixels(0,0,width,height,GL_RGB,GL_UNSIGNED_BYTE,pixels); glReadPixels(0,0,width,height,GL_RGB,GL_UNSIGNED_BYTE,pixels);
......
#ifndef _GL2JPEG_H_ #ifndef _GL2JPEG_H_
#define _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 #endif
/* $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 "Gmsh.h"
#include "GmshUI.h" #include "GmshUI.h"
...@@ -7,6 +7,8 @@ void create_ppm(FILE *outfile, int width, int height){ ...@@ -7,6 +7,8 @@ void create_ppm(FILE *outfile, int width, int height){
unsigned char *pixels; unsigned char *pixels;
int i, row_stride; int i, row_stride;
glPixelStorei(GL_PACK_ALIGNMENT,1);
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
pixels=(unsigned char *)Malloc(height*width*3); pixels=(unsigned char *)Malloc(height*width*3);
glReadPixels(0,0,width,height,GL_RGB,GL_UNSIGNED_BYTE,pixels); glReadPixels(0,0,width,height,GL_RGB,GL_UNSIGNED_BYTE,pixels);
......
/* $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 "Gmsh.h"
#include "GmshUI.h" #include "GmshUI.h"
...@@ -41,9 +41,11 @@ void create_yuv(FILE *outfile, int width, int height){ ...@@ -41,9 +41,11 @@ void create_yuv(FILE *outfile, int width, int height){
} }
/* yuv format assumes even number of rows and columns */ /* yuv format assumes even number of rows and columns */
if(height%2) height--; height -= height%2;
if(width%2) width--; width -= width%2;
glPixelStorei(GL_PACK_ALIGNMENT,1);
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
pixels=(unsigned char *)Malloc(height*width*3); pixels=(unsigned char *)Malloc(height*width*3);
glReadPixels(0,0,width,height,GL_RGB,GL_UNSIGNED_BYTE,pixels); glReadPixels(0,0,width,height,GL_RGB,GL_UNSIGNED_BYTE,pixels);
row_stride = width * 3; row_stride = width * 3;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment