我对图像编程不懂,想实现以下功能:   有1个BMP或JPG文件,我需要改变图片的尺寸(放大或缩小),要保证图片质量,可以拉伸。最后要把放大或缩小的图片保存   请问各位大虾,怎么做   分不是问题,可以增加

解决方案 »

  1.   

    Try
          MyBmp:=TBitmap.Create;
          MyBmp.PixelFormat:=pf24Bit;
          Mybmp.loadfromfile('c:\1.bmp');
          Image1.Canvas.StretchDraw(Rect(0,0,300,200),MyBmp);
       Finally
          MyBmp.Free;
       End;
    300,200自己随便定
      

  2.   

    要定义变量
    Var
      Mybmp:Tbitmap;
      

  3.   

    不知道为什么我只要改变了图片的大小,图片的分辨率由150象素/英寸了
    就变为72象素/英寸了
    不知道那错了
    我的代码:Try
          MyBmp:=TBitmap.Create;
          MyBmp.PixelFormat:=pf24Bit;
          Mybmp.loadfromfile('c:\1.bmp');
          Image1.Canvas.StretchDraw(Rect(0,0,300,200),MyBmp);
          Mybmp.width := 800;
          MyBmp.Height := 600;
         MyBmp.Savetofile('d:\2.bmp');
       Finally
          MyBmp.Free;
       End;
      

  4.   

    Image1.Canvas.StretchDraw(Rect(0,0,300,200),MyBmp
      错了,是
    Image1.Canvas.StretchDraw(Rect(0,0,800,600),MyBmp
      

  5.   

    Image中的图片才是你缩小后的图片你为什么要保存mybmp呢
      

  6.   

    用api函数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
    );
      

  7.   

    to cnssk(小柯) :
      image中的图片保存后分辨率还是72dpi
    真晕
      

  8.   

    其实分辨率(dpi)就是
      象素数/实际的英寸数,象素数可以得到,就是weight或height,
    可是实际的英寸数怎么得到呢
    photoshop中可以任意指定图片的宽度、高度(象素数),
    并且可以任意指定分辨率,不知道怎么实现的,只是保存后的文件大小会受到影响
      

  9.   

    我从网上下载了一些图形处理的组件,别说平滑缩放,就是Alpha等都能实现,需要的话可以Q我或Mail To Me.
      

  10.   

    楼上,发到我的邮箱吧: [email protected]
    先谢了
      

  11.   

    BT的用户,要让用厘米表示图片的宽度和高度,真TMD晕