Page 1 of 1

Help with converting a really weird image format to PNG

Posted: 2016-02-15T14:45:00-07:00
by DodoDude700
Hello!
I am looking to use ImageMagick to convert a Format 64 image extracted from iPod Nano firmware to a PNG or something more normal. I know the format of this image, at least to the extent offered by the below explanation:
One int32 for palette size,
then 4 times that amount of ARGB8888 bytes,
then 8 BPP image data
I also know the dimensions of the image (they should be 26x13), though I do not know what it should look like if converted properly. The image can be downloaded here: https://dl.dropboxusercontent.com/u/911 ... 4Image.bin

Re: Help with converting a really weird image format to PNG

Posted: 2016-02-16T11:03:23-07:00
by psImg
Followed the instructions - First int32 is 87, then (87*4) bytes defining the palette, then the remaining (26*13) bytes are each pixel's value (between 0 and 86, i.e. referencing a palette entry)

but couldn't make it look like much of a coherent image:

http://i.imgur.com/5S764yV.png

Re: Help with converting a really weird image format to PNG

Posted: 2016-02-16T14:27:04-07:00
by DodoDude700
OK, cool, but what command was that? I need to do this programatically.

Re: Help with converting a really weird image format to PNG

Posted: 2016-02-16T18:47:12-07:00
by psImg
I don't think imagemagick is the right tool for this job; it's not a format that it knows about already.

I used matlab because I'm a hack

Code: Select all

fid = fopen('Format64Image.bin');
dim = [26 13];

first   = fread(fid,1,'*int32','l');
palette = fread(fid,[first 4],'*uint8','l');
imgdata = fread(fid,dim,'*uint8','l');

fclose(fid)

img=reshape(palette(imgdata+1,:),[dim 4]);
imwrite(img(:,:,1:3),'test.png','png','Alpha',img(:,:,4));
but will be similarly short in any language + an image library