2

I am creating a C# WinForms application with a transparent background and a transparent background image which is pasted in the form background. The background image is not displayed properly because it shows the green background of some parts of the image. When I show the image in the application's background without setting the TransparencyKey and BackColor, the image is displayed correctly.

BackColor = Color.LimeGreen;
TransparencyKey = Color.LimeGreen;
BackgroundImage = Image.FromFile(@"c:\Temp\cherries.png");

Please see the image: Picture vs winform application

Abbas
  • 14,186
  • 6
  • 41
  • 72
Myth Rush
  • 1,088
  • 1
  • 9
  • 19
  • 1
    follow this http://stackoverflow.com/questions/395256/transparent-images-with-c-sharp-winforms?rq=1 – Jibran Khan Apr 15 '13 at 09:47
  • What is your question? – Roy Dictus Apr 15 '13 at 09:48
  • I want to display transparent cherries in the transparent form application correctly. – Myth Rush Apr 15 '13 at 09:51
  • You need a different transparency mode, per-pixel alpha blending. It isn't directly supported by winforms because it is very incompatible with traditional GDI rendering in Windows which renders RGB with an alpha of 0. So controls like TextBox are not visible. It is the default mode for WPF, you can easily google winforms code with a "winforms per-pixel alpha" query. – Hans Passant Apr 15 '13 at 11:54

0 Answers0