海信家电”换帅 “ 高玉玲接替代慧忠出任新任董事长
2024-11-22
…… pDC->PatBlt(0,0,rect.Width(),rect.Height(), BLACKNESS); return TRUE; |
…… HBITMAP hbitmap; hbitmap=(HBITMAP)LoadImage(AfxGetInstanceHandle(), m_sPath1, IMAGE_BITMAP,0,0, LR_LOADFROMFILE|LR_CREATEDIBSECTION); |
hMemDC1=::CreateCompatibleDC(NULL); SelectObject(hMemDC1,hbitmap); ::DeleteObject(hbitmap); //释放掉用过的位图句柄 Invalidate(); |
…… ::BitBlt(pDC->m_hDC,m_nX1,m_nY1, m_nWidth1,m_nHeight1, hMemDC1,0,0,m_dwRop); …… |
…… if(m_bCanMove1==true) //在移动之前鼠标左键是在图片上点击的 { int dx=m_nOldX1-m_nX1; //计算鼠标距离图片原点的距离 int dy=m_nOldY1-m_nY1; m_nX1=point.x-dx; //计算新的图片原点的坐标(客户区坐标) m_nY1=point.y-dy; Invalidate(); //更新视图 } m_nOldX1=point.x; //保存上一次的鼠标位置 m_nOldY1=point.y; …… |
…… int temp1,temp2,x0,y0,x1,y1; temp1=m_nX1<m_nX2?m_nX1:m_nX2; if(m_sPath3!="")//如果有3幅图片参与拼合 { if(m_sPath4!="")//如果有4幅图片参与拼合 temp2=m_nX3<m_nX4?m_nX3:m_nX4; else temp2=m_nX3; x0=temp1<temp2?temp1:temp2; } else x0=temp1; …… temp1=m_nX1+m_nWidth1>m_nX2+m_nWidth2?m_nX1+m_nWidth1:m_nX2+m_nWidth2; if(m_sPath3!="") { if(m_sPath4!="") temp2=m_nX3+m_nWidth3>m_nX4+m_nWidth4?m_nX3+m_nWidth3:m_nX4+m_nWidth4; else temp2=m_nX3+m_nWidth3; x1=temp1>temp2?temp1:temp2; } else x1=temp1; |
HBITMAP CImageView::CopyScreenToBitmap(LPRECT lpRect) { …… // 确保选定区域不为空矩形 if(IsRectEmpty(lpRect)) return NULL; //为屏幕创建设备描述表 hScrDC = CreateDC("DISPLAY", NULL, NULL, NULL); //为屏幕设备描述表创建兼容的内存设备描述表 hMemDC = CreateCompatibleDC(hScrDC); …… // 创建一个与屏幕设备描述表兼容的位图 hBitmap = CreateCompatibleBitmap(hScrDC, lpRect->Width(),lpRect->Height()); // 把新位图选到内存设备描述表中 hOldBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap); // 把屏幕设备描述表拷贝到内存设备描述表中 BitBlt(hMemDC, 0, 0, lpRect->Width(),lpRect->Height, hScrDC, lpRect->left lpRect->top, SRCCOPY); //得到屏幕位图的句柄 hBitmap =(HBITMAP)SelectObject(hMemDC, hOldBitmap); //清除 DeleteDC(hScrDC); DeleteDC(hMemDC); …… // 返回位图句柄 return hBitmap; } |
…… hDC = CreateDC("DISPLAY",NULL,NULL,NULL); iBits = GetDeviceCaps(hDC, BITSPIXEL) * GetDeviceCaps(hDC, PLANES); DeleteDC(hDC); if (iBits <= 1) wBitCount = 1; else if (iBits<= 4) wBitCount = 4; else if (iBits<= 8) wBitCount = 8; else if (iBits <= 24) wBitCount = 24; //计算调色板大小 …… |
…… if (wBitCount <= 8) dwPaletteSize = (1<<wBitCount) *sizeof(RGBQUAD); //设置位图信息头结构 GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&Bitmap); bi.biSize = sizeof(BITMAPINFOHEADER); bi.biWidth = Bitmap.bmWidth; bi.biHeight = Bitmap.bmHeight; bi.biPlanes = 1; bi.biBitCount = wBitCount; bi.biCompression = BI_RGB; bi.biSizeImage = 0; bi.biXPelsPerMeter = 0; bi.biYPelsPerMeter = 0; bi.biClrUsed = 0; bi.biClrImportant = 0; |
…… dwBmBitsSize = ((Bitmap.bmWidth*wBitCount+31)/32)*4*Bitmap.bmHeight; hDib = GlobalAlloc(GHND,dwBmBitsSize+dwPaletteSize+sizeof(BITMAPINFOHEADER)); lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDib); *lpbi = bi; // 处理调色板 hPal = GetStockObject(DEFAULT_PALETTE); if (hPal) { hDC = ::GetDC(NULL); hOldPal =SelectPalette(hDC, (HPALETTE)hPal, FALSE); RealizePalette(hDC); } // 获取该调色板下新的像素值 GetDIBits(hDC, hBitmap, 0, (UINT) Bitmap.bmHeight, (LPSTR)lpbi + sizeof(BITMAPINFOHEADER)+dwPaletteSize, (BITMAPINFO*)lpbi, DIB_RGB_COLORS); //恢复调色板 if (hOldPal) { SelectPalette(hDC,(HPALETTE)hOldPal, TRUE); RealizePalette(hDC); ::ReleaseDC(NULL,hDC); } …… |
…… fh = CreateFile(lpFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,NULL); // 设置位图文件头 bmfHdr.bfType = 0x4D42; // "BM" dwDIBSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + dwPaletteSize + dwBmBitsSize; bmfHdr.bfSize = dwDIBSize; bmfHdr.bfReserved1 = 0; bmfHdr.bfReserved2 = 0; bmfHdr.bfOffBits = (DWORD)sizeof(BITMAPFILEHEADER) + (DWORD)sizeof(BITMAPINFOHEADER)+ dwPaletteSize; //写入位图文件头 WriteFile(fh, (LPSTR)&bmfHdr, sizeof(BITMAPFILEHEADER), &dwWritten, NULL); // 写入位图文件其余内容 WriteFile(fh, (LPSTR)lpbi, dwDIBSize,&dwWritten, NULL); …… |
图一 图二 |
|
图三 图四 |
|
评论 {{userinfo.comments}}
{{child.content}}
{{question.question}}
提交