diff --git a/BizHawk.Client.EmuHawk/CustomControls/GDIRenderer.cs b/BizHawk.Client.EmuHawk/CustomControls/GDIRenderer.cs index 8560172cb9..d5ed56ea4e 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/GDIRenderer.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/GDIRenderer.cs @@ -62,6 +62,29 @@ namespace BizHawk.Client.EmuHawk.CustomControls #region Api + // TODO: extension method + private static byte[] ImageToByte(Image img) + { + ImageConverter converter = new ImageConverter(); + return (byte[])converter.ConvertTo(img, typeof(byte[])); + } + + /// + /// Draw a bitmap object at the given position + /// + public void DrawBitmap(Bitmap bitmap, int x, int y) + { + var bitHDC = CreateCompatibleDC(CurrentHDC); + var hbitmap = CreateCompatibleBitmap(CurrentHDC, bitmap.Width, bitmap.Height); + + SelectObject(bitHDC, hbitmap); + SetBkMode(bitHDC, BkModes.TRANSPARENT); + + var bytes = ImageToByte(bitmap); + SetBitmapBits(hbitmap, (uint)bytes.Length, bytes); + + } + /// /// Required to use before calling drawing methods /// @@ -349,6 +372,9 @@ 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")] + static extern int SetBitmapBits(IntPtr hbmp, uint cBytes, byte[] lpBits); + #endregion #region Classes, Structs, and Enums diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs index 077c4e93f5..007fff42ec 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs @@ -500,6 +500,8 @@ namespace BizHawk.Client.EmuHawk //Foreground DrawData(e); + Gdi.DrawBitmap(Properties.Resources.te_arrow, 1, 1); + Gdi.CopyToScreen(); Gdi.EndOffScreenBitmap(); }