Re: How to draw with a PEN ?? Please help

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Pamela -

After doing some tests, here's what I believe the issue is.

Your lines are not being drawn with an alpha of 255. What's happening is
that, since you are drawing over your filled shapes, the alpha-100 pen is
blending with the alpha-100 background and creating a color somewhere
between alpha-100 and alpha-255. Note that, if you draw your polygons and
then fill them, you will get lines that are closer to your fill color. But
it still won't be the same. I'm assuming you're filling first because your
output matches my tests when I fill first.

Changing the CompositingMode doesn't help. In fact, if I change it to
"SourceCopy", I get even worse results - the lines are drawn even more
starkly. However, the description of "SourceOver" seems to confirm what I'm
talking about above - the color of the pen will be blended with the
background based on the alpha component of the pen.

I guess I look at it this way: you are drawing your lines, presumably,
because you want to see them - right? So, in essence, you are getting what
you want. If you don't want to see the lines, then don't draw them.
Anything you try to do, since you are drawing over your alpha-blended
background, is not going to get you what you want - the alpha components of
the two objects will interace with each other, and you'll get what you're
getting. unless you create your pen with an Alpha of 0, which would be a
waste of time.

If you want the edges of your shapes to be defined in some fashion (which is
what I think you're really going after), then you'll have to create a new
polygon consisting of *only* your edge points, and draw that. Since you
want it defined for the user, I would think that what you're getting with
the pen you're using will work just fine (with the suggestion that you may
want to use a slightly thicker pen to get a bit more definition.) I also
believe that a polygon is not going to be the best thing for you in the
end - I think you'll want to investigate using a GraphicsPath to draw your
edges. But I may be wrong on that point.

HTH

- Scott

<expertware@xxxxxxxxx> wrote in message
news:1122359468.662976.64300@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Dear Scott and James,
>
> Thank you very much for your suggestions.
> I have tried the Scott method (which actually I tried before)
> both using
> Graphics.CompositingMode =
> Drawing2D.CompositingMode.SourceOver
>
> Graphics.CompositingMode =
> Drawing2D.CompositingMode.SourceCopy
>
> In the first case the lines are still drawn with alpha=255 and in the
> second case
> they are white (on a white background).
> I have made a web page with the picture I get using:
>
> Graphics.CompositingMode =
> Drawing2D.CompositingMode.SourceOver
> Dim br As New SolidBrush(Color.FromArgb(100,
> FacesBrush.Color))
> PenUsatoPerSpigoli = New Pen(br)
> Graphics.DrawPolygon(p, Points)
>
> as suggested by Scott. Here is the result:
>
> http://cam70.sta.uniroma1.it/TechnicalPreview/scott.htm
>
> as you see, while the faces are semitransparent, the edges are drawn
> with a alpha value different
> from that used by for the faces (although the brush is the same).
>
> I need the edgest to be colored the same way as the faces (faces use a
> brush with A=100) !! Any suggestion?
>
> Thanks you very much!!
>
> Pamela
>


.



Relevant Pages

  • Wierd problem when alpha blitting image with text in it
    ... engine for displaying graphical interfaces drawn with our design tool. ... The base interface (what you see in the background behind the popup) is ... all all the alpha channel bytes are set ot fully transparent. ... The second bitmap is composited onto the first one using a blit (alpha if ...
    (microsoft.public.win32.programmer.gdi)
  • Re: Drawing Solid and See Through Lines
    ... The mechanism for opacity is a subset of the LayeredWindow API. ... The way it works is the form will be drawn onto a bitmap buffer in memory ... comprehensive implementation includes a per-pixel alpha scheme in which the ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Alpha Blending
    ... > I am struggling to understand Direct3D alpha blending. ... I have a 2d interface which is drawn from texture ... > And the texture stage states are: ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Drawing XP icons using GDI+
    ... I am using GDI+ to draw my control...when I use DrawImage to draw an XP ... icon(32-bit with alpha), the alpha is not drawn. ... Is there a way to draw XP icons using GDI+. ...
    (microsoft.public.win32.programmer.gdi)
  • Re: 32bit xp icon alpha blending
    ... Do I have to put special params to draw the alpha icon...because it drawn weird. ...
    (borland.public.delphi.nativeapi)