GIF generation using NSBitmapImageRep
GIF generation using NSBitmapImageRep
- Subject: GIF generation using NSBitmapImageRep
- From: email@hidden
- Date: Wed, 20 Feb 2002 14:45:31 -0800
OK, I'm trying to generate a GIF using -[NSBitmapImageRep
representationUsingType:properties:]. The bitmap rep is 32-bit with no
alpha. It saves fine as TIFF, JPEG or PNG. When I save as GIF,
however, I get a GIF that is recognizably based on the original image,
but the quality is *terrible*. I know it's reducing to 8 bits in the
process of doing this; the quality, however, is much worse than I would
expect even given that.
First I tried passing just [NSDictionary dictionary] for properties.
That gave me an image that has a huge amount of noise in it, for no
apparent reason. Even plain black text on a white background that is
contained within the image comes out unreadable -- most of the black
pixels have been turned white, leaving just occasional stray black
pixels where there once was text.
Then I tried [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber
numberWithBool:NO], NSImageDitherTransparency, nil]. This does the same
thing; apparently NO is the default value.
Then I tried [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber
numberWithBool:YES], NSImageDitherTransparency, nil]. This gives the
best quality image I can get, but black text still comes out unreadable.
Finally, I tried supplying my own color table using
NSImageRGBColorTable. I'm pretty sure the color table is well-formed;
it's GraphicConverter's "system color table", converted to an NSData
using Cocoa methods. When printed out with NSLog, it looks exactly as I
would expect it to ("colorTableData == <ffffffff ffccffff 99ffff66
ffff33ff ff00ffcc ... 44444422 22221111 11000000 >"). But with this
parameter included, all I got was black and white noise -- no other
colors at all, whether NSImageDitherTransparency was YES or NO.
What am I missing here? Am I using the API incorrectly? Do I need to
somehow convert down to 256 colors first because the GIF output engine's
conversion code is broken? Is GIF output just broken period, such that
converting down first won't help? If anybody has explored this area
already, I'd appreciate a pointer before I waste more time.
Thanks!
Ben Haller
Stick Software
_______________________________________________
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.