After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 613328 - TGA files saved with incorrect header yOrigin data
TGA files saved with incorrect header yOrigin data
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Plugins
2.6.8
Other All
: Normal normal
: 2.6
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2010-03-19 14:02 UTC by Andrew Wyatt
Modified: 2010-07-07 18:41 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Andrew Wyatt 2010-03-19 14:02:39 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]
Comment 1 Sven Neumann 2010-03-21 23:24:22 UTC
The suggested fix looks correct to me. This should be fixed in both branches.
Comment 2 Sven Neumann 2010-07-07 18:41:14 UTC
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'.