BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Fill an area in transparent mode

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
Keven Corazza
Guest





PostPosted: Fri Nov 17, 2006 8:29 pm    Post subject: Fill an area in transparent mode Reply with quote



Hi to all,

I would like to know if there is a way to fill an area, using standard
Canvas.Polygon method, in a transparent mode. So I would like to fill the
area, in red for example, but at the same time I would like to see the
drawing below the area.

Is there a way to reach this result ? Even if it is not possible with
Canvas.Polygon method, could you suggest my a solution ?

Thank you in advance for your help.

Keven Corazza
Back to top
Peter Below (TeamB)
Guest





PostPosted: Sat Nov 18, 2006 12:50 am    Post subject: Re: Fill an area in transparent mode Reply with quote



Keven Corazza wrote:

Quote:
Hi to all,

I would like to know if there is a way to fill an area, using
standard Canvas.Polygon method, in a transparent mode. So I would
like to fill the area, in red for example, but at the same time I
would like to see the drawing below the area.

Is there a way to reach this result ? Even if it is not possible with
Canvas.Polygon method, could you suggest my a solution ?


The standard GDI API TCanvas is based on does not support brush colors
with an alpha channel. GDI+, however, does.

http://www.progdigy.com/modules.php?name=gdiplus (by Henri Gourvest)

used to have Delphi units for interfacing with GDI+. It is a very
different system then GDI in terms of usage, so may take some time to
get used to.

The Graphics32 library: http://sourceforge.net/projects/graphics32 has
routines for a number of visual effects, you may find something useful
there as well (never looked at it myself).

It is possible to do this with plain GDI as well, but it requires
considerable effort. The sequence would go like this:

- create a region from the polygon (CreatePolygonRgn)
- determine the regions bounding box (GetRgnBox)
- copy the rectangle inside this box from your canvas to an
off-screen bitmap that has been set up to the size of the
bounding box.
- alpha-blend the pixels in this bitmap with red in code. The
algorithm for that has been published in this group several
times in the past, you should be able to find it in the
newsgroup archives (see my signature).
- use SelectClipRgn to make the polygon the clipping region for
your canvas.
- copy the modified bitmap back to the canvas at its old position.
- clear the clipping region
- set the canvas brush style to bsClear and draw the polygon
outline, if you need that.
- delete the region created in step 1


--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be
Back to top
Keven Corazza
Guest





PostPosted: Sat Nov 18, 2006 4:19 pm    Post subject: Re: Fill an area in transparent mode Reply with quote



Dear Peter,

I've to thank you for the very useful suggestion. GDIPLus library from
Progdigy solve my problem and I've to say that they are very easy to use.

Thank you again.

Keven Corazza
Italy

"Peter Below (TeamB)" <none> ha scritto nel messaggio
news:xn0etu2su1thlx001 (AT) newsgroups (DOT) borland.com...
Quote:
Keven Corazza wrote:

Hi to all,

I would like to know if there is a way to fill an area, using
standard Canvas.Polygon method, in a transparent mode. So I would
like to fill the area, in red for example, but at the same time I
would like to see the drawing below the area.

Is there a way to reach this result ? Even if it is not possible with
Canvas.Polygon method, could you suggest my a solution ?


The standard GDI API TCanvas is based on does not support brush colors
with an alpha channel. GDI+, however, does.

http://www.progdigy.com/modules.php?name=gdiplus (by Henri Gourvest)

used to have Delphi units for interfacing with GDI+. It is a very
different system then GDI in terms of usage, so may take some time to
get used to.

The Graphics32 library: http://sourceforge.net/projects/graphics32 has
routines for a number of visual effects, you may find something useful
there as well (never looked at it myself).

It is possible to do this with plain GDI as well, but it requires
considerable effort. The sequence would go like this:

- create a region from the polygon (CreatePolygonRgn)
- determine the regions bounding box (GetRgnBox)
- copy the rectangle inside this box from your canvas to an
off-screen bitmap that has been set up to the size of the
bounding box.
- alpha-blend the pixels in this bitmap with red in code. The
algorithm for that has been published in this group several
times in the past, you should be able to find it in the
newsgroup archives (see my signature).
- use SelectClipRgn to make the polygon the clipping region for
your canvas.
- copy the modified bitmap back to the canvas at its old position.
- clear the clipping region
- set the canvas brush style to bsClear and draw the polygon
outline, if you need that.
- delete the region created in step 1


--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.