forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Loading a BMP on PSP source

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Shapyi



Joined: 25 Apr 2005
Posts: 95

PostPosted: Mon Jul 18, 2005 9:09 am    Post subject: Loading a BMP on PSP source Reply with quote

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
View user's profile Send private message
Shine



Joined: 03 Dec 2004
Posts: 728
Location: Germany

PostPosted: Mon Jul 18, 2005 2:03 pm    Post subject: Re: Loading a BMP on PSP source Reply with quote

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
View user's profile Send private message
Shapyi



Joined: 25 Apr 2005
Posts: 95

PostPosted: Tue Jul 19, 2005 4:33 pm    Post subject: Reply with quote

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
View user's profile Send private message
Shine



Joined: 03 Dec 2004
Posts: 728
Location: Germany

PostPosted: Tue Jul 19, 2005 6:03 pm    Post subject: Reply with quote

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
View user's profile Send private message
Shapyi



Joined: 25 Apr 2005
Posts: 95

PostPosted: Wed Jul 20, 2005 1:19 am    Post subject: Reply with quote

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
View user's profile Send private message
Shito



Joined: 11 May 2005
Posts: 21

PostPosted: Mon Jul 25, 2005 10:03 am    Post subject: Reply with quote

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
View user's profile Send private message
Shapyi



Joined: 25 Apr 2005
Posts: 95

PostPosted: Mon Jul 25, 2005 1:13 pm    Post subject: Reply with quote

Thanks for the help Shito. I'll try it out later.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group