• 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 -> 1-bit NSBitmapImageRep
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSImage -> 1-bit NSBitmapImageRep


  • Subject: Re: NSImage -> 1-bit NSBitmapImageRep
  • From: Ricky Sharp <email@hidden>
  • Date: Wed, 09 Feb 2005 07:52:31 -0600

On Tuesday, February 08, 2005, at 11:29PM, Sanford Selznick <email@hidden> wrote:

>I've got an NSImage with black and white data in it.  I'd like to
>copy the black and white contents to a 1-bit-per-pixel
>NSBitmapImageRep.
>
>What's the best way to do this?
>
>I need 1-bit-per-pixel data, rowbytes and a rect so I can pass them
>into a library.

See the MonochromeImage sample code at Apple's site.  It shows you how to work with an original NSImage and use its data to construct a monochrome image rep.

Note that you'll need to modify the parameters to initWithBitmapDataPlanes:pixelsWide... in order to specify 1 bpp.

Things to consider:

* The sample uses NSReadPixel which is very slow.  What I've been doing is using "direct pixel access". i.e. I get a pointer into the source and destination data streams by using [someImageRep bitmapData].

* The original source rep may have alpha (hasAlpha returns YES) and may be planar (isPlanar returns YES).  Your code should be modified to work with such data.

--
Rick Sharp
Instant Interactive(tm)

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSImage -> 1-bit NSBitmapImageRep
      • From: Sanford Selznick <email@hidden>
References: 
 >NSImage -> 1-bit NSBitmapImageRep (From: Sanford Selznick <email@hidden>)

  • Prev by Date: Re: Serious crash from setNeedsDisplayInRect:
  • Next by Date: Binding userdefaults update
  • Previous by thread: NSImage -> 1-bit NSBitmapImageRep
  • Next by thread: Re: NSImage -> 1-bit NSBitmapImageRep
  • Index(es):
    • Date
    • Thread