|
|
Clearing an NSImage
|
|
|
|
Dedicated MacNNer
Join Date: Nov 2000
Status:
Offline
|
|
Hello ...
How do I clear the contents of an NSImage, leaving a blank and transparent canvas for redrawing?
Using NSBezierPath's fillRect: with clearColor (or any color with a zeroed alpha) just coats the image with transparent paint, effectively doing nothing. NSColor's swatchInRect draws the half-white-half-black square.
I _can_ copy in a transparent .tiff or something of that sort, but shouldn't there be a straighforward way to "paint" nothingness in? (Right now I'm interested in knocking out an entire image; but what if I want to "remove" a particular shape within an image by making its pixels transparent?) I can't seem to find an appropriate method.
Thanks ...
DayLateDon
|
|
|
|
|
|
|
|
|
Junior Member
Join Date: Dec 2000
Location: Boston, MA USA
Status:
Offline
|
|
Ran across this today in NSGraphics.h:
APPKIT_EXTERN void NSEraseRect(NSRect aRect);
Have you tried this function?
- Ross
|
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Nov 2000
Status:
Offline
|
|
Hello ...
NSEraseRect() just fills a rectangle with white; no transparency.
However, in checking that out, I ran across NSRectFillUsingOperation(NSRect aRect, NSCompositingOperation op). It's a "description forthcoming" function, but using NSCompositeClear for the operation seems to work just fine.
Thanks for the nudge ...
DayLateDon
|
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Jan 2001
Location: Virginia, US
Status:
Offline
|
|
Right, the default compositing operation is usually NSCompositeSourceOver, (layering over top) whereas you want to use NSCompositeCopy (replace the pixels with the specified color) or maybe NSCompositeClear as you found.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|