diff -ruN vmd_orig/configure vmd/configure --- vmd_orig/configure Sun Jul 13 21:15:48 2003 +++ vmd/configure Sun Jul 13 21:18:06 2003 @@ -927,6 +927,7 @@ 'PlainTextInterp.C', 'PluginMgr.C', 'POV3DisplayDevice.C', + 'PNGDisplayDevice.C', 'PSDisplayDevice.C', 'VMDQuat.C', 'RadianceDisplayDevice.C', @@ -1045,6 +1046,7 @@ 'PluginMgr.h', 'PointerTool.h', 'POV3DisplayDevice.h', + 'PNGDisplayDevice.h', 'PSDisplayDevice.h', 'VMDQuat.h', 'RadianceDisplayDevice.h', @@ -1800,7 +1802,7 @@ @DEFINES = (); @INCDIRS = (); @LIBDIRS = (); -@LIBS = (); +@LIBS = ("-lpng"); @VMD_CCPP = (); @VMD_CC = (); @VMD_H = (); diff -ruN vmd_orig/src/FileRenderList.C vmd/src/FileRenderList.C --- vmd_orig/src/FileRenderList.C Sun Jul 13 21:15:40 2003 +++ vmd/src/FileRenderList.C Sun Jul 13 21:23:23 2003 @@ -46,6 +46,7 @@ #include "RenderManDisplayDevice.h" // RenderMan interface #include "VrmlDisplayDevice.h" // VRML 1.0 #include "Vrml2DisplayDevice.h" // VRML 2.0 +#include "PNGDisplayDevice.h" // PNG #if defined(VMDLIBTACHYON) #include "LibTachyonDisplayDevice.h" // Built-in Tachyon ray tracer @@ -68,6 +69,7 @@ add(new RadianceDisplayDevice()); add(new R3dDisplayDevice()); add(new VrmlDisplayDevice()); + add(new PNGDisplayDevice(app->display)); } // destructor, deallocate all the info diff -ruN vmd_orig/src/PNGDisplayDevice.C vmd/src/PNGDisplayDevice.C --- vmd_orig/src/PNGDisplayDevice.C Wed Dec 31 19:00:00 1969 +++ vmd/src/PNGDisplayDevice.C Sun Jul 13 21:26:00 2003 @@ -0,0 +1,103 @@ + +/*************************************************************************** + *cr + *cr (C) Copyright 1995-2003 The Board of Trustees of the + *cr University of Illinois + *cr All Rights Reserved + *cr + ***************************************************************************/ + +/*************************************************************************** + * RCS INFORMATION: + * + * $RCSfile: PNGDisplayDevice.C,v $ + * $Author: brad noyes $ $Locker: $ $State: Exp $ + * $Revision: 1.2 $ $Date: 2003/06/19 18:16:50 $ + * + *************************************************************************** + * DESCRIPTION: + * + * + ***************************************************************************/ +#include +#include +#include +#include "PNGDisplayDevice.h" +#include "Inform.h" +void user_error_fn (png_structp png_ptr, const char *message) +{ + msgErr << "png Error" << sendmsg; +} + +void user_warning_fn (png_structp png_ptr, const char *message) +{ + msgInfo << "png Warning" << sendmsg; +} +void write_row_callback(png_structp png_ptr, png_uint_32 row, int pass) +{ + msgInfo << "Writing row [" << pass <<"] " << sendmsg; +} + + + +PNGDisplayDevice::PNGDisplayDevice(DisplayDevice *d) : + FileRenderer("png", "snap.png", "gimp %s") +{ + display = d; +} + +int PNGDisplayDevice::open_file(const char * filename) +{ + if ((outfile = fopen(filename, "wb")) == NULL) { + msgErr << "Could not open file " << filename + << " in current directory for writing!" << sendmsg; + return FALSE; + } + my_filename = stringdup(filename); + isOpened = TRUE; + return TRUE; +} + + +void PNGDisplayDevice::render(const VMDDisplayList *) +{ + int r; + int height = display->ySize; + int width = display->xSize; + int depth = 8; + GLubyte* buffer; + png_structp png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, + NULL, user_error_fn, user_warning_fn); + png_infop info_ptr = png_create_info_struct(png_ptr); + + if (setjmp(png_jmpbuf(png_ptr))) + { + png_destroy_write_struct(&png_ptr, &info_ptr); + return; + } + + png_init_io(png_ptr, outfile); + png_set_IHDR(png_ptr, info_ptr, width, height, depth,PNG_COLOR_TYPE_RGB,PNG_INTERLACE_NONE,PNG_COMPRESSION_TYPE_DEFAULT,PNG_FILTER_TYPE_DEFAULT); + buffer = (GLubyte*)malloc (width * 3 * sizeof (unsigned char)); + msgInfo << "Height=" <