MFC 如何用CImage 改变图片尺寸?

MFC 如何用CImage 改变图片尺寸?,第1张

CImage imSrc,imDest

imSrc.Load(……)//读入原始图片

imDest.Create(……)//创建新大小的图片

imSrc.StretchBlt(imDest.GetDC(),……)

imDest.ReleaseDC()

imDest就是你制定尺寸的图片对象

BOOL StretchBlt(

HDC hdcDest, // handle to destination DC

int nXOriginDest, // x-coord of destination upper-left corner

int nYOriginDest, // y-coord of destination upper-left corner

int nWidthDest, // width of destination rectangle

int nHeightDest, // height of destination rectangle

HDC hdcSrc, // handle to source DC

int nXOriginSrc, // x-coord of source upper-left corner

int nYOriginSrc, // y-coord of source upper-left corner

int nWidthSrc,// width of source rectangle

int nHeightSrc, // height of source rectangle

DWORD dwRop // raster operation code

)

你用这个函数就是可以了,自己先创建一个BITMAP然后将你要放大的图片选到BITMAP中,这样你就是可以 *** 作你的画布了,在将图片输出

CClientDC dc(this)

CDC memDC

memDC.CreateCompatibleDC(dc)

CBitmap bitmap

bitmap.LoadBitmap(IDB_BITMAP1)

BITMAP bitinfo

bitmap.GetBitmap(&bitinfo)

memDC.SelectObject(&bitmap)

dc.BitBlt(0,0,bitinfo.bmWidth,bitinfo.bmHeight,&memDC,0,0,SRCCOPY)

通BitBlt就可以把一张图在内存DC贴到单文档的界面.通改变改函数前四个参数就可以改变图片的大小,前二个参数用来指明左上角坐标,后二个参数指明右下坐标.


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/tougao/7808923.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-10
下一篇2023-04-10

发表评论

登录后才能评论

评论列表(0条)

    保存