MakeTransparent for image

I tried the below and it is not making the black color transparent. Any ideas?

    static public Image img_cursor = null;
    static System.Drawing.Graphics img_cursor_src = System.Drawing.Graphics.FromImage(Resources.GetBitmap(Resources.BitmapResources.heat_30));

        img_cursor_src.MakeTransparent(System.Drawing.Color.Black);

        img_cursor = new Image()
        {
            Source = BitmapImage.FromGraphics(img_cursor_src),
            Height = 30,
            Width = 30,
            
        };

        //led left
        Canvas.SetLeft(img_cursor, 0);
        Canvas.SetTop(img_cursor, 0);

you didn’t make the copied image transparent?

Are you sure it is 0,0,0 black?

I am sure it will work, after you read this :))

MakeTransparent on Graphics doesn’t work - TinyCLR OS - GHI Electronics’ Forums

or this:

MakeTransparent not seeming to do anything - TinyCLR OS - GHI Electronics’ Forums

Short answer is you need to use a color with the alpha channel set to 0. Instead of System.Drawing.Color.Black (which is 0xFF000000), use Color.FromArgb(0x00000000). Not sure if this is intended but it is the only way to make it work.

2 Likes