From 75ee82edb43558fd8a67a872197abccca4105e2c Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Thu, 1 Sep 2005 19:48:37 +0000 Subject: [PATCH] fix screenshots that have only doubleheight set and not double width Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2297 --- src/gui/render.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/gui/render.cpp b/src/gui/render.cpp index 508dc560..e768837c 100644 --- a/src/gui/render.cpp +++ b/src/gui/render.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: render.cpp,v 1.31 2005-02-10 10:21:07 qbix79 Exp $ */ +/* $Id: render.cpp,v 1.32 2005-09-01 19:48:37 qbix79 Exp $ */ #include #include @@ -97,8 +97,12 @@ static void TakeScreenShot(Bit8u * bitmap) { png_bytep * row_pointers; png_color palette[256]; Bitu i; + Bitu fix_double_scale = 1;//variable to compensate for only doubleheight + + /* Remove this if we save rendered screens. instead of pre-rendered */ + if(render.src.dblh && !render.src.dblw) fix_double_scale = 2; + -/* Find a filename to open */ /* Open the actual file */ FILE * fp=OpenCaptureFile("Screenshot",".png"); if (!fp) return; @@ -106,10 +110,10 @@ static void TakeScreenShot(Bit8u * bitmap) { png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL,NULL, NULL); if (!png_ptr) return; info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) { + if (!info_ptr) { png_destroy_write_struct(&png_ptr,(png_infopp)NULL); return; - } + } /* Finalize the initing of png library */ png_init_io(png_ptr, fp); @@ -123,7 +127,7 @@ static void TakeScreenShot(Bit8u * bitmap) { png_set_compression_buffer_size(png_ptr, 8192); if (render.shot.bpp==8) { - png_set_IHDR(png_ptr, info_ptr, render.shot.width, render.shot.height, + png_set_IHDR(png_ptr, info_ptr, render.shot.width, (render.shot.height*fix_double_scale), 8, PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); for (i=0;i<256;i++) { @@ -133,15 +137,18 @@ static void TakeScreenShot(Bit8u * bitmap) { } png_set_PLTE(png_ptr, info_ptr, palette,256); } else { - png_set_IHDR(png_ptr, info_ptr, render.shot.width, render.shot.height, + png_set_IHDR(png_ptr, info_ptr, render.shot.width, (render.shot.height*fix_double_scale), render.shot.bpp, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); } + /*Allocate an array of scanline pointers*/ - row_pointers=(png_bytep*)malloc(render.shot.height*sizeof(png_bytep)); - for (i=0;i