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 

Problem showing images (UPDATED, please check it)

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



Joined: 04 Jul 2005
Posts: 17

PostPosted: Fri Sep 02, 2005 10:14 pm    Post subject: Problem showing images (UPDATED, please check it) Reply with quote

Hi:

I'm developing a simple program, and i want to put a background image. I have the image in .c, and i know to show it in the display, but my problem is that the background colors aren't the same compared with the real image. There are color like orange, red and yellow.

What can I do?

Thanks!
Bye.

Edit: http://www.megaupload.com/?d=011A728B
I put this file with:

- The original image
- The EBOOT.PBP
- main.c
- foto.c
- Makefile

I have been thinking and I think that maybe, I could be that the photo is 24bit.
Back to top
View user's profile Send private message
kecC



Joined: 04 Jul 2005
Posts: 17

PostPosted: Tue Sep 06, 2005 11:58 am    Post subject: Reply with quote

nobody can help me?
Back to top
View user's profile Send private message
skeezixcodejedi



Joined: 30 Aug 2005
Posts: 29

PostPosted: Tue Sep 06, 2005 12:40 pm    Post subject: Reply with quote

I didn't look at your code..

The image is showing up correctly, just the wrong colours?

Are you loading and parsing the palette correctly? Are you using the same palette depth as you're showing?

ie: If you're in a 444-4 type display mode (4bits for each component), then you just can't get the same colour accuracy as in a higher colour image; and if you load such an image and don't mask the palette bits right, it'd go all to hell when you shift them into a 16-bit colour value.. (depending how you determine your 16bit value, say.)

So without looking at your code, I wonder.. did you correctly parse the palette into the format needed by your display settings?

jeff
_________________
--
Have you played Atari today?
Back to top
View user's profile Send private message Visit poster's website AIM Address
hexperience



Joined: 05 Jul 2005
Posts: 19

PostPosted: Tue Sep 06, 2005 2:33 pm    Post subject: Reply with quote

Here are the functions I made to convert a 16bit image to a 32bit image. It's extreamly newbie code, but it was how I played around with it.

There are a couple of good threads that explain the 16 and 32bit display modes. http://forums.ps2dev.org/viewtopic.php?t=2899

Code:
// Take a pixel in 16bit color format and convert it to 32bit color format

// Does not include the alpha bit



unsigned int pixel_16to32(unsigned int sourceColor)

{

    unsigned int destColor;

    int r, g, b;



     b = (sourceColor&0x7C00)>>10 ;

     g = (sourceColor&0x03E0)>>5 ;

     r = (sourceColor&0x001F) ;

     destColor = ((b&0x1F)<<19)|((g&0x1F)<<11)|((r&0x1F)<<3) ;



     return destColor;

}





// Take the image in mypic.c which is in the array gfxconv_img

// copy it to vram and convert it to 32bit color using the function above



void drawimage(void)

{

   // draw image

   int x, y;

   

   u32* vram = (u32*) (0x40000000 | 0x04000000);

   for (y = 0; y < 272; y++) {

      for (x = 0; x < 480; x++) {

         vram[x + y * 512] = pixel_16to32(gfxconv_img[x + y*480]) ;



      }

   }

}
Back to top
View user's profile Send private message
kecC



Joined: 04 Jul 2005
Posts: 17

PostPosted: Tue Sep 06, 2005 7:36 pm    Post subject: Reply with quote

Thanks a lot!

It works!
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