gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > PCX to array

#164719 - iainprice - Sat Nov 15, 2008 8:47 pm

I am using loadPCX to get an image into the NDS. I want to put it into a height array for my terrain engine... how do I access the data?

#164721 - Ludo6431 - Sat Nov 15, 2008 10:33 pm

Look the libnds source code.

edit :
Code:
 typedef struct
 {
    short height,width;
    int bpp;
    unsigned short* palette;

    union
    {
       unsigned char* data8;
       unsigned short* data16;
       unsigned int* data32;
    } image;

 } sImage, *psImage;


edit2:
and pcx is a 256colors format.
so you have the data in data8 and the palette in palette.

If you need 16bit array use:
Code:
void image8to16(sImage* img)

or
Code:
void image8to16trans(sImage* img, u8 transparentColor) // with this one you can set a palette color as transparent in the 16bit data

and you can find the data in data16.