• 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: How to draw text to bitmap (array) with pre 10.5 libs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to draw text to bitmap (array) with pre 10.5 libs


  • Subject: Re: How to draw text to bitmap (array) with pre 10.5 libs
  • From: John Horigan <email@hidden>
  • Date: Sun, 29 Nov 2009 22:01:50 -0800

On Nov 29, 2009, at 9:09 PM, Graham Cox wrote:

>
> On 30/11/2009, at 2:44 PM, Glenn McCord wrote:
>
>> What I'm expecting is the drawAtPoint method to draw nsString inside
>> the bitmapRep of the NSContext at which point I can retrieve the raw
>> data  and do something with it. On account of the data all being zero,
>> I'm obviously doing something wrong and would really appreciate some
>> advice.
>
>
> You also have to lock focus on the bitmap, which requires that it first be added to an NSImage (I think if you are targeting 10.6 only there is a new API that means you can avoid this).
>
> Also, it's not necessary to allocate the bitmap's buffer - if you don't pass one, it will allocate it for you.
>
> --Graham
>

Indeed, the initWithBitmapDataPlanes method treats the supplied buffer as immutable and creates its own internal copy. You must request the bitmap back from the NSBitmapImageRep using the bitmapData method. Prior to 10.6 the data backing up the NSBitmapImageRep was a bitmap plane but in 10.6 the cocoa team changed the backing data for NSBitmapImageRep to a CGImage. Either way, you should treat the data returned by bitmapData as read-only (in case you were thinking of modifying it).

-- john

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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: How to draw text to bitmap (array) with pre 10.5 libs
      • From: "Adam R. Maxwell" <email@hidden>
References: 
 >How to draw text to bitmap (array) with pre 10.5 libs (From: Glenn McCord <email@hidden>)
 >Re: How to draw text to bitmap (array) with pre 10.5 libs (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: How to draw text to bitmap (array) with pre 10.5 libs
  • Next by Date: Re: Defining and using constants in Objective C
  • Previous by thread: Re: How to draw text to bitmap (array) with pre 10.5 libs
  • Next by thread: Re: How to draw text to bitmap (array) with pre 10.5 libs
  • Index(es):
    • Date
    • Thread