对于一幅位图,其大小是固定的,请问如何自动放大或缩小它,以使其填满一个窗口呀?
解决方案 »
- 树状列表展开出错
- CStatic控件中文字颜色如何设置
- 在CTreeCtrl上建节点?
- 还是关于winsock.h和winsock2.h的问题,但是新情况
- 拜师了 学vc++
- 帮帮我,这是我的全部分数,关于CDatabase中的rollback()函数
- 关于在picturebox中坐标和画线的问题!
- 如何利用CSocket的Send,Receive在server 与client间传输文件,大概4KB以下的文件(帮忙)
- 如果CDiolog中TextBox输入的参数没有改变,就不执行操作,该怎么办?
- VS2010中调整工具栏图标导致菜单栏的高度变更的问题
- 请教各位:网上哪里有vcguru的东东可以下载
- API函数不能连续多次调用问题
The StretchDIBits function copies the color data for a rectangle of pixels in a device-independent bitmap (DIB) to the specified destination rectangle. 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. int StretchDIBits(
HDC hdc, // handle to device context
int XDest, // x-coordinate of upper-left corner of dest. rectangle
int YDest, // y-coordinate of upper-left corner of dest. rectangle
int nDestWidth, // width of destination rectangle
int nDestHeight, // height of destination rectangle
int XSrc, // x-coordinate of upper-left corner of source rectangle
int YSrc, // y-coordinate of upper-left corner of source rectangle
int nSrcWidth, // width of source rectangle
int nSrcHeight, // height of source rectangle
CONST VOID *lpBits, // address of bitmap bits
CONST BITMAPINFO *lpBitsInfo, // address of bitmap data
UINT iUsage, // usage flags
DWORD dwRop // raster operation code
);
通过改变nSrcWidth,nSrcHeight
来改变图象大小
double fX,fY;
fX = (double)pDC->GetDeviceCaps(HORZRES)*(double)hmWidth/((double)pDC->GetDeviceCaps(HORZSIZE)*100.0);
fY = (double)pDC->GetDeviceCaps(VERTRES)*(double)hmHeight/((double)pDC->GetDeviceCaps(VERTSIZE)*100.0);
把100的大小调整好就可以得要显示的大小了
共同学习!