| View previous topic :: View next topic |
| Author |
Message |
Shapyi
Joined: 25 Apr 2005 Posts: 95
|
Posted: Mon Jul 18, 2005 9:09 am Post subject: 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. |
|
| Back to top |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Mon Jul 18, 2005 2:03 pm Post subject: 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. |
|
| Back to top |
|
 |
Shapyi
Joined: 25 Apr 2005 Posts: 95
|
Posted: Tue Jul 19, 2005 4:33 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Tue Jul 19, 2005 6:03 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
Shapyi
Joined: 25 Apr 2005 Posts: 95
|
Posted: Wed Jul 20, 2005 1:19 am Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
Shito
Joined: 11 May 2005 Posts: 21
|
Posted: Mon Jul 25, 2005 10:03 am Post subject: |
|
|
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: | 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) ; |
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. |
|
| Back to top |
|
 |
Shapyi
Joined: 25 Apr 2005 Posts: 95
|
Posted: Mon Jul 25, 2005 1:13 pm Post subject: |
|
|
| Thanks for the help Shito. I'll try it out later. |
|
| Back to top |
|
 |
|