首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

抠图有关问题

2013-02-15 
抠图问题内存中已经读取了一个BMP图使用StretchDIBits()显示在界面上现在画了一个矩形框怎么能在内存中相

抠图问题
内存中已经读取了一个BMP图
使用StretchDIBits()显示在界面上
现在画了一个矩形框
怎么能在内存中相应的比例上截图并保存?
[解决办法]
pDC->StretchDIBits(....);

就截取pDC中相应的区域就可以了
[解决办法]
不用处理内存的,将你抠下来的那部分再贴到另一个DC中,保存就行了。
[解决办法]
 If the destination rectangle is larger than the source rectangle, this function stretches the rows and columns of color data to fit the destination rectangle. If the destination rectangle is smaller than the source rectangle, this function compresses the rows and columns by using the specified raster operation.

自动的!
[解决办法]
嗯,一般不考虑这些,兼容DC
[解决办法]
Stretch 后 要考虑“相应的比例”

[解决办法]
你要屏幕 反映 你的 图的大小。 不能用 Stretch。
要 BitBlt 。(DIB 要 转成 DDB 的 bmp)

这样 矩形的 大小 就是 内存中 对应的 大小。
[解决办法]
// 原始大小,不用拉伸。
bSuccess = ::SetDIBitsToDevice(hDC,                    // hDC
   lpDCRect->left,             // DestX
   lpDCRect->top,              // DestY
   RECTWIDTH(lpDCRect),        // nDestWidth
   RECTHEIGHT(lpDCRect),       // nDestHeight
   lpDIBRect->left,            // SrcX
   (int)DIBHeight(lpDIBHdr) -
  lpDIBRect->top -
  RECTHEIGHT(lpDIBRect),   // SrcY
   0,                          // nStartScan
   (WORD)DIBHeight(lpDIBHdr),  // nNumScans
   lpDIBBits,                  // lpBits
   (LPBITMAPINFO)lpDIBHdr,     // lpBitsInfo
   DIB_RGB_COLORS);            // wUsage

热点排行