views:

2186

answers:

3

I wish to make a bitmap image (.bmp) transparent using VB.NET code. Kindly help me.

A: 

This msdn article gives full details on how to do this

Here is another article, but code sample is in c#

Binoj Antony
+1  A: 

I found the key was using the imageAttributes class. Basically set the color key to the color you are using to represent the transparent area, and use one of the drawImage calls that accepts an imageAttribute parameter...

Imports System.Drawing.Imaging

' and in a sub somewhere:

Private mImageAttributes As New ImageAttributes mImageAttributes.SetColorKey(Color.FromArgb(0, 220, 20, 255), Color.FromArgb(0, 220, 20, 255))

Dim imageRectangle As New Rectangle(pX, pY, pBitmap.Width, pBitmap.Height) e.Graphics.DrawImage(pBitmap, imageRectangle, 0, 0, pBitmap.Width, pBitmap.Height, GraphicsUnit.Pixel, mImageAttributes)

Codezy
+1  A: 

Everything you need to know about transparency with GDI+ (.NET windows forms applications).

Martin