Problem showing images (UPDATED, please check it)

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

Moderators: cheriff, TyRaNiD

Post Reply
kecC
Posts: 17
Joined: Mon Jul 04, 2005 11:07 pm

Problem showing images (UPDATED, please check it)

Post by kecC »

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.
kecC
Posts: 17
Joined: Mon Jul 04, 2005 11:07 pm

Post by kecC »

nobody can help me?
skeezixcodejedi
Posts: 29
Joined: Tue Aug 30, 2005 10:37 am
Contact:

Post by skeezixcodejedi »

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?
hexperience
Posts: 19
Joined: Tue Jul 05, 2005 7:35 am

Post by hexperience »

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: Select all

// 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 = &#40;&#40;b&0x1F&#41;<<19&#41;|&#40;&#40;g&0x1F&#41;<<11&#41;|&#40;&#40;r&0x1F&#41;<<3&#41; ;



     return destColor;

&#125;





// 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&#40;void&#41;

&#123;

   // draw image

   int x, y;

   

   u32* vram = &#40;u32*&#41; &#40;0x40000000 | 0x04000000&#41;;

   for &#40;y = 0; y < 272; y++&#41; &#123;

      for &#40;x = 0; x < 480; x++&#41; &#123;

         vram&#91;x + y * 512&#93; = pixel_16to32&#40;gfxconv_img&#91;x + y*480&#93;&#41; ;



      &#125;

   &#125;

&#125;
kecC
Posts: 17
Joined: Mon Jul 04, 2005 11:07 pm

Post by kecC »

Thanks a lot!

It works!
Post Reply