• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSImage -isValid not always right?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSImage -isValid not always right?


  • Subject: NSImage -isValid not always right?
  • From: Angela Brett <email@hidden>
  • Date: Sat, 13 Apr 2002 00:48:41 +1200

Hi,

I have a method which returns an NSImage corresponding to the info dictionary passed to it. Basically, it works out the path for the image, and then does:

image=[[NSImage alloc] initWithContentsOfFile:path];
if (!image) return nil;
if (![image isValid]) return nil;

After that it does some other stuff and returns the image. However, when it tries to get one particular jpg file, I get this message in the console while it's doing the initWithContentsOfFile:

Improper call to JPEG library in state 203

but image is not nil, and isValid returns YES, so my method returns an image which can't be displayed. When I put the image into an NSImageView the NSImageView stays blank, and I get an error when I try to open the image in Preview, so clearly the file is corrupted somehow. I notice while debugging that the image has a size of 0 by 0, so I could add an extra check for that into my function and return nil if the image size is 0 by 0, but shouldn't isValid be checking that for me? Now I don't know if even that is a failsafe way of ensuring that an image can be displayed. Is this a bug?
--
Angela Brett email@hidden http://acronyms.co.nz/angela
"Great minds think different."
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
  • Prev by Date: Re: Creating a checkbox
  • Next by Date: Re: Easy, stupid question about window delegates
  • Previous by thread: Re: Java Cocoa - App doesnt work outside of PB
  • Next by thread: Re: NSImage -isValid not always right?
  • Index(es):
    • Date
    • Thread