mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2025-01-23 19:02:04 -05:00
Merge pull request #3723 from Gymnasiast/remove-bmp-screenshots
Remove support for BMP screenshots
This commit is contained in:
commit
714baf2979
8 changed files with 7 additions and 180 deletions
|
@ -892,7 +892,7 @@ STR_0886 :Quit Game
|
|||
STR_0887 :Quit Scenario Editor
|
||||
STR_0888 :Quit Roller Coaster Designer
|
||||
STR_0889 :Quit Track Designs Manager
|
||||
STR_0890 :SCR{COMMA16}.BMP
|
||||
STR_0890 :<removed string - do not use>
|
||||
STR_0891 :Screenshot
|
||||
STR_0892 :Screenshot saved to disk as '{STRINGID}'
|
||||
STR_0893 :Screenshot failed !
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
- Feature: Allow setting ownership of map edges.
|
||||
- Feature: Allow up to 255 cars per train.
|
||||
- Feature: Importing SV4 and SC4 files with rides.
|
||||
- Removed: BMP screenshots.
|
||||
- Fix: [#1038] Guest List is out of order.
|
||||
- Fix: [#3282] Launched Freefall ride ratings are fixed for Downward Launch.
|
||||
- Fix: [#3307] Ride music and sound has degraded since RCT2.
|
||||
|
|
|
@ -90,12 +90,6 @@ typedef struct config_section_definition {
|
|||
|
||||
#pragma region Enum definitions
|
||||
|
||||
config_enum_definition _screenShotFormatEnum[] = {
|
||||
{ "BMP", SCREENSHOT_FORMAT_BMP },
|
||||
{ "PNG", SCREENSHOT_FORMAT_PNG },
|
||||
END_OF_ENUM
|
||||
};
|
||||
|
||||
config_enum_definition _measurementFormatEnum[] = {
|
||||
{ "IMPERIAL", MEASUREMENT_FORMAT_IMPERIAL },
|
||||
{ "METRIC", MEASUREMENT_FORMAT_METRIC },
|
||||
|
@ -180,7 +174,6 @@ config_property_definition _generalDefinitions[] = {
|
|||
{ offsetof(general_configuration, play_intro), "play_intro", CONFIG_VALUE_TYPE_BOOLEAN, false, NULL },
|
||||
{ offsetof(general_configuration, save_plugin_data), "save_plugin_data", CONFIG_VALUE_TYPE_BOOLEAN, false, NULL },
|
||||
{ offsetof(general_configuration, debugging_tools), "debugging_tools", CONFIG_VALUE_TYPE_BOOLEAN, false, NULL },
|
||||
{ offsetof(general_configuration, screenshot_format), "screenshot_format", CONFIG_VALUE_TYPE_UINT8, SCREENSHOT_FORMAT_PNG, _screenShotFormatEnum },
|
||||
{ offsetof(general_configuration, show_height_as_units), "show_height_as_units", CONFIG_VALUE_TYPE_BOOLEAN, false, NULL },
|
||||
{ offsetof(general_configuration, temperature_format), "temperature_format", CONFIG_VALUE_TYPE_UINT8, TEMPERATURE_FORMAT_C, _temperatureFormatEnum },
|
||||
{ offsetof(general_configuration, window_height), "window_height", CONFIG_VALUE_TYPE_SINT32, -1, NULL },
|
||||
|
|
|
@ -83,11 +83,6 @@ enum {
|
|||
SHORTCUT_COUNT
|
||||
};
|
||||
|
||||
enum {
|
||||
SCREENSHOT_FORMAT_BMP,
|
||||
SCREENSHOT_FORMAT_PNG
|
||||
};
|
||||
|
||||
enum {
|
||||
TEMPERATURE_FORMAT_C,
|
||||
TEMPERATURE_FORMAT_F
|
||||
|
|
125
src/image_io.c
125
src/image_io.c
|
@ -187,128 +187,3 @@ static void my_png_flush(png_structp png_ptr)
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
// Bitmap header structs, for cross platform purposes
|
||||
typedef struct BitmapFileHeader {
|
||||
uint16 bfType;
|
||||
uint32 bfSize;
|
||||
uint16 bfReserved1;
|
||||
uint16 bfReserved2;
|
||||
uint32 bfOffBits;
|
||||
} BitmapFileHeader;
|
||||
|
||||
typedef struct BitmapInfoHeader {
|
||||
uint32 biSize;
|
||||
sint32 biWidth;
|
||||
sint32 biHeight;
|
||||
uint16 biPlanes;
|
||||
uint16 biBitCount;
|
||||
uint32 biCompression;
|
||||
uint32 biSizeImage;
|
||||
sint32 biXPelsPerMeter;
|
||||
sint32 biYPelsPerMeter;
|
||||
uint32 biClrUsed;
|
||||
uint32 biClrImportant;
|
||||
} BitmapInfoHeader;
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00683D20
|
||||
*/
|
||||
bool image_io_bmp_write(const rct_drawpixelinfo *dpi, const rct_palette *palette, const utf8 *path)
|
||||
{
|
||||
BitmapFileHeader header;
|
||||
BitmapInfoHeader info;
|
||||
|
||||
int i, y, width, height, stride;
|
||||
uint8 *buffer, *row;
|
||||
SDL_RWops *fp;
|
||||
unsigned int bytesWritten;
|
||||
|
||||
// Open binary file for writing
|
||||
if ((fp = SDL_RWFromFile(path, "wb")) == NULL){
|
||||
return false;
|
||||
}
|
||||
|
||||
// Allocate buffer
|
||||
buffer = malloc(0xFFFF);
|
||||
if (buffer == NULL) {
|
||||
SDL_RWclose(fp);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get image size
|
||||
width = dpi->width;
|
||||
height = dpi->height;
|
||||
stride = dpi->width + dpi->pitch;
|
||||
|
||||
// File header
|
||||
memset(&header, 0, sizeof(header));
|
||||
header.bfType = 0x4D42;
|
||||
header.bfSize = height * stride + 1038;
|
||||
header.bfOffBits = 1038;
|
||||
|
||||
bytesWritten = SDL_RWwrite(fp, &header, sizeof(BitmapFileHeader), 1);
|
||||
if (bytesWritten != 1) {
|
||||
SDL_RWclose(fp);
|
||||
SafeFree(buffer);
|
||||
log_error("failed to save screenshot");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Info header
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.biSize = sizeof(info);
|
||||
info.biWidth = width;
|
||||
info.biHeight = height;
|
||||
info.biPlanes = 1;
|
||||
info.biBitCount = 8;
|
||||
info.biXPelsPerMeter = 2520;
|
||||
info.biYPelsPerMeter = 2520;
|
||||
info.biClrUsed = 246;
|
||||
|
||||
bytesWritten = SDL_RWwrite(fp, &info, sizeof(BitmapInfoHeader), 1);
|
||||
if (bytesWritten != 1) {
|
||||
SDL_RWclose(fp);
|
||||
SafeFree(buffer);
|
||||
log_error("failed to save screenshot");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Palette
|
||||
memset(buffer, 0, 246 * 4);
|
||||
for (i = 0; i < 246; i++) {
|
||||
const rct_palette_entry *entry = &palette->entries[i];
|
||||
buffer[i * 4 + 0] = entry->blue;
|
||||
buffer[i * 4 + 1] = entry->green;
|
||||
buffer[i * 4 + 2] = entry->red;
|
||||
}
|
||||
|
||||
bytesWritten = SDL_RWwrite(fp, buffer, sizeof(char), 246 * 4);
|
||||
if (bytesWritten != 246*4){
|
||||
SDL_RWclose(fp);
|
||||
SafeFree(buffer);
|
||||
log_error("failed to save screenshot");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Image, save upside down
|
||||
for (y = dpi->height - 1; y >= 0; y--) {
|
||||
row = dpi->bits + y * (dpi->width + dpi->pitch);
|
||||
|
||||
memset(buffer, 0, stride);
|
||||
memcpy(buffer, row, dpi->width);
|
||||
|
||||
bytesWritten = SDL_RWwrite(fp, buffer, sizeof(char), stride);
|
||||
if (bytesWritten != stride){
|
||||
SDL_RWclose(fp);
|
||||
SafeFree(buffer);
|
||||
log_error("failed to save screenshot");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_RWclose(fp);
|
||||
free(buffer);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,5 @@
|
|||
bool image_io_png_read(uint8 **pixels, uint32 *width, uint32 *height, const utf8 *path);
|
||||
|
||||
bool image_io_png_write(const rct_drawpixelinfo *dpi, const rct_palette *palette, const utf8 *path);
|
||||
bool image_io_bmp_write(const rct_drawpixelinfo *dpi, const rct_palette *palette, const utf8 *path);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -29,9 +29,6 @@
|
|||
#include "screenshot.h"
|
||||
#include "viewport.h"
|
||||
|
||||
static const char *_screenshot_format_extension[] = { ".bmp", ".png" };
|
||||
|
||||
static int screenshot_dump_bmp();
|
||||
static int screenshot_dump_png();
|
||||
|
||||
/**
|
||||
|
@ -75,7 +72,7 @@ static void screenshot_get_rendered_palette(rct_palette* palette) {
|
|||
}
|
||||
}
|
||||
|
||||
static int screenshot_get_next_path(char *path, int format)
|
||||
static int screenshot_get_next_path(char *path)
|
||||
{
|
||||
char screenshotPath[MAX_PATH];
|
||||
|
||||
|
@ -90,7 +87,7 @@ static int screenshot_get_next_path(char *path, int format)
|
|||
set_format_arg(0, uint16, i);
|
||||
|
||||
// Glue together path and filename
|
||||
sprintf(path, "%sSCR%d%s", screenshotPath, i, _screenshot_format_extension[format]);
|
||||
sprintf(path, "%sSCR%d.png", screenshotPath, i);
|
||||
|
||||
if (!platform_file_exists(path)) {
|
||||
return i;
|
||||
|
@ -103,39 +100,7 @@ static int screenshot_get_next_path(char *path, int format)
|
|||
|
||||
int screenshot_dump()
|
||||
{
|
||||
switch (gConfigGeneral.screenshot_format) {
|
||||
case SCREENSHOT_FORMAT_BMP:
|
||||
return screenshot_dump_bmp();
|
||||
case SCREENSHOT_FORMAT_PNG:
|
||||
return screenshot_dump_png();
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00683D20
|
||||
*/
|
||||
int screenshot_dump_bmp()
|
||||
{
|
||||
// Get a free screenshot path
|
||||
int index;
|
||||
char path[MAX_PATH] = "";
|
||||
if ((index = screenshot_get_next_path(path, SCREENSHOT_FORMAT_BMP)) == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
rct_drawpixelinfo *dpi = &gScreenDPI;
|
||||
|
||||
rct_palette renderedPalette;
|
||||
screenshot_get_rendered_palette(&renderedPalette);
|
||||
|
||||
if (image_io_bmp_write(dpi, &renderedPalette, path)) {
|
||||
return index;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
return screenshot_dump_png();
|
||||
}
|
||||
|
||||
int screenshot_dump_png()
|
||||
|
@ -143,7 +108,7 @@ int screenshot_dump_png()
|
|||
// Get a free screenshot path
|
||||
int index;
|
||||
char path[MAX_PATH] = "";
|
||||
if ((index = screenshot_get_next_path(path, SCREENSHOT_FORMAT_PNG)) == -1) {
|
||||
if ((index = screenshot_get_next_path(path)) == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -233,7 +198,7 @@ void screenshot_giant()
|
|||
// Get a free screenshot path
|
||||
char path[MAX_PATH];
|
||||
int index;
|
||||
if ((index = screenshot_get_next_path(path, SCREENSHOT_FORMAT_PNG)) == -1) {
|
||||
if ((index = screenshot_get_next_path(path)) == -1) {
|
||||
log_error("Giant screenshot failed, unable to find a suitable destination path.");
|
||||
window_error_open(STR_SCREENSHOT_FAILED, -1);
|
||||
return;
|
||||
|
|
|
@ -120,7 +120,6 @@ enum {
|
|||
STR_QUIT_SCENARIO_EDITOR = 887,
|
||||
STR_QUIT_ROLLERCOASTER_DESIGNER = 888,
|
||||
STR_QUIT_TRACK_DESIGNS_MANAGER = 889,
|
||||
STR_SCR_BMP = 890,
|
||||
STR_SCREENSHOT = 891,
|
||||
STR_SCREENSHOT_SAVED_AS = 892,
|
||||
STR_SCREENSHOT_FAILED = 893,
|
||||
|
|
Loading…
Add table
Reference in a new issue