Results 1 to 5 of 5

Thread: Hlp with alphablend

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    30

    Hlp with alphablend

    Hi everyone,

    I'm learning VB and hope you can help?

    I can use alphablend to produce the result i want which i display in a picture box and everything looks great. The problem is that if i then try and reference the picture i have just produced i dont display the picture?

    For example

    if objItem.Lockout = False then
    Set msflexgrid.CellPicture = Picture2 'picturebox where alphablend image displayed
    End If

    I guess i'm doing something silly but i dont know what

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Hlp with alphablend

    Moved from the CodeBank

  3. #3
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Talking Re: Hlp with alphablend

    Hai berrick

    not sure exactly what your problem is weather with displaying alphablended picture or with your flexgrid. Here is an Alphablended picture discussion thread: http://www.vbforums.com/showthread.php?t=463045

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    30

    Re: Hlp with alphablend

    Thanks for the reply Fazi,

    I'm trying to do something more basic than shown in those threads....
    Here is the code

    Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
    lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long)

    Private Type BLENDFUNCTION
    BlendOp As Byte
    BlendFlags As Byte
    SourceConstantAlpha As Byte
    AlphaFormat As Byte
    End Type
    ' BlendOp:
    Private Const AC_SRC_OVER = &H0
    ' AlphaFormat:
    Private Const AC_SRC_ALPHA = &H1

    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 lBlendFunction As Long) As Long

    Private Sub Form_Paint()

    Dim lBlend As Long
    Dim bf As BLENDFUNCTION

    bf.BlendOp = AC_SRC_OVER
    bf.BlendFlags = 0
    bf.SourceConstantAlpha = 255
    bf.AlphaFormat = AC_SRC_ALPHA
    CopyMemory lBlend, bf, 4

    AlphaBlend Picture3.hDC, 0, 0, _
    Picture3.ScaleWidth \ Screen.TwipsPerPixelX, _
    Picture3.ScaleHeight \ Screen.TwipsPerPixelY, _
    Picture1.hDC, 0, 0, _
    Picture1.ScaleWidth \ Screen.TwipsPerPixelX, _
    Picture1.ScaleHeight \ Screen.TwipsPerPixelY, _
    lBlend
    Picture2.Picture = Picture3.Picture
    End Sub

    Similar to other code i have seen in other threads on this site.
    Anyway, as i have stated all appears to work, i have picturebox1 loaded with a picture with plenty of black on the alpha channel this is combined with and displayed in picturebox3 which before this code runs has a purple fill. Therefore picturebox3 displays a purple backgroound and the picture from picturebox1 without the black.

    If i then try to display the picture in picturebox3 in picturebox2 i get a picturebox with a gray fill nothing else??


    Hope this clearifies my problem.

    Hoping someone can point out what i'm doing wrong

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    30

    Re: Hlp with alphablend

    Bump.

    Anyone able to offer a posible answer??

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