How to display a PNG image with libpng

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
picobsd
Posts: 18
Joined: Thu Apr 19, 2007 7:24 pm

How to display a PNG image with libpng

Post by picobsd »

hi all
my goal is to display the opaque part of a PNG image, and skip the transparent part of it(like acdsee )

I use libpng, use Double Frame Buffer and set display mode to PSP_DISPLAY_PIXEL_FORMAT_8888
the follow is my code fragment:

for (y = 0; y < info_ptr->height; y ++)
{
png_byte *prow = prowtable[y];
for (x = 0; x < info_ptr->width; x ++)
{
b = *prow++;
g = *prow++;
r = *prow++;

a = * prow++; // It' doesnt' work

iRetCode = __rgbaToColorAuto( lpImgData,r,g,b, a);//copy to image buffer
lpImgData+=__global_iPGPixelSize;
}
}

but it does'nt work, I think the fourth byte of png pixel is not as same as psp's alpha channel, Could you please tell me How should I disp a png image correctly?
picobsd
Posts: 18
Joined: Thu Apr 19, 2007 7:24 pm

Post by picobsd »

I don't know why the alpha channel doesn't work when I put the color value which include rgba into Vram directly.
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

Try just setting the alpha to 0xff.

Jim
Post Reply