如何将32 x 32像素图标转换为16 x 16像素值的图标
生活随笔
收集整理的這篇文章主要介紹了
如何将32 x 32像素图标转换为16 x 16像素值的图标
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
14.如何將32 x 32像素圖標(biāo)轉(zhuǎn)換為16 x 16像素值的圖標(biāo)
| HICON Convert32x32IconTo16x16(HICON h32x32Icon) {HDC hMainDC, hMemDC1, hMemDC2;HICON h16x16Icon;BITMAP bmp;HBITMAP hOldBmp1, hOldBmp2;ICONINFO IconInfo32x32, IconInfo16x16;GetIconInfo(h32x32Icon, &IconInfo32x32);hMainDC = ::GetDC(m_hWnd);hMemDC1 = CreateCompatibleDC(hMainDC);hMemDC2 = CreateCompatibleDC(hMainDC);GetObject(IconInfo32x32.hbmColor, sizeof(BITMAP), &bmp);IconInfo16x16.hbmColor = CreateBitmap( 16, 16, bmp.bmPlanes,bmp.bmBitsPixel,NULL);hOldBmp1 = (HBITMAP) SelectObject( hMemDC1, IconInfo32x32.hbmColor);hOldBmp2 = (HBITMAP) SelectObject( hMemDC2,IconInfo16x16.hbmColor);StretchBlt(hMemDC2,0, 0,16, 16,hMemDC1,0, 0,32, 32,SRCCOPY);GetObject(IconInfo32x32.hbmMask, sizeof(BITMAP), &bmp);IconInfo16x16.hbmMask = CreateBitmap( 16, 16, bmp.bmPlanes, bmp.bmBitsPixel,NULL);SelectObject(hMemDC1, IconInfo32x32.hbmMask);SelectObject(hMemDC2, IconInfo16x16.hbmMask);StretchBlt(hMemDC2,0, 0,16, 16,hMemDC1,0, 0,32, 32,SRCCOPY);SelectObject(hMemDC1, hOldBmp1);SelectObject(hMemDC2, hOldBmp2);IconInfo16x16.fIcon = TRUE;h16x16Icon = CreateIconIndirect(&IconInfo16x16);DeleteObject(IconInfo32x32.hbmColor);DeleteObject(IconInfo16x16.hbmColor);DeleteObject(IconInfo32x32.hbmMask);DeleteObject(IconInfo16x16.hbmMask);DeleteDC(hMemDC1);DeleteDC(hMemDC2);::ReleaseDC(m_hWnd, hMainDC);return h16x16Icon; } |
總結(jié)
以上是生活随笔為你收集整理的如何将32 x 32像素图标转换为16 x 16像素值的图标的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 树与搜索
- 下一篇: CVPR 2018 | TVNet:可端