-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #275 from gnustep/Magick_TGA
ImageMagick TGA support fix
- Loading branch information
Showing
1 changed file
with
16 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]> | ||
Riccardo Mottola | ||
Date: June 2011 | ||
This file is part of the GNUstep Application Kit Library. | ||
|
@@ -123,13 +125,17 @@ + (NSBitmapImageRep *) imageRepWithImageMagickImage: (Image *)image | |
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 @@ + (NSArray*) imageRepsWithData: (NSData *)data allImages: (BOOL)allImages | |
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) | ||
|