From 859946876045806c3d305694b20a4fda3b819627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sat, 23 Jan 2016 17:13:15 +0100 Subject: [PATCH] Cleanup unused lodepng stuff --- CMakeLists.txt | 1 - OpenRCT2.xcodeproj/project.pbxproj | 2 - distribution/readme.txt | 1 - openrct2.vcxproj | 6 +-- src/image_io.c | 77 ++---------------------------- 5 files changed, 7 insertions(+), 80 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 101a61a550..6509c2ab1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,6 @@ project(${PROJECT}) add_definitions(-DORCT2_RESOURCE_DIR="${ORCT2_RESOURCE_DIR}") add_definitions(-DHAVE_CONFIG_H) add_definitions(-DCURL_STATICLIB) -add_definitions(-DUSE_LIBPNG) INCLUDE(FindPkgConfig) diff --git a/OpenRCT2.xcodeproj/project.pbxproj b/OpenRCT2.xcodeproj/project.pbxproj index f22aa4ea58..b76cf0f63e 100644 --- a/OpenRCT2.xcodeproj/project.pbxproj +++ b/OpenRCT2.xcodeproj/project.pbxproj @@ -1513,7 +1513,6 @@ GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", - USE_LIBPNG, ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; @@ -1556,7 +1555,6 @@ GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; - GCC_PREPROCESSOR_DEFINITIONS = USE_LIBPNG; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; diff --git a/distribution/readme.txt b/distribution/readme.txt index 97e36f5d57..384e065b5c 100644 --- a/distribution/readme.txt +++ b/distribution/readme.txt @@ -147,7 +147,6 @@ OpenRCT2 is licensed under the GNU General Public Licence version 3.0. For the complete licence text, see the file 'licence.txt'. This licence applies to all files in this distribution, except as noted below. -argparse | MIT licence. Jansson | MIT licence. libcURL | MIT (or Modified BSD-style) licence. libspeex | BSD-style license. diff --git a/openrct2.vcxproj b/openrct2.vcxproj index 215b153a01..7831d3b315 100644 --- a/openrct2.vcxproj +++ b/openrct2.vcxproj @@ -338,7 +338,7 @@ Disabled true 1Byte - $(OpenRCT2_DEFINES);DEBUG;USE_LIBPNG;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + $(OpenRCT2_DEFINES);DEBUG;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreaded true $(IntDir)\%(RelativeDir) @@ -364,7 +364,7 @@ 4013 false - $(OpenRCT2_DEFINES);USE_LIBPNG;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;%(PreprocessorDefinitions) + $(OpenRCT2_DEFINES);_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;%(PreprocessorDefinitions) $(IntDir)\%(RelativeDir) true Speed @@ -379,4 +379,4 @@ - \ No newline at end of file + diff --git a/src/image_io.c b/src/image_io.c index 4ff6d93f1a..c78fa9c4ca 100644 --- a/src/image_io.c +++ b/src/image_io.c @@ -1,20 +1,13 @@ -#ifdef USE_LIBPNG - #include -#else - #include -#endif +#include #include "image_io.h" -#ifdef USE_LIBPNG - static void my_png_read_data(png_structp png_ptr, png_bytep data, png_size_t length); - static void my_png_write_data(png_structp png_ptr, png_bytep data, png_size_t length); - static void my_png_flush(png_structp png_ptr); -#endif +static void my_png_read_data(png_structp png_ptr, png_bytep data, png_size_t length); +static void my_png_write_data(png_structp png_ptr, png_bytep data, png_size_t length); +static void my_png_flush(png_structp png_ptr); bool image_io_png_read(uint8 **pixels, uint32 *width, uint32 *height, const utf8 *path) { -#ifdef USE_LIBPNG png_structp png_ptr; png_infop info_ptr; unsigned int sig_read = 0; @@ -91,28 +84,10 @@ bool image_io_png_read(uint8 **pixels, uint32 *width, uint32 *height, const utf8 if (width != NULL) *width = pngWidth; if (height != NULL) *height = pngHeight; return true; -#else - // Read the pixels as 32bpp RGBA - unsigned char *pngPixels; - unsigned int pngWidth, pngHeight; - unsigned int pngError = lodepng_decode_file(&pngPixels, &pngWidth, &pngHeight, path, LCT_RGBA, 8); - if (pngError != 0) { - free(pngPixels); - log_error("Error creating PNG data, %u: %s", pngError, lodepng_error_text(pngError)); - return false; - } - - // Return the output data - *pixels = (uint8*)pngPixels; - if (width != NULL) *width = pngWidth; - if (height != NULL) *height = pngHeight; - return true; -#endif } bool image_io_png_write(const rct_drawpixelinfo *dpi, const rct_palette *palette, const utf8 *path) { -#ifdef USE_LIBPNG // Get image size int stride = dpi->width + dpi->pitch; @@ -178,50 +153,8 @@ bool image_io_png_write(const rct_drawpixelinfo *dpi, const rct_palette *palette png_free(png_ptr, png_palette); png_destroy_write_struct(&png_ptr, &info_ptr); return true; -#else - unsigned int error; - unsigned char* png; - size_t pngSize; - LodePNGState state; - - lodepng_state_init(&state); - state.info_raw.colortype = LCT_PALETTE; - - // Get image size - int stride = dpi->width + dpi->pitch; - - lodepng_palette_add(&state.info_raw, 0, 0, 0, 0); - for (int i = 1; i < 256; i++) { - const rct_palette_entry *entry = &palette->entries[i]; - uint8 r = entry->red; - uint8 g = entry->green; - uint8 b = entry->blue; - uint8 a = 255; - lodepng_palette_add(&state.info_raw, r, g, b, a); - } - - error = lodepng_encode(&png, &pngSize, dpi->bits, stride, dpi->height, &state); - if (error != 0) { - log_error("Error creating PNG data, %u: %s", error, lodepng_error_text(error)); - free(png); - return false; - } else { - SDL_RWops *file = SDL_RWFromFile(path, "wb"); - if (file == NULL) { - free(png); - return false; - } - SDL_RWwrite(file, png, pngSize, 1); - SDL_RWclose(file); - } - - free(png); - return true; -#endif } -#ifdef USE_LIBPNG - static void my_png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { SDL_RWops *file = (SDL_RWops*)png_get_io_ptr(png_ptr); @@ -239,8 +172,6 @@ static void my_png_flush(png_structp png_ptr) } -#endif - // Bitmap header structs, for cross platform purposes typedef struct { uint16 bfType;