[PATCH] Fix building of fbsplash with libpng >= 1.5.0.
Arnaud Fontaine <[email protected]>
| Newsgroups | gmane.linux.swsusp.devel |
|---|---|
| Message-ID | <[email protected]> |
From this particular version of libpng, png_info definition is not
available anymore to applications, so use png_get_IHDR() instead,
which works fine with both libpng 1.2 and 1.5.
---
fbsplash/image.c | 35 ++++++++++++++++++++---------------
1 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/fbsplash/image.c b/fbsplash/image.c
index ba31328..0fec43d 100644
--- a/fbsplash/image.c
+++ b/fbsplash/image.c
@@ -81,6 +81,8 @@ int load_png(char *filename, u8 **data, struct fb_cmap *cmap, unsigned int *widt
png_colorp palette;
int rowbytes, num_palette;
int i, j, bytespp = (fb_var.bits_per_pixel + 7) >> 3;
+ int png_bit_depth, png_color_type;
+ png_uint_32 png_width, png_height;
u8 *buf = NULL;
u8 *t;
FILE *fp;
@@ -118,29 +120,32 @@ 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) {
+ png_get_IHDR(png_ptr, info_ptr, &png_width, &png_height,
+ &png_bit_depth, &png_color_type, NULL, NULL, NULL);
+
+ if (cmap && png_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 (png_color_type == PNG_COLOR_TYPE_GRAY ||
+ png_color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb(png_ptr);
- if (info_ptr->bit_depth == 16)
+ if (png_bit_depth == 16)
png_set_strip_16(png_ptr);
- if (!want_alpha && info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
+ if (!want_alpha && png_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 (!(png_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 && png_color_type != PNG_COLOR_TYPE_RGB && png_color_type != PNG_COLOR_TYPE_RGBA) {
printk("Could not read file %s. Not an RGB image.\n", filename);
goto failed;
}
@@ -156,12 +161,12 @@ 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)) {
+ if ((width && *width && png_width != *width) || (height && *height && png_height != *height)) {
printk("Image size mismatch: %s.\n", filename);
goto failed;
} else {
- *width = info_ptr->width;
- *height = info_ptr->height;
+ *width = png_width;
+ *height = png_height;
}
*data = malloc(fb_var.xres * fb_var.yres * bytespp);
@@ -177,11 +182,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 < png_height; i++) {
if (cmap) {
- row_pointer = *data + info_ptr->width * i;
+ row_pointer = *data + png_width * i;
} else if (want_alpha) {
- row_pointer = *data + info_ptr->width * i * 4;
+ row_pointer = *data + png_width * i * 4;
} else {
row_pointer = buf;
}
@@ -190,7 +195,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 + png_width * i;
if (h) {
/* Move the colors up by 'h' offset. This is used because fbcon
@@ -202,7 +207,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 + png_width * bytespp * i, png_width, i, 0);
}
}
--
1.7.7.1