Merge remote-tracking branch 'origin/master' into HEAD

This commit is contained in:
Sergii Pylypenko
2019-04-23 18:16:24 +03:00
179 changed files with 6418 additions and 1144 deletions
+16 -3
View File
@@ -25,6 +25,7 @@
#include "window_func.h"
#include "tile_map.h"
#include "landscape.h"
#include "blitter/16bpp_base.hpp"
#include "table/strings.h"
@@ -36,7 +37,7 @@ static const char * const HEIGHTMAP_NAME = "heightmap"; ///< Default filename
char _screenshot_format_name[8]; ///< Extension of the current screenshot format (corresponds with #_cur_screenshot_format).
uint _num_screenshot_formats; ///< Number of available screenshot formats.
uint _cur_screenshot_format; ///< Index of the currently selected screenshot format in #_screenshot_formats.
static char _screenshot_name[128]; ///< Filename of the screenshot file.
static char _screenshot_name[256]; ///< Filename of the screenshot file.
char _full_screenshot_name[MAX_PATH]; ///< Pathname of the screenshot file.
/**
@@ -265,7 +266,8 @@ static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *user
png_infop info_ptr;
/* only implemented for 8bit and 32bit images so far. */
if (pixelformat != 8 && pixelformat != 32) return false;
if (pixelformat != 8 && pixelformat != 32 && pixelformat != 16) return false;
if (pixelformat == 16) bpp = 3;
f = fopen(name, "wb");
if (f == NULL) return false;
@@ -379,6 +381,17 @@ static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *user
/* render the pixels into the buffer */
callb(userdata, buff, y, w, n);
y += n;
if (pixelformat == 16) {
// Convert to 24bpp
Blitter_16bppBase::Colour16 *inp = (Blitter_16bppBase::Colour16 *)buff;
uint8 *outp = (uint8 *)buff;
for (i = 1; i <= w * n; i++) {
outp[(w * n - i) * 3 ] = inp[w * n - i].r << 3;
outp[(w * n - i) * 3 + 1] = inp[w * n - i].g << 2;
outp[(w * n - i) * 3 + 2] = inp[w * n - i].b << 3;
//outp[(w * n - i) * 3] = 0xff;
}
}
/* write them to png */
for (i = 0; i != n; i++) {
@@ -851,7 +864,7 @@ bool MakeScreenshot(ScreenshotType t, const char *name)
if (ret) {
SetDParamStr(0, _screenshot_name);
ShowErrorMessage(STR_MESSAGE_SCREENSHOT_SUCCESSFULLY, INVALID_STRING_ID, WL_WARNING);
//ShowErrorMessage(STR_MESSAGE_SCREENSHOT_SUCCESSFULLY, INVALID_STRING_ID, WL_WARNING); // No need for message when we're doing cloudsave
} else {
ShowErrorMessage(STR_ERROR_SCREENSHOT_FAILED, INVALID_STRING_ID, WL_ERROR);
}