Frustration..

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

Hello,

Bitmap.MakeTransparent( ) causes some really wild graphical anomalies.
This must me a bug. Does anyone know a work-around?
Can anyone shed some light on this issue?

To see this in action just do the following:

1. Create a new Windows Application Project
2. Add two buttons to the form (make button2 bigger than button1).
3. Add the following three lines of code to Form1_Load( )

Bitmap img = new Bitmap(@"c:\test.bmp"); //use any .bmp file you desire
img.MakeTransparent();
this.button2.BackgroundImage = img;

Run it.

Thanks, Jeff
 
Hi Jeff,
Calling img.MakeTransparent() makes the LightGray or the left-bottom pixel's color as
the color key.
Please check your bmp or use MakeTransparent Method (Color) instead. With this
function, you can specify the color the color to make transparent as you like.


Thanks,
Rhett Gong [MSFT]
Microsoft Online Partner Support

This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only. Thanks.
 
Hi Rhett,

Thanks for replying.

I have tried MakeTransparent(Color), and it behaves in a similar manner.
Please try the following:

1. Create a new Winforms App.

2. Add two buttons (make button 2 larger)

3. Add this code to Form1_Load()

Bitmap img = new Bitmap(@"c:\test.bmp");
img.MakeTransparent();
this.button2.BackgroundImage = img;
this.button2.Invalidate();

4. Run it, press button2 a couple of times and let me know if button2
behaves properly.

Don't worry about the wallpapering effect of the bitmap.
Also, you can use any bitmap you like.

Thanks, Jeff
 
I was focusing on the wrong class.
The Bitmap::MakeTransparent( ) looks fine.
However, Control::BackgroundImage appears to be the culprit.
Using ButtonBase::Image appears to work fine with the bitmap that
was manipulated by MakeTransparent( ).

Lesson learned: avoid BackgroundImage, and use Image instead!

Thanks again.

Regards, Jeff
 
Hi Jeff,
Glad to see you have found a workaround for this problem. :-)
If you need assist, please feel free to post it in this newsgroup.


Best regards,
Rhett Gong [MSFT]
Microsoft Online Partner Support

This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only. Thanks.
 
Back
Top