Generating Decent GIF With Transparency from NSBitmapImageRep
Generating Decent GIF With Transparency from NSBitmapImageRep
- Subject: Generating Decent GIF With Transparency from NSBitmapImageRep
- From: "Steven W. Schuldt" <email@hidden>
- Date: Fri, 6 Sep 2002 15:09:03 -0700
All:
Does anyone know what a valid "packed RGB color table" value might be
for the NSImageRGBColorTable key used to generate GIF data from an
NSBitmapImageRep?
The following code - my best guess - will crash an app:
imProperties = [NSDictionary
dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:1],
NSImageDitherTransparency, [NSArchiver
archivedDataWithRootObject:[NSColor colorWithDeviceRed:1.0 green:1.0
blue:1.0 alpha:1.0]], NSImageRGBColorTable, nil];
[[(NSBitmapImageRep*)imageRep
representationUsingType:NSGIFFileType properties:imProperties]
writeToFile:pathForImage atomically:YES];
The following code (same as above but sans NSImageRGBColorTable key)
will generate an ugly, unuseable GIF:
imProperties = [NSDictionary
dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:1],
NSImageDitherTransparency, nil];
[[(NSBitmapImageRep*)imageRep
representationUsingType:NSGIFFileType properties:imProperties]
writeToFile: pathForImage atomically:YES];
Thanks!
- Steven
_______________________________________________
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.