This is an automated email from the git hooks/post-receive script. smcv pushed a commit to branch debian/master in repository openjk.
commit 87b551f97685254b58fb22aadad32810d455bfee Author: bibendovsky <[email protected]> Date: Thu Aug 11 22:14:42 2016 +0300 JO: Fix saved game and regular screenshots --- code/rd-common/tr_common.h | 2 +- code/rd-common/tr_image_jpg.cpp | 16 ++++++++++++---- code/rd-common/tr_public.h | 2 +- code/server/sv_savegame.cpp | 9 ++++++++- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/code/rd-common/tr_common.h b/code/rd-common/tr_common.h index becdf10..4d70883 100644 --- a/code/rd-common/tr_common.h +++ b/code/rd-common/tr_common.h @@ -79,7 +79,7 @@ void LoadJPGFromBuffer( byte *inputBuffer, size_t len, byte **pic, int *width, i ================================================================================ */ // Convert raw image data to JPEG format and store in buffer. -size_t RE_SaveJPGToBuffer( byte *buffer, size_t bufSize, int quality, int image_width, int image_height, byte *image_buffer, int padding ); +size_t RE_SaveJPGToBuffer( byte *buffer, size_t bufSize, int quality, int image_width, int image_height, byte *image_buffer, int padding, bool flip_vertical ); // Save raw image data as JPEG image file. void RE_SaveJPG( const char * filename, int quality, int image_width, int image_height, byte *image_buffer, int padding ); diff --git a/code/rd-common/tr_image_jpg.cpp b/code/rd-common/tr_image_jpg.cpp index 4bc19ed..a3ddb84 100644 --- a/code/rd-common/tr_image_jpg.cpp +++ b/code/rd-common/tr_image_jpg.cpp @@ -339,7 +339,7 @@ void LoadJPGFromBuffer( byte *inputBuffer, size_t len, unsigned char **pic, int * Here the array is only one element long, but you could ask for * more than one scanline at a time if that's more convenient. */ - buf = ((out+(row_stride*cinfo.output_scanline))); + buf = ((out+(row_stride*(cinfo.output_height - cinfo.output_scanline - 1)))); buffer = &buf; (void) jpeg_read_scanlines(&cinfo, buffer, 1); } @@ -492,7 +492,7 @@ Expects RGB input data ================= */ size_t RE_SaveJPGToBuffer(byte *buffer, size_t bufSize, int quality, - int image_width, int image_height, byte *image_buffer, int padding) + int image_width, int image_height, byte *image_buffer, int padding, bool flip_vertical) { struct jpeg_compress_struct cinfo; struct jpeg_error_mgr jerr; @@ -543,7 +543,15 @@ size_t RE_SaveJPGToBuffer(byte *buffer, size_t bufSize, int quality, * Here the array is only one element long, but you could pass * more than one scanline at a time if that's more convenient. */ - row_pointer[0] = &image_buffer[((cinfo.image_height-1)*row_stride)-cinfo.next_scanline * row_stride]; + + int row_index = cinfo.next_scanline; + + if (!flip_vertical) + { + row_index = cinfo.image_height - cinfo.next_scanline - 1; + } + + row_pointer[0] = &image_buffer[row_index * row_stride]; (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); } @@ -569,7 +577,7 @@ void RE_SaveJPG(const char * filename, int quality, int image_width, int image_h bufSize = image_width * image_height * 3; out = (byte *) R_Malloc( bufSize, TAG_TEMP_WORKSPACE, qfalse ); - bufSize = RE_SaveJPGToBuffer(out, bufSize, quality, image_width, image_height, image_buffer, padding); + bufSize = RE_SaveJPGToBuffer(out, bufSize, quality, image_width, image_height, image_buffer, padding, false); ri.FS_WriteFile(filename, out, bufSize); R_Free(out); diff --git a/code/rd-common/tr_public.h b/code/rd-common/tr_public.h index 73e96aa..850a68f 100644 --- a/code/rd-common/tr_public.h +++ b/code/rd-common/tr_public.h @@ -209,7 +209,7 @@ typedef struct { void (*GetScreenShot)(byte *data, int w, int h); #ifdef JK2_MODE - size_t (*SaveJPGToBuffer)(byte *buffer, size_t bufSize, int quality, int image_width, int image_height, byte *image_buffer, int padding ); + size_t (*SaveJPGToBuffer)(byte *buffer, size_t bufSize, int quality, int image_width, int image_height, byte *image_buffer, int padding, bool flip_vertical ); void (*LoadJPGFromBuffer)( byte *inputBuffer, size_t len, byte **pic, int *width, int *height ); #endif diff --git a/code/server/sv_savegame.cpp b/code/server/sv_savegame.cpp index 0711779..d3c4635 100644 --- a/code/server/sv_savegame.cpp +++ b/code/server/sv_savegame.cpp @@ -977,7 +977,14 @@ static void SG_WriteScreenshot(qboolean qbAutosave, const char *psMapName) size_t iJPGDataSize = 0; size_t bufSize = SG_SCR_WIDTH * SG_SCR_HEIGHT * 3; byte *pJPGData = (byte *)Z_Malloc( static_cast<int>(bufSize), TAG_TEMP_WORKSPACE, qfalse, 4 ); - iJPGDataSize = re.SaveJPGToBuffer(pJPGData, bufSize, JPEG_IMAGE_QUALITY, SG_SCR_WIDTH, SG_SCR_HEIGHT, pbRawScreenShot, 0 ); + +#ifdef JK2_MODE + bool flip_vertical = true; +#else + bool flip_vertical = false; +#endif // JK2_MODE + + iJPGDataSize = re.SaveJPGToBuffer(pJPGData, bufSize, JPEG_IMAGE_QUALITY, SG_SCR_WIDTH, SG_SCR_HEIGHT, pbRawScreenShot, 0, flip_vertical ); if ( qbAutosave ) delete[] byBlank; -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/openjk.git _______________________________________________ Pkg-games-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

