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 (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com