From 13bee35b857eb2acda23e4585d2c3d89b31c3d4a Mon Sep 17 00:00:00 2001 From: Glen Masgai Date: Mon, 11 Oct 2010 15:07:17 +0000 Subject: [PATCH] jpg screenshot path fix git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@5751 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/main.cpp | 26 ++++++++++---------------- source/src/platform.h | 6 ++---- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/source/src/main.cpp b/source/src/main.cpp index 88f34e7a..7936ec0a 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -362,16 +362,6 @@ void jpeg_screenshot_____(const char *imagepath, bool mapshot = false) #include "jpegenc.h" -int save_jpeg(const char *filename, uchar *pixels, int iw, int ih, int jpegquality) -{ - jpegenc *jpegencoder = new jpegenc; - if(jpegencoder->encode(filename, (colorRGB *)pixels, iw, ih, jpegquality) < 0) return -1; - - conoutf("writing to file: %s", filename); - delete jpegencoder; - return 0; -} - void jpeg_screenshot(const char *imagepath, bool mapshot = false) { extern int minimaplastsize; @@ -405,16 +395,20 @@ void jpeg_screenshot(const char *imagepath, bool mapshot = false) GLubyte *swapline = (GLubyte *) malloc(stride); for(int row = 0; row < ih/2; row++) { - memcpy(swapline, pixels + row * stride, stride); - memcpy(pixels + row * stride, pixels + (ih - row - 1) * stride, stride); - memcpy(pixels + (ih - row -1) * stride, swapline, stride); + memcpy(swapline, pixels + row * stride, stride); + memcpy(pixels + row * stride, pixels + (ih - row - 1) * stride, stride); + memcpy(pixels + (ih - row -1) * stride, swapline, stride); } } - const char *filename = screenshotpath(imagepath, "jpg"); - if(save_jpeg(filename, pixels, iw, ih, jpegquality) < 0) conoutf("\f3Error saving jpeg file"); + const char *filename = findfile(screenshotpath(imagepath, "jpg"), "wb"); + conoutf("writing to file: %s", filename); - delete[] pixels; + jpegenc *jpegencoder = new jpegenc; + jpegencoder->encode(filename, (colorRGB *)pixels, iw, ih, jpegquality); + delete jpegencoder; + + delete[] pixels; } VARP(pngcompress, 0, 9, 9); diff --git a/source/src/platform.h b/source/src/platform.h index e4d8d635..0c9f79aa 100644 --- a/source/src/platform.h +++ b/source/src/platform.h @@ -45,9 +45,9 @@ #ifndef STANDALONE #include #include - //#include + //#include - #include + #include #define GL_GLEXT_LEGACY #define __glext_h__ @@ -59,13 +59,11 @@ #ifdef __APPLE__ #include "INTL/libintl.h" - #include "JPEG/jpeglib.h" #include "OpenAL/al.h" #include "OpenAL/alc.h" #include "Vorbis/vorbisfile.h" #else #include - #include #include "AL/al.h" #include "AL/alc.h" #include "vorbis/vorbisfile.h"