对于一幅位图,其大小是固定的,请问如何自动放大或缩小它,以使其填满一个窗口呀?

解决方案 »

  1.   

    StretchDIBits
    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
    来改变图象大小
      

  2.   

    图的宽和高分别是hmWidth,hmHeight。
    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的大小调整好就可以得要显示的大小了
      

  3.   

    用CDC::StretchBlt() 啊,会自动给你解决缩放间的插值问题!
      

  4.   

    知道了〉 CDC::StretchBlt 
    共同学习!