📄 代码.txt
字号:
// Getting bitmap size
/*BITMAP bm;
GetObject(m_hBitmap, sizeof(BITMAP), &bm);
// Creating new bitmap and receive pointer to it's bits.
HBITMAP hTargetBitmap;
void *pBuffer;
int nCorrectedWidth = ((bm.bmWidth + 3) / 4 ) * 4;
// Initialize DIBINFO structure
DIBINFO dibInfo;
dibInfo.bmiHeader.biBitCount = 24;
dibInfo.bmiHeader.biClrImportant = 0;
dibInfo.bmiHeader.biClrUsed = 0;
dibInfo.bmiHeader.biCompression = 0;
dibInfo.bmiHeader.biHeight = bm.bmHeight;
dibInfo.bmiHeader.biPlanes = 1;
dibInfo.bmiHeader.biSize = 40;
dibInfo.bmiHeader.biSizeImage = nCorrectedWidth*bm.bmHeight*3;
dibInfo.bmiHeader.biWidth = nCorrectedWidth;
dibInfo.bmiHeader.biXPelsPerMeter = 3780;
dibInfo.bmiHeader.biYPelsPerMeter = 3780;
dibInfo.bmiColors[0].rgbBlue = 0;
dibInfo.bmiColors[0].rgbGreen = 0;
dibInfo.bmiColors[0].rgbRed = 0;
dibInfo.bmiColors[0].rgbReserved = 0;
// Create bitmap and receive pointer to points into pBuffer
HDC hDC = ::GetDC(NULL);
ASSERT(hDC);
hTargetBitmap = ::CreateDIBSection(
hDC,
(const BITMAPINFO*)dibInfo,
DIB_RGB_COLORS,
(void**)&pBuffer,
NULL,
0);
::ReleaseDC(NULL, hDC);
// Copy source bitmap into the target bitmap.
// Create 2 device contexts
HDC hMemDc = ::CreateCompatibleDC(NULL);
HDC hTargetDc = ::CreateCompatibleDC(NULL);
// Select source bitmap into one DC, target into another
HBITMAP hOldBitmap1 = (HBITMAP) ::SelectObject(hMemDc, m_hBitmap);
HBITMAP hOldBitmap2 = (HBITMAP) ::SelectObject(hTargetDc, hTargetBitmap);
// Copy source bitmap into the target one
::BitBlt(hTargetDc, 0, 0, bm.bmWidth, bm.bmHeight, hMemDc, 0, 0, SRCCOPY);
// Restore device contexts
::SelectObject(hMemDc, hOldBitmap1);
::SelectObject(hTargetDc, hOldBitmap2);
::DeleteDC(hMemDc);
::DeleteDC(hTargetDc);*/
BGRColor* pb=new BGRColor(0,0,0);
SIZE size;
HBITMAP hResultBitmap;
//pb=CSTGapiBuffer::GetDIBits(m_hBitmap);
/*BITMAP bm2;
GetObject(m_hb, sizeof(BITMAP), &bm2);
// Creating new bitmap and receive pointer to it's bits.
HBITMAP hTargetBitmap2;
void *pBuffer2;
int nCorrectedWidth2 = ((bm2.bmWidth + 3) / 4 ) * 4;
// Initialize DIBINFO structure
DIBINFO dibInfo2;
dibInfo2.bmiHeader.biBitCount = 24;
dibInfo2.bmiHeader.biClrImportant = 0;
dibInfo2.bmiHeader.biClrUsed = 0;
dibInfo2.bmiHeader.biCompression = 0;
dibInfo2.bmiHeader.biHeight = bm2.bmHeight;
dibInfo2.bmiHeader.biPlanes = 1;
dibInfo2.bmiHeader.biSize = 40;
dibInfo2.bmiHeader.biSizeImage = nCorrectedWidth2*bm2.bmHeight*3;
dibInfo2.bmiHeader.biWidth = nCorrectedWidth2;
dibInfo2.bmiHeader.biXPelsPerMeter = 3780;
dibInfo2.bmiHeader.biYPelsPerMeter = 3780;
dibInfo2.bmiColors[0].rgbBlue = 0;
dibInfo2.bmiColors[0].rgbGreen = 0;
dibInfo2.bmiColors[0].rgbRed = 0;
dibInfo2.bmiColors[0].rgbReserved = 0;
// Create bitmap and receive pointer to points into pBuffer
HDC hDC2 = ::GetDC(NULL);
ASSERT(hDC2);
hTargetBitmap2 = ::CreateDIBSection(
hDC2,
(const BITMAPINFO*)dibInfo2,
DIB_RGB_COLORS,
(void**)&pBuffer2,
NULL,
0);
::ReleaseDC(NULL, hDC2);
// Copy source bitmap into the target bitmap.
// Create 2 device contexts
HDC hMemDc2 = ::CreateCompatibleDC(NULL);
HDC hTargetDc2 = ::CreateCompatibleDC(NULL);
// Select source bitmap into one DC, target into another
HBITMAP hOldBitmap3 = (HBITMAP) ::SelectObject(hMemDc2, m_hb);
HBITMAP hOldBitmap4 = (HBITMAP) ::SelectObject(hTargetDc2, hTargetBitmap2);
// Copy source bitmap into the target one
::BitBlt(hTargetDc2, 0, 0, bm2.bmWidth, bm2.bmHeight, hMemDc2, 0, 0, SRCCOPY);
// Restore device contexts
::SelectObject(hMemDc2, hOldBitmap3);
::SelectObject(hTargetDc2, hOldBitmap4);
::DeleteDC(hMemDc2);
::DeleteDC(hTargetDc2);*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -