Re: Inverting an NSImage
Re: Inverting an NSImage
- Subject: Re: Inverting an NSImage
- From: "John C. Randolph" <email@hidden>
- Date: Mon, 10 Feb 2003 14:05:16 -0800
- Newsgroups: apple.lists.cocoa-dev
- Organization: Apple Computer, Inc.
- Xref: forum.apple.com apple.lists.cocoa-dev:38515
email@hidden wrote:
>
>
On samedi, fivrier 8, 2003, at 12:50 PM, Arthur VIGAN wrote:
>
>
> Hi,
>
>
>
> I have a black and white NSImage, and I would like to know if it is
>
> possible to invert this image (ie making white pixels black, and black
>
> pixels white)?
>
>
Link:
>
>
http://developer.apple.com/samplecode/Sample_Code/Graphics_2D/
>
Image_Difference.htm
>
>
This code can be optimized I think as it's using:
>
>
pixel = 255-pixel;
>
>
to invert the value, when this might be faster to do:
>
>
pixel=~pixel;
>
>
and this might be even 32 bits optimized for B&W Bitmaps.
Yes, I could have done it that way, and I could also have munged several
pixels at once with altivec code, but the idea in sample code is to make
it as clear as possible.
As for performance, the difference (if any) between bitwise inversion
and subtraction of an 8-bit constant is negligible.
-jcr
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.