Author | Message | Time |
---|---|---|
FrostWraith | I decided to write a utility to do a number of things with a targa image, one of which is to decompress it. Using the targa image that is contained in icons.bni, I am looking at the encoding it has. [code]00 00 0A 00 00 00 00 00 00 00 00 00 1C 00 18 01 18 00 01 BD AD 6F B5 A8 6E 81 88 81 5A 02[/code] This snippet contains the tga header and a small amount of pixel data. Noting the 0x0A (10), it has run-length encoding. Question #1 From what I have read about RLE, I have found tutorials that are completely opposite of each other. I am not sure which result is correct: Example: Data - AAAAAAAAAAAAABBCCCCCCCCCCCC Would this be encoded as: 13A2B12C or as A13B2C12 Question #2 Looking at the data above, you can see the pixel data starts with this snippet: [code] 01 BD AD 6F B5 A8 6E 81 88 81 5A 02[/code] How would i separate this out? 1 pixel of BD, AD, 6F? 181 pixels! of A8, 6E, 81? | July 16, 2008, 9:55 PM |
HdxBmx27 | [code] Info length: 0 Map type: 0 Image Type: 10 Color Map Origin: 0 Color Map Length: 0 Color Map Entry Size: 0 Start: 0, 0 Size: 28x280 Depth: 24 Descriptor: 0[/code] There is your header which leaves 01 BD AD 6F B5 A8 6E 81 88 81 5A 02 as your data. Lets get started: 0x01 - 1 byte of raw pixel data, (189, 173, 111) 0xB5 - Since its > 128 [meaning it's highest bit is set] its RLE, 0xB5 - 128 = 53. So you have 53 pixel of (168, 110, 129) 0x88 - Since its > 128 its RLE, 0x88 - 128 = 8. 8 pixels of (129, 90, 2) BUT to answer your question. Let: A = (1, 2, 3) B = (4, 5, 6) C = (7, 8, 9) D = (10, 11, 12) Image AAAAAAAAAAAAABBCCCCCCCCCCCCD Would be encoded as such: 8D 01 02 03 82 04 05 06 8C 07 08 09 01 0A 0B 0C get it? | July 18, 2008, 4:44 PM |
FrostWraith | [quote]0x01 - 1 byte of raw pixel data, (189, 173, 111) 0xB5 - Since its > 128 [meaning it's highest bit is set] its RLE, 0xB5 - 128 = 53. So you have 53 pixel of (168, 110, 129) 0x88 - Since its > 128 its RLE, 0x88 - 128 = 8. 8 pixels of (129, 90, 2)[/quote] I decided to use a premade tool to convert the image to a bmp and open it in paint to look at the pixels. That first pixel is correct, but there aren't 53 consecutive pixels of the same color from the where the start is specified (bottom left i believe). | July 19, 2008, 1:58 AM |
HdxBmx27 | Well, From what you gave me it should be. Unless I did my math wrong. My Java Implementation Google cache of the document I worked off of Why not just try coding it as such and then see what you get. | July 19, 2008, 4:24 AM |
Myndfyr | Also available is my C# implementation specific for BNI files. My code was based on Kane's description of the format. | July 19, 2008, 7:38 AM |