• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSBitmapImageRep from tiff NSData bug?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSBitmapImageRep from tiff NSData bug?


  • Subject: Re: NSBitmapImageRep from tiff NSData bug?
  • From: Heinrich Giesen <email@hidden>
  • Date: Tue, 6 Feb 2007 17:24:00 +0100


On 05.02.2007, at 23:34, Patrick Haruksteiner wrote:

I ran into a problem when i tried to convert image data and export it to a gif file.

Here is a little snippet:

image = [self createImageFromView:animationView forTimeStamp:t];
tiffData = [image TIFFRepresentation];
bmpRep = [NSBitmapImageRep imageRepWithData:tiffData];
imgData = [bmpRep representationUsingType:NSGIFFileType properties:nil];
[imgData writeToFile:tmpFileName atomically:NO];


Well it works most time, but if the image contains only one color it
fails with " CGImageDestinationFinalize failed for output type
'com.compuserve.gif' ". I narrowed it down that the tiffData is
correct, but something happens during creation of the
NSBitmapImageRep in [NSBitmapImageRep imageRepWithData:tiffData];


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
email@hidden


_______________________________________________

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


  • Follow-Ups:
    • Re: NSBitmapImageRep from tiff NSData bug?
      • From: Patrick Haruksteiner <email@hidden>
  • Prev by Date: NSDatePicker - can it be empty/blank?
  • Next by Date: Re: NSDatePicker - can it be empty/blank?
  • Previous by thread: Re: NSBitmapImageRep from tiff NSData bug?
  • Next by thread: Re: NSBitmapImageRep from tiff NSData bug?
  • Index(es):
    • Date
    • Thread