From 362d47f91f7b30398c206681df450984c3bbcd63 Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 18 Sep 2013 12:17:29 +0100 Subject: [PATCH] Kill legacy PPM support in screen-dump --- simgear/screen/screen-dump.cxx | 50 ---------------------------------- simgear/screen/screen-dump.hxx | 15 ---------- 2 files changed, 65 deletions(-) diff --git a/simgear/screen/screen-dump.cxx b/simgear/screen/screen-dump.cxx index ff3e9b71..6165ba83 100644 --- a/simgear/screen/screen-dump.cxx +++ b/simgear/screen/screen-dump.cxx @@ -23,14 +23,6 @@ # include #endif -#ifdef WIN32 -# include -#endif - -#include -#include -#include - #include #include @@ -39,48 +31,6 @@ #include "screen-dump.hxx" -#define RGB3 3 // 3 bytes of color info per pixel -#define RGBA 4 // 4 bytes of color+alpha info - -bool sg_glWritePPMFile(const char *filename, GLubyte *buffer, int win_width, int win_height, int mode) -{ - int i, j, k, q; - unsigned char *ibuffer; - FILE *fp; - int pixelSize = mode==GL_RGBA?4:3; - - ibuffer = (unsigned char *) malloc(win_width*win_height*RGB3); - - if ( (fp = fopen(filename, "wb")) == NULL ) { - free(ibuffer); - printf("Warning: cannot open %s\n", filename); - return false; - } - - fprintf(fp, "P6\n# CREATOR: glReadPixel()\n%d %d\n%d\n", - win_width, win_height, UCHAR_MAX); - q = 0; - for (i = 0; i < win_height; i++) - for (j = 0; j < win_width; j++) - for (k = 0; k < RGB3; k++) - ibuffer[q++] = (unsigned char) - *(buffer + (pixelSize*((win_height-1-i)*win_width+j)+k)); - int written = fwrite(ibuffer, sizeof(unsigned char), RGB3*win_width*win_height, fp); - fclose(fp); - free(ibuffer); - - if ( written != RGB3*win_width*win_height ) - { - printf("Warning: failed to write %s. File truncated.\n", filename); - return false; - } - - printf("wrote file '%s' (%d x %d pixels, %d bytes)\n", - filename, win_width, win_height, RGB3*win_width*win_height); - return true; -} - - // dump the screen buffer to a png file, returns true on success bool sg_glDumpWindow(const char *filename, int win_width, int win_height) { osg::ref_ptr img(new osg::Image); diff --git a/simgear/screen/screen-dump.hxx b/simgear/screen/screen-dump.hxx index 375f5398..665eb16c 100644 --- a/simgear/screen/screen-dump.hxx +++ b/simgear/screen/screen-dump.hxx @@ -24,10 +24,6 @@ #ifndef SG_SCREEN_DUMP_HXX #define SG_SCREEN_DUMP_HXX -#include - -#include - /** * Dump the screen buffer to a PNG file. * @param filename name of file @@ -37,15 +33,4 @@ bool sg_glDumpWindow( const char *filename, int win_width, int win_height ); -/** - * Given a GLubyte *buffer, write it out to a ppm file. - * @param filename name of file - * @param buffer pointer to opengl buffer - * @param win_width width of buffer - * @param win_height height of buffer - * @param mode one of GL_RGBA, GL_RGB, etc. - */ -bool sg_glWritePPMFile( const char *filename, GLubyte *buffer, int win_width, - int win_height, int mode); - #endif // of SG_SCREEN_DUMP_HXX -- 2.39.5