NSImage initWithData: / problem with GIF images?
NSImage initWithData: / problem with GIF images?
- Subject: NSImage initWithData: / problem with GIF images?
- From: <email@hidden>
- Date: Wed, 2 Jan 2002 14:10:56 -0600
I am having trouble initializing an NSImage using the initWithData:
method. Here is (roughly) what I am doing:
url =[NSURL URLWithString:@"..."];
data = [NSData dataWithContentsOfURL:url];
image = [[[NSImage alloc] initWith
Data:data] autorelease];
I am trying to read a set of images this way, all in GIF format, and it
works for most of the files I try, but not for all. I saved the images
that I could not process and tried to load them into Apple's Preview
- with the same problem. The GraphicConverter application, however,
has no problems with the file and reports it to be of type GIF87a.
Both Preview and my own application log the following string trying to
initialize the NSImage:
decompress_gif: ran off the end of my bits
Apparently, there is a compatibility issue between the data I receive
and what NSImage thinks is the GIF format. My guess is that either some
kind of processing needs to be done with the received data before calling
initWithData:, or I'll have to implement a different importer for GIF
that creates an NSImage instance.
Is this a known issue of NSImage initWithData:, or do I have a non-
standard GIF file that other (more tolerant) applications happen to be
able to read? Has anyone had the same problem and can maybe point me to
a solution?