Re: Unknown transparency mask color -- how to?



Mike,

OK, I think I'm finally seeing the light at the end of the tunnel.

Current (bad) Method: "Blank out DC" using a FillRect of color XYZ. Use
various tools (BitBlt, TextOut, Lines, etc...) to put objects on that layer.
TransparentBlt/ChromaBLT the layer with a transparency color of XYZ.
Problems and issues with this already described below. Your comments
understood.

New Proposed Method: Create a layer with an alpha channel of 0 across the
board, and render my objects onto it (using standard APIs as listed above).
You said anything that GDI touches gives an Alpha of 100, correct?? So a
final alpha blend would only show the objects, lines, etc... that I've
placed on it, correct?

If this is true, 2 questions
1.) What is the most optimum way to way to create a DC with height/width of
lHeight and lWidth that has an alpha channel of 0 across it.
2.) Once this layer is created and I need to re-render the objects on it, is
there a quick way to "wipe it clean" -- resetting everything as above to
alpha 0 with nothing on it??

I hope I'm making myself clear :( Sorry for all the confusion.

Evan

"Mike D Sutton" <EDais@xxxxxxxx> wrote in message
news:etlxjYKFHHA.3304@xxxxxxxxxxxxxxxxxxxxxxx
I'm still stumped at the final phase on my graphics merging. Putting
everything I've done together...

There are two main layers of bitmaps that I have. A changing bottom layer
(an changing array of DCs blt'd into a picture box hdc via a timer), and
an quasi-static top layer that serves as an overlay.

The top layer consists of various objects, including the transparent png
graphics you helped me with in a previous thread.

There are several major problems I'm having with this top layer --

Right now, I am simply creating the overlay layer as a compatible DC
and pre-setting the layer by performing a FillRect of some color I
"hoped" wasn't present in the overlay layer.

This image doesn't need a 'background' colour since it already has a full
alpha channel and as such won't be drawn with Transparent/ChromaBlt().

1.) If the items on the overlay layer are that transparency color,
they obviously get wiped out when I perform a TransparentBLT/ChromaBLT. I
alluded to this in my 11/13 thread. I read your wonderful reply post but
in light of the 2nd issue below, I'm not sure I'm handling this
correctly.

Again, since you'll be using AlphaBlend() to draw the top layer, this
solves this problem too.

2.) The other big problem I noticed is that when I perform the
modifyDIBarray hack and alpha blend the transparent .png's into the
overlay DC, I'm alphablending into that solid transparent color (set with
the FillRect above). So, say my pre-selected transparency color is green
(0,255,0). If a pixel from a transparent png had an alpha value of say
10, the alpha blend results in a "slightly" altered shade of green on the
overlay layer. Thus, when I perform the final TransparentBLT/ChromaBLT,
my final image shows these "slightly" modified green pixels. Obviously
for both these problems, this is the completely wrong approach.

See above ;)

I guess what I'd like to do is create this top overlay layer with an
alpha of 0. I'd also like to place the transparent pngs from the file
into this layer, but preserve their alpha value and not perform the
modDIBarray hack/alpha blend until we merge this overlay layer with the
base data layer. Obviously I need a completely different approach to
create an overlay layer that has these transparent .pngs on them to be
ultimately blending into my final base layer. I'm utterly lost in this
code right now :(

GDI doesn't handle alpha particularly well, however the AlphaBlend() API
call does actually do a pretty good job of preserving alpha data (IIRC) so
you can use that for this case. Be aware though that alpha-blending is a
quite costly process so unless you need to create a full-screen buffer
with an alpha channel, I would recommend just drawing the individual
elements to the top layer on their own. Of course, if they overlap each
other than you may want to create a composite and just draw that, but it
really depends on the situation as to which method to take for optimal
performance.
Hope this helps,

Mike


- Microsoft Visual Basic MVP -
E-Mail: EDais@xxxxxxxx
WWW: Http://EDais.mvps.org/



.



Relevant Pages

  • Re: Make a color semi-transparent.
    ... I know how to make a color transparent using Gimp (by defining an alpha ... Choose to apply your changes only the the ALPHA layer. ... In that case, with the selection made, add a white layer mask to the ...
    (comp.graphics.apps.gimp)
  • Re: Backpropagation Neural network Code problem
    ... % sigmak Portion of error correction weight adjustment for wjk that is due ... % alpha Learning rate ... % v0j Bais on the hidden unit j. ... %%%First hidden Layer ...
    (comp.soft-sys.matlab)
  • Re: Backpropagation Neural network Code problem
    ... % layer to the hidden unit Z_j. ... % alpha Learning rate ... % v0_j Bais on the hidden unit j. ... iteration = iteration +1; ...
    (comp.soft-sys.matlab)
  • Re: Using Alpha for non-transparent images
    ... Put the mouse over the alpha layer and ctrl-Lclick. ... your method worked on layer masks and not the alpha channel, ... channel to include the data of this new layer mask and add a big white ...
    (comp.graphics.apps.gimp)
  • Re: Backpropagation Neural network Code problem
    ... % alpha Learning rate ... % v0j Bais on the hidden unit j. ... %%% Initialization of the Input / Target ... %%%First hidden Layer ...
    (comp.soft-sys.matlab)

Loading