Re: drawing 1 bit images, and image resolution
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