On 20 Jun '08, at 4:00 PM, Grant Limberg wrote:

Currently, the user drags an existing image from their filesystem to an NSImageView bound to an NSData attribute in the sqlite data store. This causes the decompression from 1.5MB to 20MB.

That's an issue with NSImageView — when an image is dragged into it, it converts it into an NSImage (in most cases, an uncompressed pixmap). It does not store the original image data at all. So the binding has no alternative but to convert from the NSImage back into data. I would guess it uses TIFF for that. PNG would give somewhat better compression, but it won't be close to JPEG. (But it would be a bad idea for it to use JPEG, because that would decrease image quality and eliminate the alpha channel.)

If you want to use an NSImageView but keep the original image data, you'll need to subclass it. I've done this once before. Basically you need to override the drag-and-drop methods and handle the drag yourself. At the end of the drag you convert the data into an NSImage and put that into the view, but you hang onto the data itself in the form of an NSData* instance variable. You can then write that data into the CoreData store.

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to