GDI Renderer - very bad attempt to start bitmap support

This commit is contained in:
adelikat 2014-09-03 02:24:13 +00:00
parent c84d8ec93c
commit 21404611ab
2 changed files with 28 additions and 0 deletions

View File

@ -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[]));
}
/// <summary>
/// Draw a bitmap object at the given position
/// </summary>
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);
}
/// <summary>
/// Required to use before calling drawing methods
/// </summary>
@ -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

View File

@ -500,6 +500,8 @@ namespace BizHawk.Client.EmuHawk
//Foreground
DrawData(e);
Gdi.DrawBitmap(Properties.Resources.te_arrow, 1, 1);
Gdi.CopyToScreen();
Gdi.EndOffScreenBitmap();
}