[RESOLVED] Hot to have a transparent background in an ownerdrawn picture
I need to set a picture in a background which is painted ownerdrawn using a LinearGradientBrush. In the picture the background should exactly show the gradient changeing colors of the other background, so my figure looks like directly being drawn into the GradientBackground When I create the picture ( icon ) with microangelo and having the backgroundcolors as being transparent, I dont get the background in the same way as the rest of the background is. In the moment I do something like
Code:
protected override void OnPaint(PaintEventArgs pe)
{
Graphics g = pe.Graphics;
.....
// Drawing the Background
LinearGradientBrush b = new LinearGradientBrush(rec, startColor, endColor, 90);
g.FillRectangle(b, rec);
...
// drawing the picture
Rectangle srcRect = new Rectangle(new Point(0, 0), _HeaderPicture.Size);
g.DrawImage(_HeaderPicture, destRect, srcRect, g.PageUnit);
...
But this looks as if it doesnt really have a transparent background but only one Color of my Gradient brush in the full background area
How to do this correct, or do i need to draw the full Icon myself too ?
Drawing each dot, which is not transparent myself too?
In this case my question is how to read out the color data of an icon pixel by pixel and how to paint each single pixel ?
Jonny Poet
Re: Hot to have a transparent background in an ownerdrawn picture
I don't know if I understand your question correctly but perhaps you can use something like in this example here
http://www.bobpowell.net/transcontrols.htm
Re: Hot to have a transparent background in an ownerdrawn picture
Quote:
Originally Posted by Luthv
That comes near to the point to draw the icon myself So anyone knows how to read out Icon data and how to draw a pixel in a specific color so I can do a loop reading a point and if it hasn't transparent color then drawing the picel in its color.
Re: Hot to have a transparent background in an ownerdrawn picture
If you only want to draw icon with its transparent background then why not use DrawIcon method instead of DrawImage?
Re: Hot to have a transparent background in an ownerdrawn picture
Quote:
Originally Posted by Luthv
If you only want to draw icon with its transparent background then why not use DrawIcon method instead of DrawImage?
works thx:thumb: