• 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
ImageIO errors generating UIImage from NSData from NSImage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ImageIO errors generating UIImage from NSData from NSImage


  • Subject: ImageIO errors generating UIImage from NSData from NSImage
  • From: Carl Hoefs <email@hidden>
  • Date: Wed, 09 Jul 2014 11:13:20 -0700

OS X 10.8.5, iOS 7.1.2
I have an OSX app that shows NSImages. When the user selects an image, it is transferred to an iOS device as an NSData and then turned into a UIImage and displayed onscreen.

The problem is I can't get the conversion of NSImage to NSData to UIImage to work. I'm using a home-brew -nsDataFromNSImage: method (attached below) for the conversion:

    NSData *imageData = [self nsDataFromNSImage:nsImage];

On the iOS side, when I try to recreate a UIImage from the NSData, like this:

    UIImage *userImage = [UIImage imageWithData:imageData];

-imageWithData: generates odd messages and returns NULL.

<Error>: ImageIO: PNG PNG unsigned integer out of range
<Error>: ImageIO: PNG [00][00][00][00]: invalid chunk type
<Error>: ImageIO: PNG [DA][AD][F9][1A]: invalid chunk type
<Error>: ImageIO: PNG [07][82]o[ED]: invalid chunk type
<Error>: ImageIO: PNG invalid distance too far back

Is there another way of doing this? I've also tried the method here without success https://lists.apple.com/archives/cocoa-dev/2011/Aug/msg01102.html
-Carl

------------------------------------

- (NSData *) nsDataFromNSImage:(NSImage *) nsImage
{
    NSBitmapImageRep *imageRep =
        [NSBitmapImageRep imageRepWithData:[nsImage TIFFRepresentation]];
    return [imageRep representationUsingType:NSPNGFileType
                                  properties:nil];
}
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: ImageIO errors generating UIImage from NSData from NSImage
      • From: Jens Alfke <email@hidden>
  • Prev by Date: IOS Navigator strategies.
  • Next by Date: Re: ImageIO errors generating UIImage from NSData from NSImage
  • Previous by thread: IOS Navigator strategies.
  • Next by thread: Re: ImageIO errors generating UIImage from NSData from NSImage
  • Index(es):
    • Date
    • Thread