Re: How to make an eraser -- need new CompositingMode?

From: BlueMonkMN (BlueMonkMN_at_email.com)
Date: 05/03/04


Date: 3 May 2004 05:36:20 -0700

Why would I go to all that trouble when I could just create a solid
brush of the background color, set the SmoothingMode to AntiAlias and
get the desired effect? The problem is I don't have a solid
background color. My background is alpha 0 (transparent). In design
mode (when the user is drawing the graphics) I draw whatever the user
wants to put in the background as a backdrop to see the transparency
in action (a diamond or diagonal crosshatch pattern of gray shades).
But I clearly don't want to be putting this in the image being edited
itself. The graphics they are creating need to be able to blend with
any background. Since my primary goal is to erase to alpha 0, I think
SrcCopy is as close as I can get (although I should be able to do
getpixel and setpixel to set the alpha components manually and get
exactly what I need). Anti-aliasing is a secondary goal, and I
definitely wouldn't want to give up being able to truly erase (to
alpha = 0) in order to get it.

"Frank Hileman" <frankhil@no.spamming.prodigesoftware.com> wrote in message news:<en#Ejs6LEHA.1312@TK2MSFTNGP12.phx.gbl>...
> What about this: Create a small bitmap, clear its pixels to transparent,
> create a Graphics from that Bitmap, and draw into it a path gradient fill
> the shape of a circle, with the center opaque, the background color, and the
> edges transparent. The size of the circle is the size of your eraser. Since
> you are using a path gradient it will be opaque at the center and fade to
> transparent at the edges. There are many other path gradient parameters you
> can use.
>
> Now when you draw this bitmap onto another bitmap, or the screen, it will
> "erase" strongest in the center, and less around the edge. It does not erase
> by changing alpha, but by covering with the background color.
>
> I think this is as close as you can get -- I don't think there is a way to
> modify only the alpha component, short of writing your own pixel
> manipulation routines, but it would be nice if someone could prove me wrong!
>
> Regards,
> Frank Hileman



Relevant Pages

  • Re: Bitmap to Icon
    ... What I'm doing is reading an .ico file then converting it to a bitmap which I ... I make the background color transparent then convert it back to ...
    (microsoft.public.dotnet.languages.vb)
  • Having trouble with picture control VS.NET Unmanaged C++.
    ... I've dropped a picture control onto a dialog & loaded a bitmap using a ... The "Transparent" property of the picture ... bitmap somehow to get the background color to be transparent? ...
    (microsoft.public.win32.programmer.ui)
  • Re: Transparent Merging (Antialias problems)
    ... > Are there any kind of algorythms to get the alpha values of the foreground ... look at the alpha value and store it in some ... > background color is green or white or black or any other color as long as ... the pixels around the edges will not ...
    (comp.lang.pascal.delphi.misc)
  • Setting the transparency color of a bitmap
    ... I have a method i found for setting the background of a bitmap ... transparent but its slow must be an easier way than saving the image ... then setting all the pixels to the background color. ... graphics.Clear and the transparent color but no luck, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Alpha Channels Bitmaps
    ... deal with alpha. ... >> selection of Windows themes would not have an ugly impact on the ... >> fine if the active Windows theme has white as the background color ... >> the resource editor to include the bitmap file with alpha channel ...
    (microsoft.public.vc.mfc)