如何将图片放大或缩小?
图片已放在image中,如果不通过image控件的放大与缩小,如何实现?

解决方案 »

  1.   

    StretchBlt 函数 (WinApi)或使用Canvas的CopyRect方法..要是需要具体的代码就传呼俺..
      

  2.   

    通过image控件的放大与缩小,然后抓屏,哈哈。
      

  3.   

    var
      DestRect:TRect;
      SourceRect:Trect;
    begin
      With DestRect do
      begin
        Top:=0;
        Left:=0;
        Right:=Image2.Width;
        Bottom:=Image2.Height;
      end;
      With SourceRect do
      begin
        Top:=0;
        Left:=0;
        Right:=Image1.Width;
        Bottom:=Image1.Height;
      end;
      image2.Canvas.CopyRect(DestRect,Image1.Canvas,SourceRect);//CopyRect
      StretchBlt(Image2.Canvas.Handle,0,0, Image2.Width,Image2.Height,
        Image1.Canvas.Handle,0,0,
        Image1.Width, Image1.Height,SrcCopy);//StretchBlt
      

  4.   

    StretchBlt 函数 (WinApi)
    它的功能是什么?
      

  5.   

    http://expert.csdn.net/Expert/topic/2902/2902512.xml?temp=.7517816
      

  6.   

    Sorry!
    上面的写错了
    http://expert.csdn.net/Expert/topic/2841/2841286.xml?temp=.5164453
      

  7.   

    我现在很希望这个,能给我发一份程序吗?[email protected]
      

  8.   

    大哥,我要这个代码,麻烦发给我:[email protected]
      

  9.   

    me too  [email protected]
      

  10.   

    用那个API改变大小后会有比较严重的色彩失真,用下面的改,是我从BCB的代码改的var
      jpg :TJpegImage;
      bmp1,bmp2 :TBitmap;
      x1,y1,x2,y2,x0,y0,dx,dy,x,y:integer;
    begin
      jpg :=TJpegImage.Create;
      jpg.LoadFromFile('未命名.jpg');
      bmp1 :=TBitmap.Create;
      bmp2 :=TBitmap.Create;
      bmp1.Assign(jpg);  //改变后的的 Size
      bmp2.Width:=112;
      bmp2.Height:=98;  x1:=bmp1.Width;
      y1:=bmp1.Height;
      x2:=bmp2.Width;
      y2:=bmp2.Height;
      dx:=0;
      x0:=0;
      for x:=0 to bmp2.Width-1  do
      begin
         dy:=0;
         y0:=0;
         dx:=dx+x1;        while (dx>=x2) do
            begin
              x0:=x0+1;
              dx:=dx-x2;
            end;        for y:=0 to bmp2.Height-1  do
            begin              dy:=dy+y1;
                  while (dy>=y2) do
                  begin
                         y0:=y0+1;
                         dy:=dy-y2;
                  end;
                  bmp2.Canvas.Pixels[x,y]:=bmp1.Canvas.Pixels[x0,y0];
            end;
      end;  jpg.Assign(bmp2);
      jpg.SaveToFile('未命名1.jpg');
      jpg.Free;
      bmp1.Free;
      bmp2.Free;end;