Re: NSBitmapImageRep from tiff NSData bug?
Re: NSBitmapImageRep from tiff NSData bug?
- Subject: Re: NSBitmapImageRep from tiff NSData bug?
- From: Patrick Haruksteiner <email@hidden>
- Date: Tue, 6 Feb 2007 19:53:09 +0100
you are right, bmpRep seems correct. I implemented your fix, but it
does not work for me, I'm getting "CGImageDestinationFinalize failed
for output type 'com.compuserve.gif'" again during imgData = [bmpRep
representationUsingType:NSGIFFileType properties:nil];
the new imageData is stil nil... (and so writing the file fails too)
do I have to tell the bmpReb somehow, that the bitmapData changed?
how did you create the image you tested this with? - the way I create
my image results in an image with only an NSCachedImageRep:
image = [self createImageFromView:animationView forTimeStamp:t];
tiffData = [image TIFFRepresentation];
bmpRep = [NSBitmapImageRep imageRepWithData:tiffData];
if(!imgData){
//one-colered gif bug
unsigned char *bitmapData = [bmpRep bitmapData];
bitmapData[0] = (bitmapData[0] == 255) ? 254 : bitmapData[0] +1;
imgData = [bmpRep representationUsingType:NSGIFFileType
properties:nil];
NSLog(@"imgData: %@", imgData);
}
[imgData writeToFile:tmpFileName atomically:NO];
my image is created this way:
- (NSImage *)createImageFromView:(PHAAnimationView *)view
forTimeStamp:(phaTimeStamp)time{
NSRect rect = [view frame];
NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize
(rect.size.width, rect.size.height)];
[image lockFocus];
[view drawObjectsInRect:rect forTimeStamp:time];
[image unlockFocus];
return image;
}
[view drawObjectsInRect:rect forTimeStamp:time] contains some fill/
stroke operations of NSBezierPath and a NSRectFill(rect) that fills
the background color
-> so i get a background only image if no animations to fill/stroke
are present
On Feb 06, 2007, at 17:24, Heinrich Giesen wrote:
No, the created NSBitmapImageRep bmpRep is correct and has exactly
one color and can be shown in an NSView. Have a look into bmpRep with:
NSLog( @"bmpRep = %@", bmpRep ); But the creation of:
imgData = [bmpRep representationUsingType:NSGIFFileType
properties:nil];
fails. And therefore imgData is nil. You should check it with
something like "if( imgData==nil ) //ERROR;" . There seems to be a bug
in creating a GifImage for single color data. In a small experiment
I changed the color of a pixel with:
unsigned char *bitmapData = [bmpRep bitmapData];
bitmapData[0] = (bitmapData[0]==255) ? 254 : bitmapData[0]+1;
(small change, but now the image has two colors!) followed by:
BOOL rtn = [imgData writeToFile:tmpFileName atomically:NO];
(The return value rtn is YES).
Stupid, but now it works! The created GifImage has two colors, a
global
colortable with two entries, and an AppExtension block which contains
the ICC-profile Adobe RGB (1998).
Heinrich Giesen
PS. also Preview.app cannot create a Gif-Image from a one color
TIFF image.
But ToyViewer.app can:
http://www7a.biglobe.ne.jp/~ogihara/software/index.html
--
Heinrich Giesen
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden