急!在线等~~C++怎么把图象缩小或放大一倍?HDIB ChangeDIBSize(HDIB hDIB, int nWidth, int nHeight){ LPBITMAPINFO lpbmi = NULL; LPBYTE lpSourceBits, lpTargetBits, lpResult; HDC hDC = NULL, hSourceDC, hTargetDC; HBITMA

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/16 08:17:43
急!在线等~~C++怎么把图象缩小或放大一倍?HDIBChangeDIBSize(HDIBhDIB,intnWidth,intnHeight){LPBITMAPINFOlpbmi=NULL;LPBYT

急!在线等~~C++怎么把图象缩小或放大一倍?HDIB ChangeDIBSize(HDIB hDIB, int nWidth, int nHeight){ LPBITMAPINFO lpbmi = NULL; LPBYTE lpSourceBits, lpTargetBits, lpResult; HDC hDC = NULL, hSourceDC, hTargetDC; HBITMA
急!在线等~~C++怎么把图象缩小或放大一倍?
HDIB ChangeDIBSize(HDIB hDIB, int nWidth, int nHeight)
{ LPBITMAPINFO lpbmi = NULL;
LPBYTE lpSourceBits, lpTargetBits, lpResult;
HDC hDC = NULL, hSourceDC, hTargetDC;
HBITMAP hSourceBitmap, hTargetBitmap, hOldTargetBitmap, hOldSourceBitmap;
DWORD dwSourceBitsSize, dwTargetBitsSize, dwTargetHeaderSize;
HDIB hNewDIB;
DWORD dwSize;
WaitCursorBegin()
if (! hDIB)
{WaitCursorEnd();
return NULL;}
LPBITMAPINFO lpSrcDIB = (LPBITMAPINFO)GlobalLock(hDIB);
if (! lpSrcDIB)
{WaitCursorEnd();
return NULL;}
dwTargetHeaderSize = sizeof( BITMAPINFOHEADER ) + PaletteSize(lpSrcDIB);
lpbmi = (LPBITMAPINFO)malloc( dwTargetHeaderSize );
memcpy(lpbmi, lpSrcDIB, dwTargetHeaderSize);
lpbmi->bmiHeader.biWidth = nWidth;
lpbmi->bmiHeader.biHeight = nHeight;
hDC = GetDC( NULL );
hTargetBitmap = CreateDIBSection( hDC, lpbmi, DIB_RGB_COLORS, (VOID **)&lpTargetBits, NULL, 0 );
hSourceBitmap = CreateDIBSection( hDC, lpSrcDIB, DIB_RGB_COLORS, (VOID **)&lpSourceBits, NULL, 0 );
hSourceDC = CreateCompatibleDC( hDC );
hTargetDC = CreateCompatibleDC( hDC );
dwSourceBitsSize = lpSrcDIB->bmiHeader.biHeight * BytesPerLine((LPBYTE)&(lpSrcDIB->bmiHeader));
dwTargetBitsSize = lpbmi->bmiHeader.biHeight * BytesPerLine((LPBYTE)&(lpbmi->bmiHeader));
memcpy( lpSourceBits, FindDIBBits((LPBYTE)lpSrcDIB), dwSourceBitsSize );
lpbmi->bmiHeader.biSizeImage = dwTargetBitsSize;
hOldSourceBitmap = (HBITMAP)SelectObject( hSourceDC, hSourceBitmap );
hOldTargetBitmap = (HBITMAP)SelectObject( hTargetDC, hTargetBitmap );
SetStretchBltMode( hTargetDC, COLORONCOLOR );
StretchBlt( hTargetDC, 0, 0, lpbmi->bmiHeader.biWidth, lpbmi->bmiHeader.biHeight, hSourceDC, 0, 0, lpSrcDIB->bmiHeader.biWidth, lpSrcDIB->bmiHeader.biHeight, SRCCOPY );
SelectObject( hSourceDC, hOldSourceBitmap );
SelectObject( hTargetDC, hOldTargetBitmap );
DeleteDC( hSourceDC );
DeleteDC( hTargetDC );
ReleaseDC( NULL, hDC );
GdiFlush();
dwSize = dwTargetHeaderSize + dwTargetBitsSize;
hNewDIB = GlobalAlloc(GHND, dwSize);
lpResult = (LPBYTE)GlobalLock(hNewDIB);//malloc( dwTargetHeaderSize + dwTargetBitsSize );
memcpy( lpResult, lpbmi, dwTargetHeaderSize );
memcpy( FindDIBBits( (LPBYTE)lpResult ), lpTargetBits, dwTargetBitsSize );
DeleteObject( hTargetBitmap );
DeleteObject( hSourceBitmap );
free( lpbmi );
GlobalUnlock(hDIB);
GlobalUnlock(hNewDIB);
WaitCursorEnd();
return hNewDIB;}
以上是图象缩放函数的源代码,我现在需要直接把图象缩小到原来的一半和放大一倍.请问需要改动哪里,具体怎么改?用自己的代码也可以~谢谢啦

急!在线等~~C++怎么把图象缩小或放大一倍?HDIB ChangeDIBSize(HDIB hDIB, int nWidth, int nHeight){ LPBITMAPINFO lpbmi = NULL; LPBYTE lpSourceBits, lpTargetBits, lpResult; HDC hDC = NULL, hSourceDC, hTargetDC; HBITMA
HDIB是原始图像的句柄, nWidth和nHeight就是缩小或放大后的大小.直接调用就行.
WaitCursorBegin()
WaitCursorEnd();两句删掉;

急!在线等~~C++怎么把图象缩小或放大一倍?HDIB ChangeDIBSize(HDIB hDIB, int nWidth, int nHeight){ LPBITMAPINFO lpbmi = NULL; LPBYTE lpSourceBits, lpTargetBits, lpResult; HDC hDC = NULL, hSourceDC, hTargetDC; HBITMA 把图形放大或缩小,就是把图形的什么扩大或缩小? 把图形放缩,实际是把图形的( )放大或缩小A各边长 B面积 C周长 PS中怎么把ALT加鼠标滑轮放大缩小,改成滑轮直接放大缩小? 什么物品能把物体或图象缩小 常见的图形变换有放大或缩小,还有哪些?请帮我把这个问题打出来:常见的图形变换有放大或缩小,( ),( ),( )等. 投影仪 投放的画面尺寸怎么放大或缩小? 某同学需要找一块焦距在10cm到5cm之间的凸透镜现有A B C三块凸透镜A:倒立,缩小的实像B:倒立,放大的实像C:只能得到放大,正立的虚像或者三个都得急!在线等物距10CM...忘看了...清楚点,详 【急】两道高一函数选择题,在线等点击放大 word表格怎么把格子单独放大缩小 在研究凸透镜成像规律的实验中蜡烛在光屏上成一个清晰缩小的象,光屏离凸透镜的距a;只可能是缩小倒立的实像b;只可能是倒立放大的实像c;只可能是正立放大的象d;倒立放大.缩小.或等 result怎么造句 在线等!急 在线等初中的 怎么把数学或物理的图弄到百度上问题呀? 高手 谢谢我不知道,谢谢,有一题.我不会,很急.谢谢我在线等 求高人指点~~~ 自然人投资或控股 怎么翻译呀?在线等,急求~~~谢谢了 这道题怎么做?急!在线等!要图或添辅助线的过程! 在现实生活中 ,哪些是把物体放大或缩小的? 为什么瞳孔会放大或缩小啊 小孔成像是A.倒立的,B 放大的C 等大的 D缩小的