Transparency by image in GDI
-
Hi, I'm trying to use GDI to make a bitmap from a variety of other bitmaps. I'm new to vb2005 from vb6, and I've figured out how to bitblt from one hDC to another, and get the resulting graphics to appear. What I want to know is how to display a transparent bitmap, based on an alpha channel. I can use an alpha mask, but this doesn't seem to work for shades of grey. I keep seeing code snippets that set a global transparency for your image to be used, but I need transparency per pixel, and at least 255 shades so that it blends or completely covers the bitmap underneath. I'm going to be using multiple images that overlay to make a final image. I'm fine with the graphics side of it, I know how to make alpha layers for PNG's etc and how they work. I just can't code it in. This code is not complete - it's been cut out to show the basic method I'm using. I'm copying a variety of graphics into a 'master graphic', then stretching that result into the size I require on my form (so it will cope at any resized form) HDC4 is a small graphic to paste into HDC3 (my 'master image') - HDC4 is what I want to have transparency with HDC5 is the stretched target
Dim PictSrc As New Bitmap(texture(1)) 'Picture that goes from file to memory Dim PictMem As Graphics = Graphics.FromImage(PictSrc) Dim HDC4 As IntPtr = PictMem.GetHdc BitBlt(HDC3, xpos, ypos, 100, 75, HDC4, 0, 0, &HEE0086) StretchBlt(HDC5, 0, 0, Ship_Systems_Graphic.Width, Ship_Systems_Graphic.Height, HDC3, 0, 0, 453, 192, &HCC0020)
Any help is appreciated. www.c-digital-art.co.uk