不用windows的api函数,实现对位图的拉伸处理
比如一幅位图的长高是100 * 100,现要变为40 * 40,这种算法如何实现?

解决方案 »

  1.   

    MSDN解释:StretchBlt
    The StretchBlt function copies a bitmap from a source rectangle into a destination rectangle, stretching or compressing the bitmap to fit the dimensions of the destination rectangle, if necessary. The system stretches or compresses the bitmap according to the stretching mode currently set in the destination device context. 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
    );
    Parameters
    hdcDest 
    [in] Handle to the destination device context. 
    nXOriginDest 
    [in] Specifies the x-coordinate, in logical units, of the upper-left corner of the destination rectangle. 
    nYOriginDest 
    [in] Specifies the y-coordinate, in logical units, of the upper-left corner of the destination rectangle. 
    nWidthDest 
    [in] Specifies the width, in logical units, of the destination rectangle. 
    nHeightDest 
    [in] Specifies the height, in logical units, of the destination rectangle. 
    hdcSrc 
    [in] Handle to the source device context. 
    nXOriginSrc 
    [in] Specifies the x-coordinate, in logical units, of the upper-left corner of the source rectangle. 
    nYOriginSrc 
    [in] Specifies the y-coordinate, in logical units, of the upper-left corner of the source rectangle. 
    nWidthSrc 
    [in] Specifies the width, in logical units, of the source rectangle. 
    nHeightSrc 
    [in] Specifies the height, in logical units, of the source rectangle. 
    dwRop 
    [in] Specifies the raster operation to be performed. Raster operation codes define how the system combines colors in output operations that involve a brush, a source bitmap, and a destination bitmap. 
    See BitBlt for a list of common raster operation codes. 
      

  2.   

    http://www.kk518.net/soft/dispbbs.asp?BoardID=14&replyID=222&id=222&skin=1
      

  3.   

    Mackz(在相互) 
    的回答是对的Featured(我握着爱情的门票静静排队……) 
    我想楼主的意思是对图片文件进行物理的转换,而不仅仅是缩小显示
      

  4.   

    我是用了显示的,只是想实现类似StretchBlt()的功能,但不能用StretchBlt(),必须自己写算法来完成StretchBlt的功能
      

  5.   

    看MSDN platform sdk GDI部分,有位图的缩放的
      

  6.   

    to teli_eurydice(哭泣的仙人掌。) :
    我已经说明了不能用StretchBlt的,要自己写算法实现位图的缩放
      

  7.   

    如果是固定的模式,可以采用抽点采样,如果不是,
    可以用StretchBlt,但这个函数是在显存里画的
    保存是有点问题了,尤其是大图片的时候。
    一般是采用插值的