summaryrefslogtreecommitdiff
path: root/plugingui/image.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2013-09-20 22:19:39 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2013-09-20 22:19:39 +0200
commit3d0ed93889afb5ae739d2998e33178689c2de965 (patch)
tree6963941e3ba16baa4592805b0841d34fc4e33a57 /plugingui/image.cc
parentd1d257dea150d79bedcf691d4aaac429b621de46 (diff)
Remove non-working png hack.
Diffstat (limited to 'plugingui/image.cc')
-rw-r--r--plugingui/image.cc43
1 files changed, 20 insertions, 23 deletions
diff --git a/plugingui/image.cc b/plugingui/image.cc
index 817fe05..cba27fc 100644
--- a/plugingui/image.cc
+++ b/plugingui/image.cc
@@ -37,9 +37,6 @@
#include "resource.h"
// http://blog.hammerian.net/2009/reading-png-images-from-memory/
-#define PNG_PREFIX(x) dg_##x
-//#define PNG_PREFIX(x) x
-
typedef struct {
size_t p;
size_t size;
@@ -48,10 +45,10 @@ typedef struct {
static void dio_reader(png_structp png_ptr, png_bytep buf, png_size_t size)
{
- data_io_t *dio = (data_io_t *)PNG_PREFIX(png_get_io_ptr(png_ptr));
+ data_io_t *dio = (data_io_t *)png_get_io_ptr(png_ptr);
if(size > dio->size - dio->p) {
- PNG_PREFIX(png_error(png_ptr, "Could not read bytes."));
+ png_error(png_ptr, "Could not read bytes.");
}
memcpy(buf, (dio->data + dio->p), size);
@@ -118,7 +115,7 @@ void GUI::Image::load(const char* data, size_t size)
const char *header = data;
// test for it being a png:
- if(PNG_PREFIX(png_sig_cmp((png_byte*)header, 0, 8))) {
+ if(png_sig_cmp((png_byte*)header, 0, 8)) {
ERR(image, "[read_png_file] File is not recognized as a PNG file");
setError(0);
return;
@@ -126,7 +123,7 @@ void GUI::Image::load(const char* data, size_t size)
// initialize stuff
png_ptr =
- PNG_PREFIX(png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL));
+ png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if(!png_ptr) {
ERR(image, "[read_png_file] png_create_read_struct failed");
@@ -134,18 +131,18 @@ void GUI::Image::load(const char* data, size_t size)
return;
}
- info_ptr = PNG_PREFIX(png_create_info_struct(png_ptr));
+ info_ptr = png_create_info_struct(png_ptr);
if(!info_ptr) {
ERR(image, "[read_png_file] png_create_info_struct failed");
setError(2);
- PNG_PREFIX(png_destroy_read_struct(&png_ptr, NULL, NULL));
+ png_destroy_read_struct(&png_ptr, NULL, NULL);
return;
}
- if(setjmp(PNG_PREFIX(png_jmpbuf(png_ptr)))) {
+ if(setjmp(png_jmpbuf(png_ptr))) {
ERR(image, "[read_png_file] Error during init_io");
setError(3);
- PNG_PREFIX(png_destroy_read_struct(&png_ptr, &info_ptr, NULL));
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
return;
}
@@ -154,37 +151,37 @@ void GUI::Image::load(const char* data, size_t size)
dio.data = data;
dio.size = size;
dio.p = 8; // skip header
- PNG_PREFIX(png_set_read_fn(png_ptr, &dio, dio_reader));
+ png_set_read_fn(png_ptr, &dio, dio_reader);
- PNG_PREFIX(png_set_sig_bytes(png_ptr, 8));
+ png_set_sig_bytes(png_ptr, 8);
- PNG_PREFIX(png_read_info(png_ptr, info_ptr));
+ png_read_info(png_ptr, info_ptr);
- w = PNG_PREFIX(png_get_image_width(png_ptr, info_ptr));
- h = PNG_PREFIX(png_get_image_height(png_ptr, info_ptr));
+ w = png_get_image_width(png_ptr, info_ptr);
+ h = png_get_image_height(png_ptr, info_ptr);
//color_type = png_get_color_type(png_ptr, info_ptr);
//bit_depth = png_get_bit_depth(png_ptr, info_ptr);
- number_of_passes = PNG_PREFIX(png_set_interlace_handling(png_ptr));
- PNG_PREFIX(png_read_update_info(png_ptr, info_ptr));
+ number_of_passes = png_set_interlace_handling(png_ptr);
+ png_read_update_info(png_ptr, info_ptr);
// read file
- if(setjmp(PNG_PREFIX(png_jmpbuf(png_ptr)))) {
+ if(setjmp(png_jmpbuf(png_ptr))) {
ERR(image, "[read_png_file] Error during read_image");
setError(4);
- PNG_PREFIX(png_destroy_read_struct(&png_ptr, &info_ptr, NULL));
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
return;
}
row_pointers = (png_bytep*) malloc(sizeof(png_bytep) * h);
for(size_t y = 0; y < h; y++) {
row_pointers[y] =
- (png_byte*) malloc(PNG_PREFIX(png_get_rowbytes(png_ptr, info_ptr)));
+ (png_byte*) malloc(png_get_rowbytes(png_ptr, info_ptr));
}
- PNG_PREFIX(png_read_image(png_ptr, row_pointers));
+ png_read_image(png_ptr, row_pointers);
- PNG_PREFIX(png_destroy_read_struct(&png_ptr, &info_ptr, NULL));
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
}
size_t GUI::Image::width()