[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.drawing

Re: Changing BackgroundImage doesn't work properly with transparency

Michael Herman \(Parallelspace\)

12/30/2004 3:31:00 PM

Plse note: This is not the traditional "I can't get transparency to work"
issue.

Transparency works ...the problem I'm having is changing the BackgroundImage
after I've set it the first time. The new image is overlaying the first
....not fully replacing it like I expect/want.

Cheers,
Michael.

"Michael Herman (Parallelspace)"
<mwherman@parallelspace.$nospam$.net.$please$> wrote in message
news:%23eY9cjc7EHA.3856@tk2msftngp13.phx.gbl...
> When I run the sample code below, I expect the background image of the
> borderless winform to change to that of the new Bitmap image (and for the
> form to resize to fit the bitmap). The latter works fine but instead of
> the new image replacing the old background image, they are being overlayed
> on top of each other. The attached screen shot shows the results of
> right-clicking on the winform (I used Paint to paste these side-by-side).
> The red circle background is 200x200 and the green circle background is
> 200x300 (with the circle shifted down relative to the position of the
> circle in the other image).
>
> Any ideas on how to fix this? I'm running WinXP SP2 on a Dell Inspiron
> 8200.
>
> private void main_window_MouseUp(object sender,
> System.Windows.Forms.MouseEventArgs e)
>
> {
>
> if (e.Button == MouseButtons.Right)
>
> {
>
> this.BackgroundImage = null;
>
> //this.TransparencyKey = Color.AliceBlue;
>
> System.Drawing.Bitmap bmpTemp = null;
>
> if (bOdd)
>
> {
>
> bmpTemp = new Bitmap(GetType(),"P2b.bmp");
>
> }
>
> else
>
> {
>
> bmpTemp = new Bitmap(GetType(),"P3b.bmp");
>
> }
>
> bOdd = ! bOdd;
>
> bmpTemp.MakeTransparent(bmpTemp.GetPixel(10,10));
>
> this.BackgroundImage = bmpTemp;
>
> this.TransparencyKey = bmpTemp.GetPixel(10,10);
>
> this.ClientSize = this.BackgroundImage.Size;
>
> }
>
>
> }
>
>
>