Click to See Complete Forum and Search --> : Image Opacity


Off
August 9th, 2001, 05:00 PM
Hi,

i want to know if it is possible in VB to change the opacity of an image.

Thanks in advance.

shree
August 9th, 2001, 07:55 PM
Yes, using the AlphaBlend() function from msimg32.dll
Here's the declaration:

Private Declare Function AlphaBlend Lib "msimg32.dll" (ByVal hdcDest As Long, ByVal nXOriginDest As Long, ByVal nYOriginDest As Long, ByVal nWidthDest As Long, ByVal nHeightDest As Long, ByVal hdcSrc As Long, ByVal nXOriginSrc As Long, ByVal nYOriginSrc As Long, ByVal nWidthSrc As Long, ByVal nHeightSrc As Long, ByVal BF As Long) As Long

The third byte of the BF parameter is the transparency. Here's a sample call:

Dim lngBlend as Long
Dim Trans as Integer
Trans = 120 'Can be from 0 to 255
lngBlend = Val("&h" & Hex(Trans) & "00" & "00")
AlphaBlend destHDC, XDest, YDest, destWidth, destHeight, srcHDC, XSrc, ycrc, srcWidth, srcHeight, lngBlend