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 (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com