Skip navigation.
 
mlRe: Creating black and white image
FROM : Osamu Shigematsu
DATE : Wed Dec 22 20:57:25 2004

Thank you very much for your information.

I read NSImage_monochrom.m, but this sample computes color of all 
pixels.

With QuickTime, converting color depth (dithering), resizing (affine 
transform) are done in single function call.

I hope NSImage's -compositeToPoint:operation:fraction: does that work, 
but converting depth does not work well.

I added following lines at the end of my bitmap creating function, and 
checked the output. The image size (dpi) was changed, but it was color 
image. The image (dst) has only one Image Representations, or 1 bit 
depth NSBitmapImageRep.

    NSData *tiff = [dst TIFFRepresentation];
    [tiff writeToFile:[@"~/Desktop/test.tif" 
stringByExpandingTildeInPath] atomically:NO];

Anyway, the performance of NSReadPixel may not good, and the code of 
NSImage_monochrom.m is too long for it's feature. I will try to create 
NSBitmapImageRep from QuickDraw's PixMapHandle.

This might be not so cool, but code will be simple.

On Dec 23, 2004, at 4:09 AM, Ricky Sharp wrote:

> Check out the following example:
>
> <http://developer.apple.com/samplecode/Monochrome_Image/

> Monochrome_Image.html>
>
> Specifically, look at the NSImage_monochrom.m file.
>
> Note that the code uses NSReadPixel which is quite slow.  I've since 
> optimized a local copy of it by directly accessing the pixels.  I hope 
> to one day submit this code.  Currently, it doesn't yet support bitmap 
> reps that contains alpha or is planar.
>

--
Osamu Shigematsu

Related mailsAuthorDate
mlCreating black and white image Osamu Shigematsu Dec 22, 19:02
mlRe: Creating black and white image Chuck Soper Dec 22, 19:17
mlRe: Creating black and white image Osamu Shigematsu Dec 22, 20:00
mlRe: Creating black and white image Ricky Sharp Dec 22, 20:09
mlRe: Creating black and white image Osamu Shigematsu Dec 22, 20:57
mlRe: Creating black and white image Clark Cox Dec 22, 21:19
mlRe: Creating black and white image Osamu Shigematsu Dec 23, 08:05