Users browsing this thread: 1 Guest(s)
Basics?
#9
Well, in this particular case the image doesn't actually look like it uses a palette; rather just a plain 32-bit colouring, or maybe something different altogether. But yeah, if it was using a palette, the first pixel would be the colour at index 0x80 = 128 in the palette, the second would be at 0x1B = 27, etc.

Let's work with an example file. This is a file from Patapon 2 for the PSP. The first 0xC bytes are just a magic ID, and there are some other things in the header, but for now I'll just focus on the pixel and palette data.

At 0x80 starts the pixel data, which is 0x1FE00 bytes long. At 0x1FEC0 is the palette data, which is 0x400 bytes long. The palette has 0x100 (256) colours in it, each 4 bytes long, and they're in RGBA format.
In the pixel data, each byte represents a pixel, and the value of each one points to a specific place in the palette. Let's look at the first one at 0x80, which is 0xD3. In decimal that's 211, so you go to the 211th colour in the palette, which is 0x739FD3FF.

You can use this process to create an array of all the pixels, each element being a colour value grabbed from the palette. After that, you can create the image using the width and height. In this specific file they're found at 0x20360 as little-endian 32-bit integers, first width then height.
You may have a fresh start any moment you choose, for this thing that we call "failure" is not the falling down, but the staying down. -Mary Pickford
Reply
Thanked by: Struggleton!


Messages In This Thread
Basics? - by Struggleton! - 07-23-2015, 07:45 AM
RE: Basics? - by puggsoy - 07-24-2015, 01:38 AM
RE: Basics? - by Struggleton! - 07-24-2015, 07:34 AM
RE: Basics? - by Struggleton! - 10-03-2015, 01:51 AM
RE: Basics? - by Vipershark - 10-03-2015, 01:59 AM
RE: Basics? - by Struggleton! - 10-03-2015, 02:39 AM
RE: Basics? - by puggsoy - 10-03-2015, 07:34 AM
RE: Basics? - by Struggleton! - 10-03-2015, 12:53 PM
RE: Basics? - by puggsoy - 10-03-2015, 11:28 PM
RE: Basics? - by TGE - 10-04-2015, 09:18 AM

Forum Jump: