From ffdc7c08d4a4597191e2f2c190d4d2208ad750a3 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Thu, 21 Dec 2000 08:03:43 +0000 Subject: [PATCH] *** empty log message *** --- Graphics/gl2ppm.cpp | 37 +++++++++++++++++++++++++++++++++++++ Graphics/gl2ppm.h | 6 ++++++ 2 files changed, 43 insertions(+) create mode 100644 Graphics/gl2ppm.cpp create mode 100644 Graphics/gl2ppm.h diff --git a/Graphics/gl2ppm.cpp b/Graphics/gl2ppm.cpp new file mode 100644 index 0000000000..99f29ad10f --- /dev/null +++ b/Graphics/gl2ppm.cpp @@ -0,0 +1,37 @@ + +#include "Gmsh.h" +#include "GmshUI.h" + +void create_ppm(FILE *outfile, int width, int height){ + unsigned char *red, *green, *blue; + register int x, y; + unsigned char r, g, b; + + red = (unsigned char *)malloc(height*width*sizeof(unsigned char)); + green = (unsigned char *)malloc(height*width*sizeof(unsigned char)); + blue = (unsigned char *)malloc(height*width*sizeof(unsigned char)); + + glReadPixels(0,0,width,height,GL_RED,GL_UNSIGNED_BYTE,red); + glReadPixels(0,0,width,height,GL_GREEN,GL_UNSIGNED_BYTE,green); + glReadPixels(0,0,width,height,GL_BLUE,GL_UNSIGNED_BYTE,blue); + + fprintf(outfile, "P6\n"); + fprintf(outfile, "%d %d\n", width, height); + fprintf(outfile, "%d\n", 255); + + for ( y = height-1; y >= 0; y-- ){ + for ( x = 0; x < width; x++ ){ + r = red[y*width+x]; + g = green[y*width+x]; + b = blue[y*width+x]; + fwrite(&r, 1, 1, outfile); + fwrite(&g, 1, 1, outfile); + fwrite(&b, 1, 1, outfile); + } + } + + Free(red); + Free(green); + Free(blue); +} + diff --git a/Graphics/gl2ppm.h b/Graphics/gl2ppm.h new file mode 100644 index 0000000000..47b88824d1 --- /dev/null +++ b/Graphics/gl2ppm.h @@ -0,0 +1,6 @@ +#ifndef _GL2PPM_H_ +#define _GL2PPM_H_ + +void create_ppm(FILE *outfile, int width, int height); + +#endif -- GitLab