CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Image Opacity

  1. #1
    Join Date
    Mar 2000
    Location
    canada
    Posts
    60

    Image Opacity

    Hi,

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

    Thanks in advance.

    "the opposition of the opposites is the engine of becoming"

  2. #2
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: Image Opacity

    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





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured