Merge pull request #275 from gnustep/Magick_TGA

ImageMagick TGA support fix
This commit is contained in:
Riccardo 2024-05-22 15:06:32 +02:00 committed by GitHub
commit 6094e40e8e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,9 +2,11 @@
<abstract>ImageMagick image representation.</abstract>
Copyright (C) 2011 Free Software Foundation, Inc.
Copyright (C) 2011-2024 Free Software Foundation, Inc.
Author: Eric Wasylishen <ewasylishen@gmail.com>
Riccardo Mottola
Date: June 2011
This file is part of the GNUstep Application Kit Library.
@ -123,13 +125,17 @@
return bmp;
}
#define SIGNATURE_LENGTH 18
+ (NSArray*) imageRepsWithData: (NSData *)data allImages: (BOOL)allImages
{
NSMutableArray *reps = [NSMutableArray array];
ExceptionInfo *exception = AcquireExceptionInfo();
ImageInfo *imageinfo = CloneImageInfo(NULL);
Image *images, *image;
Image *images;
Image *image;
char signature[SIGNATURE_LENGTH];
// Set the background color to transparent
// (otherwise SVG's are rendered against a white background by default)
@ -139,6 +145,14 @@
QueryColorDatabase("none", &imageinfo->background_color, exception);
#endif
memset(signature, 0, SIGNATURE_LENGTH);
[data getBytes: signature range: NSMakeRange([data length] - 18, 18)];
if (strncmp(signature, "TRUEVISION-XFILE.", 17) == 0)
{
NSWarnLog(@"Targa file detected!, giving a magick hint...");
strcpy(imageinfo->magick, "TGA");
}
images = BlobToImage(imageinfo, [data bytes], [data length], exception);
if (exception->severity != UndefinedException)