Loading a BMP on PSP source

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

Moderators: cheriff, TyRaNiD

Post Reply
Shapyi
Posts: 95
Joined: Mon Apr 25, 2005 9:31 am

Loading a BMP on PSP source

Post by Shapyi »

Does anyone have an source code that can produce the same results as bmp2c only off the memory stick on PSP? I've searched and couldn't find any. Any help would be great.
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Re: Loading a BMP on PSP source

Post by Shine »

You should do a "svn co svn://svn.pspdev.org/psp/trunk/libpng" and then a "make" and "make install". After this you can load PNG images (much better than BMP, because you have an alpha channel and it is better compressed, because BMP has only RLE instead of zlib as standard compression method), see for example the loadImage function in my Lua player.
Shapyi
Posts: 95
Joined: Mon Apr 25, 2005 9:31 am

Post by Shapyi »

Alright, I got it installed. Do you think you could give me a simple example on how to use it with my pgBitBlt function I got based on Nem's from pg.h? That would be helpful, I never used libpng.
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

Shapyi wrote:Alright, I got it installed. Do you think you could give me a simple example on how to use it with my pgBitBlt function I got based on Nem's from pg.h? That would be helpful, I never used libpng.
It doesn't work with Nem's pgBitBlt, because it is 32 bit (true color with alpha) instead of 16 bit, but take a look at the loadImage function from the Snake game (which you can see ithere, too) : At the end you have the 32 bit RGBA data in image->data and you can convert the data to the u16 format for the pgBitBlt, if you don't want a true color display mode.
Shapyi
Posts: 95
Joined: Mon Apr 25, 2005 9:31 am

Post by Shapyi »

Shine wrote:
Shapyi wrote:Alright, I got it installed. Do you think you could give me a simple example on how to use it with my pgBitBlt function I got based on Nem's from pg.h? That would be helpful, I never used libpng.
It doesn't work with Nem's pgBitBlt, because it is 32 bit (true color with alpha) instead of 16 bit, but take a look at the loadImage function from the Snake game (which you can see ithere, too) : At the end you have the 32 bit RGBA data in image->data and you can convert the data to the u16 format for the pgBitBlt, if you don't want a true color display mode.
The link doesn't seem to work. And if its not too much trouble can you show me how to convert 32bit to 16bit. I'm pretty new at this sort of stuff.
Shito
Posts: 21
Joined: Wed May 11, 2005 1:38 am

Post by Shito »

Found this thread while searching for something else, and if it's not too late here's how you convert a 32 bits RGB color to a 16 bits one :

Code: Select all

int sourceColor, destColor ;
int r, g, b ;
r = (sourceColor&0x7C00)>>10 ;
g = (sourceColor&0x03E0)>>5 ;
b = (sourceColor&0x001F) ;
destColor  = &#40;&#40;b&0x1F&#41;<<10&#41;|&#40;&#40;g&0x1F&#41;<<5&#41;|&#40;r&0x1F&#41; ;
sourceColor being of course the color you want to convert.
Please note that we convert a 32 bits RGB int to a 16 bits 555 BGR int, that's because that's the format the PSP seems to be using in 16 bits mode.
Of course you'll be losing colors in the process. ^^
Hope it helps.
Shapyi
Posts: 95
Joined: Mon Apr 25, 2005 9:31 am

Post by Shapyi »

Thanks for the help Shito. I'll try it out later.
Post Reply