1

I am currently trying to reverse engineer some game files. I have found the exact location of each graphic element, but now I am stuck trying to convert their data to "readable" rgb code. They use 16 bit long Hex values (0xC306 or 110000110000 converts to R:0 G:219 B:24)

The file is written in little endian. Could someone tell me how they convert it?

More examples:

(0xCFC0 -> RGB 198 24 123)

(0xFFF0 -> RGB 247 28 255)

(0xFF00 -> RGB 0 28 255)

1 Answer 1

4

It appears to be stored in byte-reversed order from what you gave with a standard 5-6-5 bit encoding and then scaled to a maximum of 255 for each.

0xC0CF (0b1100000011001111)

R: 24 (0b11000) * 255/31 = 197 G: 6 (0b000110) * 255/63 = 24 B: 15 (0b01111) * 255/31 = 123

0xF0FF (0b1111000011111111)

R: 30 (0b11110) * 255/31 = 247 G: 7 (0b000111) * 255/63 = 28 B: 31 (0b11111) * 255/31 = 255

0x00FF (0b0000000011111111)

R: 0 (0b00000) * 255/31 = 0 G: 7 (0b000111) * 255/63 = 28 B: 31 (0b11111) * 255/31 = 255

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.