Commits

Christian Fischer committed 5f72d5d

the new common library contains common interface implementations - at first moved the png-loading code from android to common

  • Participants
  • Parent commits cdecaa0

Comments (0)

Files changed (11)

File build/build.cmake

 set(WIESEL_SRC_DIR       ${WIESEL_DIR}/src)
 set(WIESEL_TESTS_DIR     ${WIESEL_DIR}/tests)
 set(WIESEL_MODULES_DIR   ${WIESEL_DIR}/libraries/desktop)
+set(WIESEL_GENERATED_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated)
+
+# all source-files can include from the "generated" dir
+include_directories(${WIESEL_GENERATED_DIR})
+
 
 # load standard modules
 include(wiesel-registry)
 
 # load optional config includes
 include(config/local/paths.cmake OPTIONAL)
-
-
-
-# enable warnings?
-option(WIESEL_BUILD_WARN_ALL "Enable all warnings on build. (gcc option -Wall)" ON)
-if (WIESEL_BUILD_WARN_ALL)
-	set(CMAKE_CXX_FLAGS "-g -Wall")
-	set(CMAKE_C_FLAGS "-g -Wall")
+
+
+
+# enable warnings?
+option(WIESEL_BUILD_WARN_ALL "Enable all warnings on build. (gcc option -Wall)" ON)
+if (WIESEL_BUILD_WARN_ALL)
+	set(CMAKE_CXX_FLAGS "-g -Wall")
+	set(CMAKE_C_FLAGS "-g -Wall")
 endif(WIESEL_BUILD_WARN_ALL)
-
-
-
-
-# on win32 we may need to copy all SDL DLL's to our binary directory
-if (WIN32)
-	if (DEFINED EXTRALIBS_PATH)
-		file(GLOB DLLS_TO_COPY ${EXTRALIBS_PATH}/bin/*.dll)
-		file(COPY ${DLLS_TO_COPY} DESTINATION .)
-	endif()
+
+
+
+
+# on win32 we may need to copy all SDL DLL's to our binary directory
+if (WIN32)
+	if (DEFINED EXTRALIBS_PATH)
+		file(GLOB DLLS_TO_COPY ${EXTRALIBS_PATH}/bin/*.dll)
+		file(COPY ${DLLS_TO_COPY} DESTINATION .)
+	endif()
 endif()

File build/cmake/modules/wiesel-module.cmake

 
 
 function(wiesel_create_executable target source_dir)
-	set(MODULE_REGISTRY_FILE ${CMAKE_CURRENT_BINARY_DIR}/generated/${target}-module-registry.cpp)
+	set(MODULE_REGISTRY_FILE ${WIESEL_GENERATED_DIR}/${target}-module-registry.cpp)
 
 	# get all sources from this directory
 	wiesel_module_get_files(MODULE_SRC_FILES ${source_dir})

File build/cmake/modules/wiesel-registry.cmake

 
 function(wiesel_module_export_loaders module)
 	set_property(TARGET ${module} APPEND PROPERTY EXPORT_MODULE_LOADERS ${ARGN})
-	
-	foreach(loader ${ARGN})
-		message("${module} exports loader: ${loader}")
-	endforeach()
 endfunction(wiesel_module_export_loaders)
 
 

File libraries/desktop/wiesel-common/module.cmake

+# wiesel-common library
+
+
+# create the Extras module
+wiesel_create_module(wiesel-common ${WIESEL_SRC_DIR}/common ${WIESEL_TESTS_DIR}/common)
+
+# export include directories of this library for other targets
+wiesel_module_export_includes(wiesel-common ${WIESEL_SRC_DIR}/common)
+
+# add required modules
+wiesel_module_add_dependency(wiesel-common wiesel-base)
+wiesel_module_add_dependency(wiesel-common wiesel-core)
+
+
+# check if libpng is available
+include(FindPNG)
+
+if(PNG_FOUND)
+	wiesel_target_add_includes(wiesel-common ${PNG_INCLUDE_DIRS})
+	wiesel_target_add_libraries(wiesel-common ${PNG_LIBRARIES})
+	wiesel_target_add_compileflags(wiesel-common ${PNG_DEFINITIONS})
+
+	set(WIESEL_SUPPORTS_LIBPNG		TRUE)
+else()
+	set(WIESEL_SUPPORTS_LIBPNG		FALSE)
+endif()
+
+
+# finally, create the config file
+configure_file(
+		${WIESEL_SRC_DIR}/common/wiesel/wiesel-common-config.in
+		${WIESEL_GENERATED_DIR}/wiesel/wiesel-common-config.h
+)

File samples/HelloWiesel/CMakeLists.txt

 # add required libraries
 wiesel_module_add_dependency(HelloWiesel wiesel-base)
 wiesel_module_add_dependency(HelloWiesel wiesel-core)
+wiesel_module_add_dependency(HelloWiesel wiesel-common)
 wiesel_module_add_dependency(HelloWiesel wiesel-sdl)
 
 wiesel_target_add_compileflags(HelloWiesel "-DWIESEL_USE_LIBSDL")

File src/common/wiesel/resources/graphics/image_loader_libpng.cpp

+/**
+ * Copyright (C) 2012
+ * Christian Fischer
+ *
+ * https://bitbucket.org/baldur/wiesel/
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+#include "image_loader_libpng.h"
+
+#include "wiesel/resources/graphics/imageutils.h"
+
+#if WIESEL_SUPPORTS_LIBPNG
+
+#include "wiesel/util/log.h"
+#include <inttypes.h>
+#include <png.h>
+
+using namespace wiesel;
+
+
+struct PNG_BufferObject
+{
+	DataBuffer *buffer;
+	size_t offset;
+};
+
+
+// callback method to feed the PNG decoder with data from our buffer.
+static void pngReadCallback(png_structp png_ptr, png_bytep data, png_size_t length) {
+	PNG_BufferObject *buffer = (PNG_BufferObject*)png_get_io_ptr(png_ptr);
+	size_t buffer_size = buffer->buffer->getSize();
+
+	// fail, when reading beyond buffer
+	if ((buffer->offset + length) > buffer_size) {
+	//	length = buffer_size - buffer->offset;
+		png_error(png_ptr, "pngReaderCallback failed");
+	}
+
+	const unsigned char *buffer_data = buffer->buffer->getData() + buffer->offset;
+	memcpy(data, buffer_data, length);
+	buffer->offset += length;
+}
+
+
+
+LibPngImageLoader *LibPngImageLoader::create() {
+	return new LibPngImageLoader();
+}
+
+LibPngImageLoader::LibPngImageLoader() {
+	return;
+}
+
+LibPngImageLoader::~LibPngImageLoader() {
+	return;
+}
+
+
+
+Image *LibPngImageLoader::loadImage(DataSource *source) {
+	return internal_loadImage(source, NULL, false);
+}
+
+
+Image *LibPngImageLoader::loadPowerOfTwoImage(DataSource *source, dimension *pOriginal_size) {
+	return internal_loadImage(source, pOriginal_size, true);
+}
+
+
+Image *LibPngImageLoader::internal_loadImage(DataSource *source, dimension *pOriginalSize, bool pot) {
+	png_structp png_ptr;
+	png_infop info_ptr;
+	int bit_depth;
+	int color_type;
+	int interlace_type;
+	png_uint_32 width;
+	png_uint_32 height;
+	png_uint_32 original_width;
+	png_uint_32 original_height;
+	FILE* fp = NULL;
+
+	// Create and initialize the png_struct with the desired error handler functions.
+	png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+	if (png_ptr == NULL) {
+		return NULL;
+	}
+
+	// Allocate/initialize the memory for image information.
+	info_ptr = png_create_info_struct(png_ptr);
+	if (info_ptr == NULL) {
+		png_destroy_read_struct(&png_ptr, NULL, NULL);
+		return NULL;
+	}
+
+	bool io_initialized = false;
+	FileDataSource *filedata = dynamic_cast<FileDataSource*>(source);
+	if (filedata) {
+		File *file = filedata->getFile();
+
+		// open the file
+		if ((fp = fopen(file->getFullPath().c_str(), "rb")) != NULL) {
+			// get first bytes and check if the file is a valid PNG file
+			uint64_t header;
+			if (
+					fread(&header, 1, 8, fp) != 8
+				||	png_sig_cmp(reinterpret_cast<png_byte*>(&header), 0, 8) != 0
+			) {
+				return NULL;
+			}
+
+			// initialize png read struct
+			png_init_io(png_ptr, fp);
+
+			// success
+			io_initialized = true;
+		}
+
+		// maybe the file could not be opened, because it's not from a real file-system,
+		// so try the buffer-access now
+	}
+
+	if (io_initialized == false) {
+		DataBuffer *buffer = source->getDataBuffer();
+
+		// we need to cheat, because some PNG headers seems to require non-const data
+		png_bytep data_bytes = const_cast<png_bytep>(buffer->getData());
+
+		// check, if PNG file is valid
+		if (
+				buffer->getSize() < 8
+			||	png_sig_cmp(data_bytes, 0, 8) != 0
+		) {
+			return NULL;
+		}
+
+		PNG_BufferObject readbuffer;
+		readbuffer.buffer = buffer;
+		readbuffer.offset = 0;
+		png_set_read_fn(png_ptr, &readbuffer, pngReadCallback);
+
+		io_initialized = true;
+	}
+
+	if (io_initialized == false) {
+		return NULL;
+	}
+
+	// read png
+	// PNG_TRANSFORM_EXPAND:      perform set_expand()
+	// PNG_TRANSFORM_PACKING:     expand 1, 2 and 4-bit samples to bytes
+	// PNG_TRANSFORM_STRIP_16:    strip 16-bit samples to 8 bits
+	// PNG_TRANSFORM_GRAY_TO_RGB: expand grayscale samples to RGB (or GA to RGBA)
+	png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_EXPAND | PNG_TRANSFORM_PACKING | PNG_TRANSFORM_STRIP_16 | PNG_TRANSFORM_GRAY_TO_RGB, 0);
+
+	png_get_IHDR(png_ptr, info_ptr, &original_width, &original_height, &bit_depth, &color_type, &interlace_type, 0, 0);
+
+	// when we're loading a texture, we may need a power-of-two size
+	if (pot) {
+		width  = getNextPowerOfTwo(original_width);
+		height = getNextPowerOfTwo(original_height);
+	}
+	else {
+		width  = original_width;
+		height = original_height;
+	}
+
+	// init image info
+	bool has_alpha = (color_type & PNG_COLOR_MASK_ALPHA) ? true : false;
+	int bytesPerPixel = has_alpha ? 4 : 3;
+	PixelFormat pixel_format;
+
+	// determine pixelformat
+	if (has_alpha) {
+		pixel_format = PixelFormat_RGBA_8888;
+	}
+	else {
+		pixel_format = PixelFormat_RGB_888;
+	}
+
+	// allocate memory and read data
+	unsigned char *image_data = reinterpret_cast<unsigned char*>(malloc(width * height * bytesPerPixel));
+	if (image_data == NULL) {
+		return NULL;
+	}
+
+	png_bytep *png_rows = png_get_rows(png_ptr, info_ptr);
+
+	// copy data to image info
+	int bytesPerRowSrc = original_width * bytesPerPixel;
+	int bytesPerRowDst = width * bytesPerPixel;
+	int gap            = bytesPerRowDst - bytesPerRowSrc;
+	for(unsigned int row=0; row<original_height; ++row) {
+		// copy the entire line
+		memcpy(image_data + (row * bytesPerRowDst), png_rows[row], bytesPerRowSrc);
+
+		// fill the gap to the next line with transparent black color
+		memset(image_data + (row * bytesPerRowDst) + bytesPerRowSrc, 0x00, gap);
+	}
+
+	// fill empty space of resized area
+	memset(
+			image_data + (original_height * bytesPerRowDst),
+			0x00,
+			(height - original_height) * bytesPerRowDst
+	);
+
+	// create the image object
+	Image *image = new Image(
+			new ExclusiveDataBuffer(image_data, width * height * bytesPerPixel),
+			pixel_format,
+			dimension(width, height)
+	);
+
+	// store original size if requested
+	if (pOriginalSize) {
+		pOriginalSize->width  = original_width;
+		pOriginalSize->height = original_height;
+	}
+
+	// clear the png data
+	png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+
+	// close the file (if any opened)
+	if (fp) {
+		fclose(fp);
+	}
+
+	return image;
+}
+
+#endif // WIESEL_SUPPORTS_LIBPNG
+

File src/common/wiesel/resources/graphics/image_loader_libpng.h

+/**
+ * Copyright (C) 2012
+ * Christian Fischer
+ *
+ * https://bitbucket.org/baldur/wiesel/
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+#ifndef __WIESEL_RESOURCES_IMAGES_IMAGELOADER_LIBPNG_H__
+#define __WIESEL_RESOURCES_IMAGES_IMAGELOADER_LIBPNG_H__
+
+#include <wiesel/io/databuffer.h>
+#include <wiesel/io/file.h>
+#include <wiesel/modules.h>
+#include <wiesel/resources/graphics/image_loader.h>
+#include <wiesel/wiesel-common-config.h>
+#include <wiesel/wiesel-common.def>
+
+
+#if WIESEL_SUPPORTS_LIBPNG
+
+namespace wiesel {
+
+	class WIESEL_COMMON_EXPORT LibPngImageLoader : public IImageLoader
+	{
+	private:
+		LibPngImageLoader();
+
+	public:
+		static LibPngImageLoader *create();
+
+		virtual ~LibPngImageLoader();
+
+
+		virtual Image *loadImage(DataSource *source);
+		virtual Image *loadPowerOfTwoImage(DataSource *source, dimension *pOriginal_size);
+
+	private:
+		virtual Image *internal_loadImage(DataSource *source, dimension *pOriginalSize, bool pot);
+	};
+}
+
+#endif // WIESEL_SUPPORTS_LIBPNG
+
+#endif // __WIESEL_RESOURCES_IMAGES_IMAGELOADER_LIBPNG_H__

File src/common/wiesel/resources/graphics/image_loader_libpng.loadable_module

+
+#include "image_loader_libpng.h"
+
+
+#if WIESEL_SUPPORTS_LIBPNG
+
+	// add the module to the module registry
+	namespace wiesel {
+		REGISTER_MODULE_SINGLETON(
+				IImageLoader,
+				LibPngImageLoader,
+				&LibPngImageLoader::create,
+				"LibPNG",
+				0x01050000u,
+				IModuleLoader::PriorityHigh
+		)
+	}
+
+#endif // WIESEL_SUPPORTS_LIBPNG

File src/common/wiesel/wiesel-common-config.in

+/**
+ * Copyright (C) 2012
+ * Christian Fischer
+ *
+ * https://bitbucket.org/baldur/wiesel/
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+#ifndef __WIESEL_COMMON_CONFIG_H__
+#define __WIESEL_COMMON_CONFIG_H__
+
+
+// enables support for libpng
+#cmakedefine01 WIESEL_SUPPORTS_LIBPNG
+
+
+#endif // __WIESEL_COMMON_CONFIG_H__

File src/common/wiesel/wiesel-common.def

+/**
+ * Copyright (C) 2012
+ * Christian Fischer
+ *
+ * https://bitbucket.org/baldur/wiesel/
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+#ifndef __WIESEL_COMMON_DEF_H__
+#define __WIESEL_COMMON_DEF_H__
+
+/**
+ * some defines and flags specially for the wiesel-common library
+ */
+
+#if defined(_WIN32)
+	#if defined(wiesel_common_EXPORTS)
+		#define WIESEL_COMMON_EXPORT		__declspec(dllexport)
+	#else
+		#define WIESEL_COMMON_EXPORT		__declspec(dllimport)
+	#endif
+#else
+		#define WIESEL_COMMON_EXPORT
+#endif
+
+
+#endif // __WIESEL_COMMON_DEF_H__

File src/core/wiesel/platform/android/file_support/android_filesupport_png.cpp

-/**
- * Copyright (C) 2012
- * Christian Fischer
- *
- * https://bitbucket.org/baldur/wiesel/
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-#ifdef __ANDROID__
-
-#include "../android_engine.h"
-#include "wiesel/io/file.h"
-#include "wiesel/util/log.h"
-#include "wiesel/util/imageutils.h"
-#include <png.h>
-
-using namespace wiesel;
-
-
-struct PNG_BufferObject
-{
-	DataBuffer *buffer;
-	size_t offset;
-};
-
-
-// callback method to feed the PNG decoder with data from our buffer.
-static void pngReadCallback(png_structp png_ptr, png_bytep data, png_size_t length) {
-	PNG_BufferObject *buffer = (PNG_BufferObject*)png_get_io_ptr(png_ptr);
-	size_t buffer_size = buffer->buffer->getSize();
-
-	// fail, when reading beyond buffer
-	if ((buffer->offset + length) > buffer_size) {
-	//	length = buffer_size - buffer->offset;
-		png_error(png_ptr, "pngReaderCallback failed");
-	}
-
-	const unsigned char *buffer_data = buffer->buffer->getData() + buffer->offset;
-	memcpy(data, buffer_data, length);
-	buffer->offset += length;
-}
-
-
-
-bool AndroidEngine::decodeImage_PNG(
-		DataSource *data,
-		unsigned char **pBuffer, size_t *pSize,
-		unsigned int *pWidth, unsigned int *pHeight,
-		unsigned int *pOriginalWidth, unsigned int *pOriginalHeight,
-		int *pRbits, int *pGbits, int *pBbits, int *pAbits,
-		bool as_texture
-) {
-	png_structp png_ptr;
-	png_infop info_ptr;
-	unsigned int sig_read = 0;
-	int bit_depth;
-	int color_type;
-	int interlace_type;
-	png_uint_32 width;
-	png_uint_32 height;
-	png_uint_32 original_width;
-	png_uint_32 original_height;
-	FILE* fp = NULL;
-
-	// Create and initialize the png_struct with the desired error handler functions.
-	png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
-	if (png_ptr == NULL) {
-		return false;
-	}
-
-	// Allocate/initialize the memory for image information.
-	info_ptr = png_create_info_struct(png_ptr);
-	if (info_ptr == NULL) {
-		png_destroy_read_struct(&png_ptr, NULL, NULL);
-		return false;
-	}
-
-	bool io_initialized = false;
-	FileDataSource *filedata = dynamic_cast<FileDataSource*>(data);
-	if (filedata) {
-		File *file = filedata->getFile();
-
-		// open the file
-		if ((fp = fopen(file->getFullPath().c_str(), "rb")) != NULL) {
-			png_init_io(png_ptr, fp);
-
-			// success
-			io_initialized = true;
-		}
-
-		// maybe the file could not be opened, because it's not from a real file-system,
-		// so try the buffer-access now
-	}
-
-	if (io_initialized == false) {
-		PNG_BufferObject readbuffer;
-		readbuffer.buffer = data->getDataBuffer();
-		readbuffer.offset = 0;
-        png_set_read_fn(png_ptr, &readbuffer, pngReadCallback);
-
-        io_initialized = true;
-	}
-
-	if (io_initialized == false) {
-		Log::info << "loading from source failed" << std::endl;
-		return false;
-	}
-
-	// read png
-	// PNG_TRANSFORM_EXPAND:      perform set_expand()
-	// PNG_TRANSFORM_PACKING:     expand 1, 2 and 4-bit samples to bytes
-	// PNG_TRANSFORM_STRIP_16:    strip 16-bit samples to 8 bits
-	// PNG_TRANSFORM_GRAY_TO_RGB: expand grayscale samples to RGB (or GA to RGBA)
-	png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_EXPAND | PNG_TRANSFORM_PACKING | PNG_TRANSFORM_STRIP_16 | PNG_TRANSFORM_GRAY_TO_RGB, 0);
-
-	png_get_IHDR(png_ptr, info_ptr, &original_width, &original_height, &bit_depth, &color_type, &interlace_type, 0, 0);
-
-	// when we're loading a texture, we may need a power-of-two size
-	if (as_texture) {
-		width  = imageutils::getNextPowerOfTwo(original_width);
-		height = imageutils::getNextPowerOfTwo(original_height);
-	}
-	else {
-		width  = original_width;
-		height = original_height;
-	}
-
-	// init image info
-	bool has_alpha = (color_type & PNG_COLOR_MASK_ALPHA) ? true : false;
-	int bytesPerPixel = has_alpha ? 4 : 3;
-
-	// allocate memory and read data
-	unsigned char *image_data = reinterpret_cast<unsigned char*>(malloc(width * height * bytesPerPixel));
-	if (image_data == NULL) {
-		return false;
-	}
-
-	png_bytep *png_rows = png_get_rows(png_ptr, info_ptr);
-
-	// copy data to image info
-	int bytesPerRowSrc = original_width * bytesPerPixel;
-	int bytesPerRowDst = width * bytesPerPixel;
-	int gap            = bytesPerRowDst - bytesPerRowSrc;
-	for(unsigned int row=0; row<original_height; ++row) {
-		// copy the entire line
-		memcpy(image_data + (row * bytesPerRowDst), png_rows[row], bytesPerRowSrc);
-
-		// fill the gap to the next line with transparent black color
-		memset(image_data + (row * bytesPerRowDst) + bytesPerRowSrc, 0x00, gap);
-	}
-
-	// fill empty space of resized area
-	memset(
-			image_data + (original_height * bytesPerRowDst),
-			0x00,
-			(height - original_height) * bytesPerRowDst
-	);
-
-	// copy data into output pointers
-	if (pRbits)  *pRbits  = bit_depth;
-	if (pGbits)  *pGbits  = bit_depth;
-	if (pBbits)  *pBbits  = bit_depth;
-	if (pAbits)  *pAbits  = has_alpha ? bit_depth : 0;
-	if (pWidth)  *pWidth  = width;
-	if (pHeight) *pHeight = height;
-	if (pSize)   *pSize   = width * height * bytesPerPixel;
-
-	if  (pOriginalWidth) {
-		*pOriginalWidth = original_width;
-	}
-
-	if  (pOriginalHeight) {
-		*pOriginalHeight = original_height;
-	}
-
-	if  (pBuffer) {
-		*pBuffer = image_data;
-	}
-	else {
-		// when no buffer-pointer was provided, delete the image data
-		free(image_data);
-	}
-
-	// clear the png data
-	png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
-
-	// close the file (if any opened)
-	if (fp) {
-		fclose(fp);
-	}
-
-	return true;
-}
-
-#endif // __ANDROID__