画像透過転送(V) <TOP>
AlphaBlend
透過ピクセルと半透過ピクセルを持つビットマップを表示
MoveMemory
メモリの指定領域をコピー
GetDC
指定されたウィンドウのデバイスコンテキストのハンドルを取得
ReleaseDC
デバイスコンテキストを解放
'================================================================ '= 画像透過転送(V) '= (AlphaBlend3.bas) '================================================================ #include "Windows.bi" #define AC_SRC_ALPHA &H1 ' #define AC_SRC_OVER &H0 ' Type BLENDFUNCTION BlendOp As Byte 'ブレンド操作(AC_SRC_OVER) BlendFlags As Byte '常に0 SourceConstantAlpha As Byte 'コピー元のビットマップ全体に適用するアルファ値 AlphaFormat As Byte 'コピー元のビットマップがアルファ値を持つとき(AC_SRC_ALPHA) End Type ' 透過ピクセルと半透過ピクセルを持つビットマップを表示 Declare Function Api_AlphaBlend& Lib "msimg32" Alias "AlphaBlend" (ByVal hdcDest&, ByVal nXDest&, ByVal nYDest&, ByVal nWidthDest&, ByVal nHeightDest&, ByVal hdcSrc&, ByVal nXSrc&, ByVal nYSrc&, ByVal nWidthSrc&, ByVal nHeightSrc&, ByVal nBlendFunc&) ' メモリの指定領域をコピー Declare Sub MoveMemory Lib "Kernel32" Alias "RtlMoveMemory" (Dest As Any, Source As Any, ByVal Length&) ' 指定されたウィンドウのデバイスコンテキストのハンドルを取得 Declare Function Api_GetDC& Lib "user32" Alias "GetDC" (ByVal hWnd&) ' デバイスコンテキストを解放 Declare Function Api_ReleaseDC& Lib "user32" Alias "ReleaseDC" (ByVal hWnd&, ByVal hDC&) Var Shared Picture1 As Object Var Shared Picture2 As Object Var Shared Button1 As Object Var Shared Bitmap As Object Picture1.Attach GetDlgItem("Picture1") Picture2.Attach GetDlgItem("Picture2") Button1.Attach GetDlgItem("Button1") : Button1.SetFontSize 14 BitmapObject Bitmap '================================================================ '= '================================================================ Declare Sub MainForm_Start edecl () Sub MainForm_Start() Bitmap.LoadFile "Flower.bmp" Picture1.DrawBitmap Bitmap, 0, 0 Bitmap.DeleteObject Bitmap.LoadFile "Bike1.bmp" Picture2.DrawBitmap Bitmap, 0, 0 Bitmap.DeleteObject End Sub '================================================================ '= '================================================================ Declare Sub Button1_on edecl () Sub Button1_on() Var phDC1 As Long Var phDC2 As Long Var bf As BLENDFUNCTION Var lBF As Long Var Alpha As Byte Var Ret As Long phDC1 = Api_GetDC(Picture1.GethWnd) phDC2 = Api_GetDC(Picture2.GethWnd) Alpha = 180 bf.BlendOp = AC_SRC_OVER bf.BlendFlags = 0 bf.SourceConstantAlpha = Alpha bf.AlphaFormat = 0 MoveMemory lBF, BF, 4 Ret = Api_AlphaBlend(phDC1, 10, 10, 50, 50, phDC2, 0, 0, Picture2.GetWidth, Picture2.GetHeight, lBF) Ret = Api_ReleaseDC(Picture1.GethWnd, phDC1) Ret = Api_ReleaseDC(Picture2.GethWnd, phDC1) End Sub '================================================================ '= '================================================================ While 1 WaitEvent Wend Stop End