From 2e35b56aedcbb8ccb432bbac0d83c15ab4a3fff6 Mon Sep 17 00:00:00 2001 From: Cristy Date: Fri, 21 Sep 2018 20:28:18 -0400 Subject: [PATCH] https://imagemagick.org/discourse-server/viewtopic.php?f=3&t=34757 --- coders/tga.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/coders/tga.c b/coders/tga.c index ef71590fa..3384ed18e 100644 --- a/coders/tga.c +++ b/coders/tga.c @@ -307,16 +307,28 @@ static Image *ReadTGAImage(const ImageInfo *image_info, if (tga_info.attributes & (1UL << 4)) { if (tga_info.attributes & (1UL << 5)) - SetImageArtifact(image,"tga:image-origin","TopRight"); + { + image->orientation=TopRightOrientation; + SetImageArtifact(image,"tga:image-origin","TopRight"); + } else - SetImageArtifact(image,"tga:image-origin","BottomRight"); + { + image->orientation=BottomRightOrientation; + SetImageArtifact(image,"tga:image-origin","BottomRight"); + } } else { if (tga_info.attributes & (1UL << 5)) - SetImageArtifact(image,"tga:image-origin","TopLeft"); + { + image->orientation=TopLeftOrientation; + SetImageArtifact(image,"tga:image-origin","TopLeft"); + } else - SetImageArtifact(image,"tga:image-origin","BottomLeft"); + { + image->orientation=BottomLeftOrientation; + SetImageArtifact(image,"tga:image-origin","BottomLeft"); + } } if (image_info->ping != MagickFalse) { @@ -725,8 +737,7 @@ static MagickBooleanType WriteTGAImage(const ImageInfo *image_info,Image *image, compression; const char - *comment, - *value; + *comment; const double midpoint = QuantumRange/2.0; @@ -841,19 +852,12 @@ static MagickBooleanType WriteTGAImage(const ImageInfo *image_info,Image *image, else tga_info.colormap_size=24; } - value=GetImageArtifact(image,"tga:image-origin"); - if (value != (const char *) NULL) - { - OrientationType - origin; - - origin=(OrientationType) ParseCommandOption(MagickOrientationOptions, - MagickFalse,value); - if (origin == BottomRightOrientation || origin == TopRightOrientation) - tga_info.attributes|=(1UL << 4); - if (origin == TopLeftOrientation || origin == TopRightOrientation) - tga_info.attributes|=(1UL << 5); - } + if ((image->orientation == BottomRightOrientation) || + (image->orientation == TopRightOrientation)) + tga_info.attributes|=(1UL << 4); + if ((image->orientation == TopLeftOrientation) || + (image->orientation == TopRightOrientation)) + tga_info.attributes|=(1UL << 5); /* Write TGA header. */ -- 2.40.0