0

I am using AlphaBlend. Nothing special at all.

My code is working fine on Vista, Windows 7 and Windows 8, but not on Windows XP.

Usually AlphaBlend returns 1, but on XP it returns 0. I tested it on 2 XP computers.

I am totally baffled.

GetLastError returns "Successfully completed".

I am pretty sure that AlphaBlend should work on XP. Does anybody have any idea how to go on?

My (VB6-) code is

    Dim LBF As Long
    Dim bf As BLENDFUNCTION
    With bf
        .BlendOp = AC_SRC_OVER
        .SourceConstantAlpha = 255
    End With

    Call CopyMemory(LBF, bf, Len(bf))    'Copy struct into a Long var

(... some other stuff here....)

  Dim iRet&
    iRet = AlphaBlend(Me.Picture1.hdc, 0, 0, lDestWidth, lDestHeight, lOtherDC, 0, 0, (rOtherWin.Right - rOtherWin.Left), (rOtherWin.Bottom - rOtherWin.Top), LBF)

All values are valid and as expected, but AlphaBlend returns 0 anway.

Thank you.

tmighty
  • 10,734
  • 21
  • 104
  • 218
  • Can you show the code segment where you set up LBF – Isometric Jan 25 '13 at 16:09
  • Dim LBF As Long Dim bf As BLENDFUNCTION With bf .BlendOp = AC_SRC_OVER .SourceConstantAlpha = 255 End With Call CopyMemory(LBF, bf, Len(bf)) 'Copy struct into a Long var – tmighty Jan 25 '13 at 16:20
  • Private Type BLENDFUNCTION BlendOp As Byte BlendFlags As Byte SourceConstantAlpha As Byte AlphaFormat As Byte End Type – tmighty Jan 25 '13 at 16:21

2 Answers2

0

I found out why AlphaBlend fails. I try to AlphaBlend from a DC that is just a tiny bit out of the screen. If it is perfectly within the screen, AlphaBlend works great.

I am not sure however why this is so. If anybody knows, please just tell me!

tmighty
  • 10,734
  • 21
  • 104
  • 218
0

According to the documentation for AlphaBlend: The source rectangle must lie completely within the source surface, otherwise an error occurs and the function returns FALSE.

http://msdn.microsoft.com/en-us/library/windows/desktop/dd183351(v=vs.85).aspx

Isometric
  • 567
  • 7
  • 19
  • Do you know what is meant by "source surface"? – tmighty Jan 26 '13 at 07:09
  • 1
    That's your source device context (dc). If you need to blend only a portion of your source image you will need to create an intermediate bitmap. Blt from the original source into your intermediate, because that will allow a negative source offset. Then alpha blend your intermediate. – Isometric Jan 26 '13 at 12:57