mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 07:10:46 +00:00
Merge pull request #275 from gnustep/Magick_TGA
ImageMagick TGA support fix
This commit is contained in:
commit
6094e40e8e
1 changed files with 16 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue