[PATCH] Fix tuxonice-userui compilation with libpng-1.5
Harald Judt <[email protected]>
| Newsgroups | gmane.linux.swsusp.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, I'm using tuxonice-userui from git.tuxonice.net, and upgrading to libpng-1.5 on my box broke it, so I decided to try and fix it. The patch should be valid for all libpng versions. It compiles now, but I did not test it because I don't use fbsplash anymore. Regards, Harald -- `Experience is the best teacher.' _______________________________________________ TuxOnIce-devel mailing list [email protected] http://lists.tuxonice.net/listinfo/tuxonice-devel
tuxoniceui-fix-compilation-with-libpng-1.5.patch
(text/x-patch, 4.6 KB)
From cca9a0e100cb1319546f4e8382e7ac0dd6be15a7 Mon Sep 17 00:00:00 2001 From: Harald Judt <[email protected]> Date: Thu, 2 Nov 2011 09:09:52 +0100 Subject: [PATCH] Fix compilation with libpng-1.5. This patch should make TuxOnIceUI work with libpng-1.5. It should still work for <libpng-1.5, as the website states: "The libpng 1.5.x series continues the evolution of the libpng API, finally hiding the contents of the venerable and hoary png_struct and png_info data structures inside private (i.e., non-installed) header files. Instead of direct struct-access, applications should be using the various png_get_xxx() and png_set_xxx() accessor functions, which have existed for almost as long as libpng itself." --- fbsplash/image.c | 36 +++++++++++++++++++++--------------- 1 files changed, 21 insertions(+), 15 deletions(-) diff --git a/fbsplash/image.c b/fbsplash/image.c index ba31328..4378553 100644 --- a/fbsplash/image.c +++ b/fbsplash/image.c @@ -78,7 +78,9 @@ int load_png(char *filename, u8 **data, struct fb_cmap *cmap, unsigned int *widt png_structp png_ptr; png_infop info_ptr, end_info; png_bytep row_pointer; + png_byte color_type; png_colorp palette; + png_uint_32 img_width, img_height; int rowbytes, num_palette; int i, j, bytespp = (fb_var.bits_per_pixel + 7) >> 3; u8 *buf = NULL; @@ -118,29 +120,30 @@ int load_png(char *filename, u8 **data, struct fb_cmap *cmap, unsigned int *widt png_init_io(png_ptr, fp); png_read_info(png_ptr, info_ptr); - if (cmap && info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) { + color_type = png_get_color_type(png_ptr, info_ptr); + + if (cmap && color_type != PNG_COLOR_TYPE_PALETTE) { printk("Could not read file %s. Not a palette-based image.\n", filename); goto failed; } - if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY || - info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) png_set_gray_to_rgb(png_ptr); - if (info_ptr->bit_depth == 16) + if (png_get_bit_depth(png_ptr, info_ptr) == 16) png_set_strip_16(png_ptr); - if (!want_alpha && info_ptr->color_type & PNG_COLOR_MASK_ALPHA) + if (!want_alpha && color_type & PNG_COLOR_MASK_ALPHA) png_set_strip_alpha(png_ptr); #ifndef TARGET_KERNEL - if (!(info_ptr->color_type & PNG_COLOR_MASK_ALPHA) & want_alpha) { + if ((!(color_type & PNG_COLOR_MASK_ALPHA)) & want_alpha) { png_set_add_alpha(png_ptr, 0xff, PNG_FILLER_AFTER); } #endif png_read_update_info(png_ptr, info_ptr); - if (!cmap && info_ptr->color_type != PNG_COLOR_TYPE_RGB && info_ptr->color_type != PNG_COLOR_TYPE_RGBA) { + if (!cmap && color_type != PNG_COLOR_TYPE_RGB && color_type != PNG_COLOR_TYPE_RGBA) { printk("Could not read file %s. Not an RGB image.\n", filename); goto failed; } @@ -156,12 +159,15 @@ int load_png(char *filename, u8 **data, struct fb_cmap *cmap, unsigned int *widt rowbytes = png_get_rowbytes(png_ptr, info_ptr); - if ((width && *width && info_ptr->width != *width) || (height && *height && info_ptr->height != *height)) { + img_width = png_get_image_width(png_ptr, info_ptr); + img_height = png_get_image_height(png_ptr, info_ptr); + + if ((width && *width && img_width != *width) || (height && *height && img_height != *height)) { printk("Image size mismatch: %s.\n", filename); goto failed; } else { - *width = info_ptr->width; - *height = info_ptr->height; + *width = img_width; + *height = img_height; } *data = malloc(fb_var.xres * fb_var.yres * bytespp); @@ -177,11 +183,11 @@ int load_png(char *filename, u8 **data, struct fb_cmap *cmap, unsigned int *widt goto failed; } - for (i = 0; i < info_ptr->height; i++) { + for (i = 0; i < img_height; i++) { if (cmap) { - row_pointer = *data + info_ptr->width * i; + row_pointer = *data + img_width * i; } else if (want_alpha) { - row_pointer = *data + info_ptr->width * i * 4; + row_pointer = *data + img_width * i * 4; } else { row_pointer = buf; } @@ -190,7 +196,7 @@ int load_png(char *filename, u8 **data, struct fb_cmap *cmap, unsigned int *widt if (cmap) { int h = 256 - cmap->len; - t = *data + info_ptr->width * i; + t = *data + img_width * i; if (h) { /* Move the colors up by 'h' offset. This is used because fbcon @@ -202,7 +208,7 @@ int load_png(char *filename, u8 **data, struct fb_cmap *cmap, unsigned int *widt /* We only need to convert the image if we the alpha channel is not required */ } else if (!want_alpha) { - truecolor2fb((truecolor*)buf, *data + info_ptr->width * bytespp * i, info_ptr->width, i, 0); + truecolor2fb((truecolor*)buf, *data + img_width * bytespp * i, img_width, i, 0); } } -- 1.7.7.1