• 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 compression...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSBitmapImageRep compression...


  • Subject: Re: NSBitmapImageRep compression...
  • From: Jonathan Hendry <email@hidden>
  • Date: Fri, 24 Aug 2001 15:39:54 -0500

You probably don't want to use the TIFFData method.

You need to use
- (NSData *)representationUsingType:(NSBitmapImageFileType)storageType
properties:(NSDictionary *)properties;

the storageType should be one of these, from NSBitmapImageRep.h:

typedef enum _NSBitmapImageFileType {
NSTIFFFileType,
NSBMPFileType,
NSGIFFileType,
NSJPEGFileType,
NSPNGFileType,
} NSBitmapImageFileType;

and properties is a dictionary with one or more keys from the following
list (Also from NSBitmapImageRep.h):

APPKIT_EXTERN NSString* NSImageCompressionMethod; // TIFF input/output (NSTIFFCompression in NSNumber)
APPKIT_EXTERN NSString* NSImageCompressionFactor; // TIFF/JPEG input/output (float in NSNumber)
APPKIT_EXTERN NSString* NSImageDitherTransparency; // GIF output (BOOL in NSNumber)
APPKIT_EXTERN NSString* NSImageRGBColorTable; // GIF input/output (packed RGB in NSData)
APPKIT_EXTERN NSString* NSImageInterlaced; // PNG output (BOOL in NSNumber)
APPKIT_EXTERN NSString* NSImageColorSyncProfileData; // TIFF input/output (NSData)

To create an interlaced PNG, you'd use the properties described by
[NSDictionary dictionaryWithObject:[NSNumber numberWithBOOL:YES] key: NSImageInterlaced];

To create a compressed JPG, you'd use
[NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:0.75] key: NSImageCompressionFactor];

(I may be wrong on the float value there...)

So you get something like

[myBitmapImageRep representationUsingType: NSPNGFileType
properties:[NSDictionary dictionaryWithObject:[NSNumber numberWithBOOL:YES] key: NSImageInterlaced]]

It shouldn't be hard to translate to Java.

- Jon

On Friday, August 24, 2001, at 10:52 , Kyle Mandli wrote:

I need to save a NSBitmapImageRep (actually an NSImage) as a JPEG, TIFF,
GIFF and anything else I can get out of it. I figured out how to get it
to create a NSData object and save that but I was wondering what the
explanations of the compression types meant. For NSTIFFCompressionJPEG
it says it isn't supported for input/output. It seems to work fine but
this is really confusing. Does anyone have any idea what that note
means or should I just ignore it and chalk it up to documentation being
a little behind?

Kyle
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev


References: 
 >NSBitmapImageRep compression... (From: Kyle Mandli <email@hidden>)

  • Prev by Date: RE: Help on adding help
  • Next by Date: Re: Linking Error
  • Previous by thread: NSBitmapImageRep compression...
  • Next by thread: Re:NSBitmapImageRep compression...
  • Index(es):
    • Date
    • Thread