A few days ago, I saw GDI on the blog of others, and I found out that it was also very simple. I didn't look at other information, I just saw the basic parts of GDI on MSDN. It is very convenient to find that what it can support is much more than GDI, at least the CXImage function library previously used to load JPG and do not distortion zoom and grayscale calculations, all of which are done with GDI .
This part is part of GDI: hbitmap hbitmap;
CDC * PDC = getdc (); hbitmap = createcompatiblebitMap (PDC-> M_HDC, g_devpicsize.cx, g_devpicsize.cy);
CBitmap * pOldBitmap1, * pOldBitmap2, * pOldBk; CDC srcdc; srcdc.CreateCompatibleDC (NULL); if (bCustomize == false) pOldBitmap1 = srcdc.SelectObject (CBitmap :: FromHandle (m_devpic)); else {if (bTemplate == true ) PoldbitMap1 = srcdc.selectObject (cbitmap :: fromHandle (m_custdevpic)); else PoldbitMap1 = srcdc.selectObject (cbitmap :: fromHandle (M_AllCustDevpic));}
CDC bkdc; bkdc.CreateCompatibleDC (NULL); pOldBk = bkdc.SelectObject (CBitmap :: FromHandle (m_hBkPic)); CDC dstdc; dstdc.CreateCompatibleDC (pdc); pOldBitmap2 = dstdc.SelectObject (CBitmap :: FromHandle (hbitmap));
dstdc.BitBlt (0, 0, g_DevPicSize.cx, g_DevPicSize.cy, & bkdc, point.x, point.y, SRCCOPY); dstdc.TransparentBlt (0, 0, g_DevPicSize.cx, g_DevPicSize.cy, & srcdc, index * g_DevPicSize .cx, 0, g_devpicsize.cx, g_devpicsize.cy, RGB (212, 208, 200);
HPEN OLDPEN, PEN; / / Bright blue pen = createpen (ps_solid, 2, rgb (140, 233, 255)); OldPen = (HPEN) (dstdc.moveto (0, 0); dstdc.lineto (g_devpicsize.cx, 0); dstdc.moveto (g_devpicsize.cx, 0); dstdc.lineto (g_devpicsize.cx, g_devpicsize.cy); dstdc.moveto (g_devpicsize.cx, g_devpicsize.cy); dstdc.lineto (0 , g_devpicsize.cy); dstdc.moveto (0, g_devpicsize.cy); dstdc.lineto (0, 0); dstdc.selectObject (Oldpen);
HBITMAP holdbitmap = pStatic-> SetBitmap (hbitmap); if (holdbitmap = NULL!) DeleteObject (holdbitmap); pStatic-> ShowWindow (SW_NORMAL); srcdc.SelectObject (pOldBitmap1); bkdc.SelectObject (pOldBk); ReleaseDC (pdc); DeleteObject (Pen);
The same function, but modified to GDI : boost :: scoped_ptr
Boost :: scoped_ptr
CRECT TMP_RECTSTATIC; PSTATIC-> getClientRect (& TMP_RectStatic); Bitmap Tmp_BmpStatic (Tmp_RectStatic.Width (), TMP_RectStatic.Height ()); graphics tmp_grastatic (& tmp_bmpstatic);
tmp_graStatic.DrawImage (tmp_pBmpBackground.get (), Rect (0, 0, tmp_rectStatic.Width (), tmp_rectStatic.Height ()), point.x, point.y, tmp_rectStatic.Width (), tmp_rectStatic.Height (), UnitPixel NULL, NULL, NULL);
ColorMap TMP_Colormap [1]; TMP_COLORMAP [0] .OLDCOLOR = Color (255, 212, 208, 200); TMP_COLORMAP [0] .newcolor = Color (0, 255, 255, 255);
ImageAttributes TMP_ImageAttributes; TMP_ImageAttributes.SetRemaptable (1, TMP_COLORMAP, ColoradjustTypeBitmap);
tmp_graStatic.DrawImage (tmp_pBmpSource.get (), Rect (1, 1, g_DevPicSize.cx, g_DevPicSize.cy), index * g_DevPicSize.cx, 0, g_DevPicSize.cx, g_DevPicSize.cy, UnitPixel, & tmp_imageAttributes, NULL, NULL);
Pen tmp_pen (Color (255, 140, 233, 255), 2); tmp_graStatic.DrawRectangle (& tmp_pen, 1, 1, g_DevPicSize.cx, g_DevPicSize.cy); HBITMAP hbitmap; tmp_bmpStatic.GetHBITMAP (Color (255,255,255,255), & hbitmap) PStatic-> setBitmap (hbitmap); pstatic-> showwindow (sw_normal);
BTW: I also saw a very useful grayscale ColorMatrix ColorMatrix Tmp_cmgray = {0.5F, 0.5F, 0.5F, 0.5F, 0, 0.5F, 0.5F, 0.5F, 0, 0.5F, 0.5F, 0.5F, 0, 0.5F, 0.5F, 0.5F, 0, 0, 0.5F, 0.5F, 0.5F, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1};