• 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: Rasterizing an NSString to a bitmap
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rasterizing an NSString to a bitmap


  • Subject: Re: Rasterizing an NSString to a bitmap
  • From: Marcel Weiher <email@hidden>
  • Date: Thu, 10 Jun 2004 17:55:49 +0100

You've gotten too tied up in implementation details.
Will windows always have backing stores? Almost certainly yes.
Will we developers be able to get access to that backing store? Sure,
many of us have already been down that road.

Actually, in NeXTstep days, we did *not* have access to the backing store of a NSCachedImageRep. These were windows that lived inside the WindowServer

Will NSImages always be stored inside offscreen windows? I don't see
how that's a guarantee. I have yet to find any documentation
guaranteeing that an NSImage will have any particular representation,
or any example of code that gets pixels out of an NSImage without using
NSReadPixel or relying on undocumented hacks like fudging the current
NSGraphicsContext.

Hold it. The -initWithFocusedViewRect: method is a documented and reasonably efficient way to get rendered bitmap data. Even if it isn't named brilliantly in relation to NSImage.

[image lockFocus];
[myObject draw];
bitmap = [[[NSBitmapImageRep alloc] initWithFocusedViewRect:myRect] autorelease];
[image unlockFocus];

That's the canonical method of getting a bitmap of a rendered graphic in Cocoa, as far as I am aware, and is independent of NSImage implementation details. Another method is to get the TIFFRepresentation, and then re-reading that, but that involves an extra encoding/decoding step.

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.


  • Follow-Ups:
    • Re: Rasterizing an NSString to a bitmap
      • From: p3consulting <email@hidden>
    • Re: Rasterizing an NSString to a bitmap
      • From: John Stiles <email@hidden>
References: 
 >Rasterizing an NSString to a bitmap (From: John Stiles <email@hidden>)
 >Re: Rasterizing an NSString to a bitmap (From: Marcel Weiher <email@hidden>)
 >Re: Rasterizing an NSString to a bitmap (From: p3consulting <email@hidden>)
 >Re: Rasterizing an NSString to a bitmap (From: Marcel Weiher <email@hidden>)
 >Re: Rasterizing an NSString to a bitmap (From: John Stiles <email@hidden>)
 >Re: Rasterizing an NSString to a bitmap (From: p3consulting <email@hidden>)
 >Re: Rasterizing an NSString to a bitmap (From: John Stiles <email@hidden>)
 >Re: Rasterizing an NSString to a bitmap (From: Dietmar Planitzer <email@hidden>)
 >Re: Rasterizing an NSString to a bitmap (From: John Stiles <email@hidden>)
 >Re: Rasterizing an NSString to a bitmap (From: Dietmar Planitzer <email@hidden>)
 >Re: Rasterizing an NSString to a bitmap (From: John Stiles <email@hidden>)

  • Prev by Date: Re: newbie questions about objective-c, ruby, python, groovy and cocoa
  • Next by Date: Re: Re-formatting NSString
  • Previous by thread: Re: Rasterizing an NSString to a bitmap
  • Next by thread: Re: Rasterizing an NSString to a bitmap
  • Index(es):
    • Date
    • Thread