• 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: Portable Network Graphics format
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Portable Network Graphics format


  • Subject: Re: Portable Network Graphics format
  • From: Brian Webster <email@hidden>
  • Date: Sat, 11 Aug 2001 12:27:48 -0500

On Saturday, August 11, 2001, at 12:15 AM, cocoa-dev-
email@hidden wrote:

I am trying to extract and save a PNG image from a NSView subclass (in the
example below, display_box is an NSBox). I have used the basic code below
(minus error checking), but I get the following error message logged to the
debug window:

"PNG writer requires compacted components (bits/component * components/pixel
= bits/pixel)"

It is possible for a bitmap to have some extra padding in the pixel data, so that bitsPerPixel is larger than bitsPerSample * samplesPerPixel. Try sending these messages to the NSBitmapImageRep you're getting to see what their values are. It might shed a little light on the subject. Also, I'm not sure if you can actually create a bitmap directly from PDF data. I think initWithData: only accepts bitmap data types like TIFF, GIF, etc. Are you sure p_bitmap isn't nil? Another thing you might want to try is NSBitmapImageRep's initWithFocusedViewRect: method.

I have no idea how to address this. The "properties:" value in the last
method call is an NSDictionary, but I don't know what to put in it (hence I
passed a nil pointer).

p_pdf_data = [display_box dataWithPDFInsideRect: [display_box bounds]];
p_bitmap = [NSBitmapImageRep imageRepWithData: p_pdf_data];
p_png_data = [p_bitmap representationUsingType: NSPNGFileType
properties: nil];


Unfortunately, the documentation for the representationUsingType:properties:
method only says "Description forthcoming."

The keys for the properties dictionary are defined in the NSBitmapImageRep.h header file, NSImageCompressionMethod et. al. There are little comments telling what sort of object should be associated with each key. It's almost documentation! :-P

--
Brian Webster
email@hidden
http://www.owlnet.rice.edu/~bwebster


  • Prev by Date: Re: custom view in NSTableView
  • Next by Date: Re: NSArchiver
  • Previous by thread: Portable Network Graphics format
  • Next by thread: NSArchiver
  • Index(es):
    • Date
    • Thread