PDA

View Full Version : Boot logo decoding in python


tz1
01-07-2009, 01:50 PM
http://www.zdez.org/drawrgb.py

On a tablet,

"python2.5 disprgb.py /mnt/initrd/usr/share/images/logo-nokia" will display the nokia logo in a window. The only other file in this format is qgn_indi_charger_connection_detected in the same directory, but there is another which is an actual png file.

I haven't tried substituting anything for the logos yet or changing the startup scripts which run the programs which display these.

The format starts with two 4 byte integers, one each for width and height in that order, then the image. The image is a set of code/datas starting with a 1 byte rle code. zero is a terminator. If the code is > 127, the number is anded with 127 and the next byte-pair is repeated that many times. If the code is < 128, it means that that many following byte pairs (2*code bytes total) should be copied. (I don't think 0x80 as a code - zero reps - occurs).

The byte pairs are in framebuffer format, BBBBBGGG GGGRRRRR

Benson
01-07-2009, 04:25 PM
FYI, 0xffff has a C tool for encoding and decoding these, logotool, which builds fine in Maemo and in Cygwin/NT5.1; I'll attach it here (both binaries in source directory, but the .exe will not work unless you have Cygwin installed).

qwerty12
01-07-2009, 04:34 PM
I've used logotool before and replaced the logo in the initfs but I've had the program displaying the initfs logo segfault...

It's also worth noting that nokia have the logo in nolo too (i've commented out the lines that display the initfs logo in linuxrc but I still get the nokia logo).

tz1
01-08-2009, 04:58 PM
His compress doesn't actually compress, just codes everything as literal byte pairs.

I can't tell if I've got everything right (corner cases mainly since I've tested common things), but the attached will handle anything Python can accept to load as an image (which includes gif, png, jpg) and actually compress the output to logo-out.

tz1
01-08-2009, 05:16 PM
It seems to use the filesize and/or W*H to determine when to stop.
Notes on the rle byte:

0 - ignored, proceeds with the next byte as a new rle byte.

1-127 - copy the next N byte-pairs to the buffer.

128-255, copy the following byte-pair N-128 times to the buffer. If N==128, don't copy anything, but do read/skip the byte pair.