mirror of
https://github.com/RaySollium99/libpicofe.git
synced 2025-09-04 22:47:44 -04:00
merge Themaister's libpng 1.5 fix
with width/height de-confusion
This commit is contained in:
parent
f89d84717a
commit
a085ae5ef1
1 changed files with 22 additions and 21 deletions
43
readpng.c
43
readpng.c
|
@ -61,7 +61,8 @@ int readpng(void *dest, const char *fname, readpng_what what, int req_w, int req
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
// lprintf("%s: %ix%i @ %ibpp\n", fname, (int)info_ptr->width, (int)info_ptr->height, info_ptr->pixel_depth);
|
// lprintf("%s: %ix%i @ %ibpp\n", fname, (int)png_get_image_width(png_ptr, info_ptr),
|
||||||
|
// (int)png_get_image_height(png_ptr, info_ptr), png_get_bit_depth(png_ptr, info_ptr));
|
||||||
|
|
||||||
switch (what)
|
switch (what)
|
||||||
{
|
{
|
||||||
|
@ -69,17 +70,17 @@ int readpng(void *dest, const char *fname, readpng_what what, int req_w, int req
|
||||||
{
|
{
|
||||||
int height, width, h;
|
int height, width, h;
|
||||||
unsigned short *dst = dest;
|
unsigned short *dst = dest;
|
||||||
if (info_ptr->pixel_depth != 24)
|
if (png_get_bit_depth(png_ptr, info_ptr) != 8)
|
||||||
{
|
{
|
||||||
lprintf(__FILE__ ": bg image uses %ibpp, needed 24bpp\n", info_ptr->pixel_depth);
|
lprintf(__FILE__ ": bg image uses %ibpc, needed 8bpc\n", png_get_bit_depth(png_ptr, info_ptr));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
height = info_ptr->height;
|
width = png_get_image_width(png_ptr, info_ptr);
|
||||||
if (height > req_h)
|
|
||||||
height = req_h;
|
|
||||||
width = info_ptr->width;
|
|
||||||
if (width > req_w)
|
if (width > req_w)
|
||||||
width = req_w;
|
width = req_w;
|
||||||
|
height = png_get_image_height(png_ptr, info_ptr);
|
||||||
|
if (height > req_h)
|
||||||
|
height = req_h;
|
||||||
|
|
||||||
for (h = 0; h < height; h++)
|
for (h = 0; h < height; h++)
|
||||||
{
|
{
|
||||||
|
@ -103,15 +104,15 @@ int readpng(void *dest, const char *fname, readpng_what what, int req_w, int req
|
||||||
{
|
{
|
||||||
int x, y, x1, y1;
|
int x, y, x1, y1;
|
||||||
unsigned char *dst = dest;
|
unsigned char *dst = dest;
|
||||||
if (info_ptr->width != req_w || info_ptr->height != req_h)
|
if (png_get_image_width(png_ptr, info_ptr) != req_w || png_get_image_height(png_ptr, info_ptr) != req_h)
|
||||||
{
|
{
|
||||||
lprintf(__FILE__ ": unexpected font image size %dx%d, needed %dx%d\n",
|
lprintf(__FILE__ ": unexpected font image size %dx%d, needed %dx%d\n",
|
||||||
(int)info_ptr->width, (int)info_ptr->height, req_w, req_h);
|
(int)png_get_image_width(png_ptr, info_ptr), (int)png_get_image_height(png_ptr, info_ptr), req_w, req_h);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (info_ptr->pixel_depth != 8)
|
if (png_get_bit_depth(png_ptr, info_ptr) != 8)
|
||||||
{
|
{
|
||||||
lprintf(__FILE__ ": font image uses %ibpp, needed 8bpp\n", info_ptr->pixel_depth);
|
lprintf(__FILE__ ": font image uses %ibpp, needed 8bpp\n", png_get_bit_depth(png_ptr, info_ptr));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (y = 0; y < 16; y++)
|
for (y = 0; y < 16; y++)
|
||||||
|
@ -136,15 +137,15 @@ int readpng(void *dest, const char *fname, readpng_what what, int req_w, int req
|
||||||
{
|
{
|
||||||
int x1, y1;
|
int x1, y1;
|
||||||
unsigned char *dst = dest;
|
unsigned char *dst = dest;
|
||||||
if (info_ptr->width != req_w || info_ptr->height != req_h)
|
if (png_get_image_width(png_ptr, info_ptr) != req_w || png_get_image_height(png_ptr, info_ptr) != req_h)
|
||||||
{
|
{
|
||||||
lprintf(__FILE__ ": unexpected selector image size %ix%i, needed %dx%d\n",
|
lprintf(__FILE__ ": unexpected selector image size %ix%i, needed %dx%d\n",
|
||||||
(int)info_ptr->width, (int)info_ptr->height, req_w, req_h);
|
(int)png_get_image_width(png_ptr, info_ptr), (int)png_get_image_height(png_ptr, info_ptr), req_w, req_h);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (info_ptr->pixel_depth != 8)
|
if (png_get_bit_depth(png_ptr, info_ptr) != 8)
|
||||||
{
|
{
|
||||||
lprintf(__FILE__ ": selector image uses %ibpp, needed 8bpp\n", info_ptr->pixel_depth);
|
lprintf(__FILE__ ": selector image uses %ibpp, needed 8bpp\n", png_get_bit_depth(png_ptr, info_ptr));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (y1 = 0; y1 < req_h; y1++)
|
for (y1 = 0; y1 < req_h; y1++)
|
||||||
|
@ -160,17 +161,17 @@ int readpng(void *dest, const char *fname, readpng_what what, int req_w, int req
|
||||||
{
|
{
|
||||||
int height, width, h;
|
int height, width, h;
|
||||||
unsigned char *dst = dest;
|
unsigned char *dst = dest;
|
||||||
if (info_ptr->pixel_depth != 24)
|
if (png_get_bit_depth(png_ptr, info_ptr) != 8)
|
||||||
{
|
{
|
||||||
lprintf(__FILE__ ": image uses %ibpp, needed 24bpp\n", info_ptr->pixel_depth);
|
lprintf(__FILE__ ": image uses %ibpc, needed 8bpc\n", png_get_bit_depth(png_ptr, info_ptr));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
height = info_ptr->height;
|
width = png_get_image_width(png_ptr, info_ptr);
|
||||||
if (height > req_h)
|
|
||||||
height = req_h;
|
|
||||||
width = info_ptr->width;
|
|
||||||
if (width > req_w)
|
if (width > req_w)
|
||||||
width = req_w;
|
width = req_w;
|
||||||
|
height = png_get_image_height(png_ptr, info_ptr);
|
||||||
|
if (height > req_h)
|
||||||
|
height = req_h;
|
||||||
|
|
||||||
for (h = 0; h < height; h++)
|
for (h = 0; h < height; h++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue