S
S
Sergey2019-02-07 16:56:55
Canvas
Sergey, 2019-02-07 16:56:55

What is this compression method?

Hello everyone, I found a Mario game for the web, when I tried to change something, I couldn’t change the images, I found out that they are encrypted in a very strange way: https://github.com/planktonfun/mariophpjava-demo/b...
5c5c3890a39f7551229886.png
figured out the first part - these are colors from the palette, but what to do with x022,1111x010,x18,x07,x110 is not clear,
this is all parsed and brought to the form Uint8ClampedArray.
The question is how to work with this, because in fact this is a bitmap image encoded somehow?
How can I change the image into something convenient and then return to the form of numbers and x?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2019-02-07
@evd1ser

p[...] are the numbers of colors from the common palette, indices from 0 to 3.
Next come the dot colors themselves.
Digit 0..3 - color index in sprite palette
x - beginning of repetitions. Immediately after it comes the color index number, further to the comma - the number of repetitions (x011, - repeat 0 eleven times).
"p [0,2,5,8] x022,1111x010, x18 , x07, x110, x05, x17,33111000x18,32311000x19,3311003333x111,001133x110,001113x110,011213x110,011113x110,011113x110,0011233x15, x35,00222331133322200222203333002222" a
String of 256 characters
Split into 16 substrings

0000000000000000
0000001111000000
0000111111110000
0001111111111000
0011111113311100
0111111113231100
0111111111331100
3333111111111110
0113311111111110
0111311111111110
1121311111111110
1111311111111110
1111311111111110
0112331111133333
0022233113332220
0222203333002222

We replace the indexes with colors from the palette, we get the yj-zin3n79g0u0dgucf6teanlfm.png
PS bug. If the array of palette indexes is not specified, then the full base palette is used. For a sprite palette up to 10 colors inclusive, indexes are encoded with one digit (0-9), up to 100 colors - with two digits (00-99), and so on.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question