Troubles writing NSBitmapImageRep to gif file
Troubles writing NSBitmapImageRep to gif file
- Subject: Troubles writing NSBitmapImageRep to gif file
- From: Tobias Lidskog <email@hidden>
- Date: Wed, 24 Apr 2002 19:12:51 +0200
Hi,
I'm having troubles saving gif files from NSBitmapImageRep. All my
efforts result in distorted, strange images. Below is a very simple code
snippet that illustrates what I'm trying to do. The documentation about
this is rather sparse, and I haven't really found any sample code using
this. Below I'm trying to read a gif file into an NSImage and then write
the image data into another file. However when I do this foo.gif turns
up about half the size (file size in bytes that is) compared to
image.gif. Am I using the API incorrectly?
/Tobias
// --------
NSImage *image;
NSBitmapImageRep *rep;
image = [[NSImage alloc] initWithContentsOfFile:@"/tmp/image.gif"];
rep = [[image representations] objectAtIndex:0];
// I know rep is a NSBitmapImageRep since the original image was a bitmap
[[rep representationUsingType:NSGIFFileType properties:nil]
writeToFile:@"/tmp/foo.gif" atomically:NO];
// --------
_______________________________________________
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.