diff --git a/BizHawk.Client.EmuHawk/CustomControls/GDIRenderer.cs b/BizHawk.Client.EmuHawk/CustomControls/GDIRenderer.cs index b4a6b68a59..4fc70667e9 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/GDIRenderer.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/GDIRenderer.cs @@ -65,12 +65,19 @@ namespace BizHawk.Client.EmuHawk.CustomControls /// /// Draw a bitmap object at the given position /// - public void DrawBitmap(Bitmap bitmap, Point point) + public void DrawBitmap(Bitmap bitmap, Point point, bool blend = false) { IntPtr hbmp = bitmap.GetHbitmap(); var bitHDC = CreateCompatibleDC(CurrentHDC); IntPtr old = new IntPtr(SelectObject(bitHDC, hbmp)); - BitBlt(CurrentHDC, point.X, point.Y, bitmap.Width, bitmap.Height, bitHDC, 0, 0, 0xCC0020); + if (blend) + { + AlphaBlend(CurrentHDC, point.X, point.Y, bitmap.Width, bitmap.Height, bitHDC, 0, 0, bitmap.Width, bitmap.Height, new BLENDFUNCTION(AC_SRC_OVER, 0, 0xff, AC_SRC_ALPHA)); + } + else + { + BitBlt(CurrentHDC, point.X, point.Y, bitmap.Width, bitmap.Height, bitHDC, 0, 0, 0xCC0020); + } SelectObject(bitHDC, old); DeleteDC(bitHDC); } @@ -365,6 +372,29 @@ namespace BizHawk.Client.EmuHawk.CustomControls [return: MarshalAs(UnmanagedType.Bool)] static extern bool BitBlt([In] IntPtr hdc, int nXDest, int nYDest, int nWidth, int nHeight, [In] IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop); + [DllImport("gdi32.dll", EntryPoint = "GdiAlphaBlend")] + static extern bool AlphaBlend(IntPtr hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, IntPtr hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, BLENDFUNCTION blendFunction); + + [StructLayout(LayoutKind.Sequential)] + public struct BLENDFUNCTION + { + byte BlendOp; + byte BlendFlags; + byte SourceConstantAlpha; + byte AlphaFormat; + + public BLENDFUNCTION(byte op, byte flags, byte alpha, byte format) + { + BlendOp = op; + BlendFlags = flags; + SourceConstantAlpha = alpha; + AlphaFormat = format; + } + } + + const byte AC_SRC_OVER = 0x00; + const byte AC_SRC_ALPHA = 0x01; + [DllImport("gdi32.dll")] static extern int SetBitmapBits(IntPtr hbmp, uint cBytes, byte[] lpBits); diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs index 70569d90b3..2e0744a76b 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs @@ -632,7 +632,7 @@ namespace BizHawk.Client.EmuHawk if (image != null) { - Gdi.DrawBitmap(image, new Point(col.Left.Value, point.Y + 1)); + Gdi.DrawBitmap(image, new Point(col.Left.Value, point.Y + 1),true); } else {