View Single Post
Old 2009-08-05, 14:54
jdcakes jdcakes is offline
Join Date: Aug 2009
Posts: 3

Just in case anyone is interested I managed to get bmp->gga working using a very rough little script. Whilst GGA supports a whole bunch of compression codes you can ignore them all and create a valid GGA simply by inserting the byte FF every 976 bytes starting immediately after the header. This assumes that it is a 32bit BMP if not you need to pad every pixel with 0s first, additionally the bmp must be flipped in the horizontal axis. also for the last inserted control byte you need to use one calculated by the following rather than FF.

(length of file after final control byte in bytes)/4 +11

Which converted into hex will give you the replacement byte.

After this you simply need to replace the BMP header with the header from the GGA image you are trying to replace. You should only need to replace the length entry which is byte 21-24 enter in the length from your first control byte to the end of file in hex.

In my case this roughly doubled the file size, so not the best idea if you are replacing a lot of images, but it's a nice easy bodge if you just need to get something working.

For those interested in why this works; GGA uses 11 control bytes 00-0B to specify various repetitions of the four byte pixels it has already processed. Where the control byte is higher than 0B the reader will subtract 0B from the byte and read the resultant number of 4byte pixels from the file following the control byte. Thus FF gives you the maximum number of pixels (244 or 976 in bytes) before another control byte is read.
Reply With Quote