GNOME Bugzilla – Bug 613328
TGA files saved with incorrect header yOrigin data
Last modified: 2010-07-07 18:41:14 UTC
When saving TGA files with save option 'Origin=Top Left', the data in the header of the TGA file for the yOrigin is saved incorrectly according to the TGA specification. This could mean that the TGA files may not load correctly in other software. [When Origin='Bottom Left', the data is saved correctly]. This can be seen when saving an image with width=0xf3, height=0xe7 and saving with Origin=Top Left: First bytes in file - 00 00 02 00 00 00 00 00 00 00 E7 E7 ... Expected bytes - 00 00 02 00 00 00 00 00 00 00 E7 00 ... Possible fix --========-- gimp_2.6.8/root/plug-ins/common/file-tga.c (plain) function save_image(..), line 1219: header[10] = header[11] = tsvals.origin ? 0 : height; /* yorigin */ This should rather be: header[10] = tsvals.origin ? 0 : (height % 256); header[11] = tsvals.origin ? 0 : (height / 256); [Compare load_image(..) line 530 - info.yOrigin = header[10] + header[11] * 256]
The suggested fix looks correct to me. This should be fixed in both branches.
Thanks for pointing this out. Fixed in both branches: commit 4a1078796ba2d7b03567760f806ded060bd87e61 Author: Andrew Wyatt <andywyatt@onetel.com> Date: Wed Jul 7 20:38:53 2010 +0200 Bug 613328 - TGA files saved with incorrect header yOrigin data Fix header for TGA files saved with save option 'Origin=Top Left'.