Frage

I'm trying to read an image file which has its colors stored in the following fashion:

Hex      RGB
00 00 -> 0/0/0
01 00 -> 0/0/8
02 00 -> 0/0/16
...
20 00 -> 0/8/0
21 00 -> 0/8/8
22 00 -> 0/8/16

As you can see, it will increase the previous channel if the current one has a value of 256 or bigger.

I for the world can't seem to figure out a simple algorithm to calculate the appropriate color. If anyone can whip that for me I would be very thankful!

Update:

 0x00 -> 0x1F == 0x20 -> 0x3F == 0/0/0 -> 0/0/248
 0x40 -> 0x5F == 0x60 -> 0x7F == 0/8/0 -> 0/8/248

I just noticed that 32 ranges that follow up produce same color result... this is not some efficient RGB encoding, it's more like a protection if you ask me.

Another update: I ended up making a colormap which I can use to lookup the right color for a specific number, you can see it's a pretty weird looking map. If someone can figure out an algorithm to get to the colors specified in this map I'd be very grateful as I'm really curious to how it works.

enter image description here

War es hilfreich?

Lösung 2

Disclaimer: This is a repost of an update to my original question for the sake of completion.

I ended up making a colormap which I can use to lookup the right color for a specific number, you can see it's a pretty weird looking map. If someone can figure out an algorithm to get to the colors specified in this map I'd be very grateful as I'm really curious to how it works.

Lookup colormap

Andere Tipps

It looks to me as if they have done a 5-5-5 or a 5-6-5 bit level encoding to maximize the color capability within 16 bits. what this means is for lets say a 5-6-5 that the bit encoding would look like the below.

---------------------------------------------------------------------------------
| 15 | 14 | 13 | 12 | 11 | 10 |  9 |  8 |  7 |  6 |  5 |  4 |  3 |  2 |  1 |  0 |
---------------------------------------------------------------------------------
|          red           |            green            |          blue          |
---------------------------------------------------------------------------------

However in your case it also looks as if they swapped byte order meaning that yours based upon the order you gave could actually look as follows (bytes ordered as you show them):

|               byte 0                  |                 byte 1                |
---------------------------------------------------------------------------------
| 15 | 14 | 13 | 12 | 11 | 10 |  9 |  8 |  7 |  6 |  5 |  4 |  3 |  2 |  1 |  0 |
---------------------------------------------------------------------------------
|  low green   |          blue          |          red           |   hi green   |
---------------------------------------------------------------------------------
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top