summaryrefslogtreecommitdiff
path: root/plugingui/eventhandler.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2012-12-28 14:14:39 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2012-12-28 14:14:39 +0100
commit2310f168399d11bf05549abeaec117aa32a0f2fb (patch)
treeca43c41fa4a2797b4bd67996a23ef198e1ffe298 /plugingui/eventhandler.cc
parentf440919d67279ee5bf30ddb1b412e25725bcc2cf (diff)
Use bitmap blitting on win32 drawing.
Diffstat (limited to 'plugingui/eventhandler.cc')
-rw-r--r--plugingui/eventhandler.cc72
1 files changed, 65 insertions, 7 deletions
diff --git a/plugingui/eventhandler.cc b/plugingui/eventhandler.cc
index aa0e5e9..0d77665 100644
--- a/plugingui/eventhandler.cc
+++ b/plugingui/eventhandler.cc
@@ -251,14 +251,46 @@ LRESULT CALLBACK dialogProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
handler->event = e;
+#if 1
+ // Move to window.h (in class)
+ HDC pDC;
+ HBITMAP old;
+ HBITMAP ourbitmap;
+ int * framebuf;
+ GUI::PixelBuffer &px = gwindow->wpixbuf;
+
+ { // Create bitmap (move to window.cc)
+
+ HDC hDC;
+ BITMAPINFO bitmapinfo;
+ hDC=CreateCompatibleDC(NULL);
+ bitmapinfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
+ bitmapinfo.bmiHeader.biWidth=px.width;
+ bitmapinfo.bmiHeader.biHeight=-px.height; /* top-down */
+ bitmapinfo.bmiHeader.biPlanes=1;
+ bitmapinfo.bmiHeader.biBitCount=32;
+ bitmapinfo.bmiHeader.biCompression=BI_RGB;
+ bitmapinfo.bmiHeader.biSizeImage=0;
+ bitmapinfo.bmiHeader.biClrUsed=256;
+ bitmapinfo.bmiHeader.biClrImportant=256;
+ ourbitmap=CreateDIBSection(hDC,&bitmapinfo,DIB_RGB_COLORS,(void**)&framebuf,0,0);
+ pDC=CreateCompatibleDC(NULL);
+ old=(HBITMAP__*)SelectObject(pDC,ourbitmap);
+ DeleteDC(hDC);
+
+ }
+ { // Copy GUI::PixelBuffer to framebuffer (move to window.cc)
-
-
-
-
-
+ int i,j,k;
+ for (k=0,i=0;i<px.height;i++)
+ for (j=0;j<px.width;j++,k++)
+ *(framebuf+k)=RGB(px.buf[(j + i * px.width) * 3 + 2],
+ px.buf[(j + i * px.width) * 3 + 1],
+ px.buf[(j + i * px.width) * 3 + 0]);
+ }
+
PAINTSTRUCT ps;
// RECT rect;
HDC hdc;
@@ -267,8 +299,33 @@ LRESULT CALLBACK dialogProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
// HBRUSH m_brush;
// HPEN m_penh, m_pens; //Outer
// HPEN m_penih, m_penis; //Inner
-
+
hdc = BeginPaint(handler->gctx->m_hwnd, &ps);
+ BitBlt(hdc,0,0,px.width,px.height,pDC,0,0,SRCCOPY);
+ EndPaint(handler->gctx->m_hwnd, &ps);
+
+
+
+
+ { // Destroy bitmap (move to window.cc)
+
+ SelectObject(pDC,old);
+ DeleteDC(pDC);
+ DeleteObject(ourbitmap);
+
+ }
+
+
+
+
+
+
+
+#else
+ PAINTSTRUCT ps;
+ // RECT rect;
+ HDC hdc;
+ hdc = BeginPaint(handler->gctx->m_hwnd, &ps);
if(hdc) {
// GetClientRect(handler->gctx->m_hwnd, &rect);
@@ -306,7 +363,8 @@ LRESULT CALLBACK dialogProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
*/
EndPaint(handler->gctx->m_hwnd, &ps);
}
-
+ //DeleteDC(hdc);
+#endif