...ing logging 4.0

はてなブログに移行しました。D言語の話とかいろいろ。

Gdiplus::Graphics::DrawImage() が遅すぎて

void Draw(Graphics& g, int left, int top, int width, int height, Bitmap& bitmap)
{
	HBITMAP hBmp;
	HBITMAP* hOldBmp = NULL;
	bitmap.GetHBITMAP(Color(0,0,0), &hBmp);
	CDC dc;
	HDC hdc = g.GetHDC();
	dc.Attach(hdc);
	CDC MemDC;
	MemDC.CreateCompatibleDC(&dc);
	hOldBmp = (HBITMAP*)MemDC.SelectObject(hBmp);
	COLORREF backgroundColor = RGB(0,0,255);
	dc.TransparentBlt(
		left, top, width, height,
		&MemDC,
		0, 0, bitmap.GetWidth(), bitmap.GetHeight(),
		backgroundColor);
	MemDC.SelectObject(hOldBmp);
	DeleteObject(hBmp);
	MemDC.DeleteDC();
	dc.Detach();
	dc.DeleteDC();
	g.ReleaseHDC(hdc);
}