Loading a BMP on PSP source
Loading a BMP on PSP source
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.
Re: Loading a BMP on PSP source
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.
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 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.
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.Shine wrote: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 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.
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 :
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.
Code: Select all
int sourceColor, destColor ;
int r, g, b ;
r = (sourceColor&0x7C00)>>10 ;
g = (sourceColor&0x03E0)>>5 ;
b = (sourceColor&0x001F) ;
destColor = ((b&0x1F)<<10)|((g&0x1F)<<5)|(r&0x1F) ;
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.