• 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: drawing 1 bit images, and image resolution
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: drawing 1 bit images, and image resolution


  • Subject: Re: drawing 1 bit images, and image resolution
  • From: Graham Cox <email@hidden>
  • Date: Sat, 11 Feb 2012 10:26:06 +1100

On 11/02/2012, at 7:46 AM, Chris Paveglio wrote:

> for (column = 0; column <widthInPixels; column++)
> {
> //get pixel value from grey and put into 1bit
> [imgRep getPixel:&lePixel atX:row y:column];
> [newRep setPixel:&lePixel atX:row y:column];
> }
> //FYI this is not an all purpose solution, this will ONLY work with greyscale images
> //that are already 1-bit in spirit


Noting your comment, you could make it general purpose with an extremely minor change to your code.

Compare the value in 'le' against some desired threshold value (given that the input image is 8-bit grey, this would be a value between 0 and 255), and call setPixel: with 0 or 1 depending on the outcome.

Also, you might get a small performance improvement if you first clear the destination image buffer to all zero, then only set the bits that are 1s. That would avoid many calls to -setPixel in the inner loop (though whether that performance matters would need to be determined).


--Graham


_______________________________________________

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


References: 
 >drawing 1 bit images, and image resolution (From: Chris Paveglio <email@hidden>)
 >Re: drawing 1 bit images, and image resolution (From: email@hidden)
 >Re: drawing 1 bit images, and image resolution (From: Chris Paveglio <email@hidden>)
 >Re: drawing 1 bit images, and image resolution (From: Graham Cox <email@hidden>)
 >Re: drawing 1 bit images, and image resolution (From: Chris Paveglio <email@hidden>)

  • Prev by Date: Re: Lion: unlocking a document
  • Next by Date: NSReadPixel
  • Previous by thread: Re: drawing 1 bit images, and image resolution
  • Next by thread: Can I somehow encourage the deallocation of a dismissed view controller?
  • Index(es):
    • Date
    • Thread