我的图片是显示在VIEW里的,想对它进行放大或缩小处理。调用StretchBlt这个函数,如何来实现,能否帮我写一段简单的代码。我的比例参数是放在菜单里的,比如放大里有三个菜单项,分别是放大1倍,2倍,4倍。缩小也是,请问如何实现?

解决方案 »

  1.   

    http://www.pcdog.com/p/html/2004915/15920044025_1.htm
      

  2.   

    BOOL StretchBlt( int x, int y, int nWidth, int nHeight, CDC* pSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, DWORD dwRop );
    在nWidth和nHeight处乘上缩放比例,它们确定了目标区矩形的宽度和高度,所以可以通过它们实现缩放。
    其中所有参数意义如下:
    x              Specifies the x-coordinate (in logical units) of the upper-left corner ofthedestination rectangle.
    y              Specifies the y-coordinate (in logical units) of the upper-left corner of the destination rectangle.
    nWidth         Specifies the width (in logical units) of the destination rectangle.
    nHeight        Specifies the height (in logical units) of the destination rectangle.
    pSrcDC         Specifies the source device context.
    xSrc           Specifies the x-coordinate (in logical units) of the upper-left corner of the source rectangle.
    ySrc            Specifies the x-coordinate (in logical units) of the upper-left corner of the source rectangle.
    nSrcWidth       Specifies the width (in logical units) of the source rectangle.
    nSrcHeight      Specifies the height (in logical units) of the source rectangle.
    dwRop           Specifies the raster operation to be performed. Raster operation codes define how GDI combines colors in output operations that involve a current brush, a possible source bitmap, and a destination bitmap. This parameter may be one of the following values: