• 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: NSImage -- getting raw bitmap data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSImage -- getting raw bitmap data


  • Subject: Re: NSImage -- getting raw bitmap data
  • From: Marcel Weiher <email@hidden>
  • Date: Sun, 3 Aug 2003 16:28:00 +0100

On Sunday, Aug 3, 2003, at 13:49 Europe/London, M. Uli Kusterer wrote:

At 10:32 Uhr -0700 02.08.2003, Dennis C.De Mars wrote:
NSData* tiffData = [theImage TIFFRepresentation];
NSBitmapImageRep* bitMapRep = [NSBitmapImageRep imageRepWithData:tiffData];

ThanksA At worst this and bitmapData should let me do the conversion manually, like the IconFamily package seems to do it (didn't think about checking that before).

This is a fairly roundabout way of achieving that effect, because you are serializing the image, which can be quite expensive. The direct way is to -lockFocus: on the NSImage instance and then -initWithFocusedViewRect: the NSBitmapImageRep.

NSImageRep has some interesting methods for setting these parameters but I don't know if using them on a bitmap rep will cause any kind of conversion to take place. You could experiment.

No, according to the docs, these accessors are solely for providing information about the data, but they perform no conversion :-(

Correct.


And this is where it gets weird: It draws a *color* image on top of my B/W image, and it doesn't change my image data one bit. So I guess it replaces my representation with another??

You can't draw into an NSBitmapImageRep. You have to draw what you want into an NSImage (one of its NSCachedImageReps to be precise, but you don't have to worry about that, just lockFocus on the NSImage) and then initialize your NSBitmapImageRep from that.

[image lockFocus];
[self doDrawing];
size=[image size];
bitmap=[[[NSBitmapImageRep alloc] initWithFocusedViewRect:NSMakeRect( 0,0, size.x,size.y )] autorelease];
[image unlockFocus];

Beware that the initWithFocusedViewRect will honor the CTM in effect at the time. This will only get you one of the supported depths for window backing stores, so it is useless for general depth-conversion. You'll have to twiddle the bits yourself.

Marcel


--
Marcel Weiher Metaobject Software Technologies
email@hidden www.metaobject.com
Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc.
1d480c25f397c4786386135f8e8938e4
_______________________________________________
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.

References: 
 >Re: NSImage -- getting raw bitmap data (From: "M. Uli Kusterer" <email@hidden>)

  • Prev by Date: Re: NSImage -- getting raw bitmap data
  • Next by Date: NSProgressIndicator always NSProgressIndicatorBarStyle
  • Previous by thread: Re: NSImage -- getting raw bitmap data
  • Next by thread: Re: NSImage -- getting raw bitmap data
  • Index(es):
    • Date
    • Thread