用OnMousedown
canvas.moveto(x,y);
用OnMouseup
canvas.lineto(x,y);
肯定能画出来,我就是这样做的,怎么样?给分吗?

解决方案 »

  1.   

    放大(缩小):
    …………
    procedure ChangeBmp;
    var 
      mybmp:Tbitmap;
      myrect:Trect;
    begin 
      mybmp:=TBitmap.create;
      mybmp.loadfromfile('.\1.bmp'); //比如你装载了一幅图1.bmp,你的image1中是那幅图
      image1.canvas.StretchDraw(myrect,mybmp);
    ……
    end
    ……
      

  2.   

    tombyron(京) 
    移动、旋转呢???
      

  3.   

    在http://www.truevcl.com 有TCAD控件
      

  4.   

    To fhb:
       www.truevcl.com?? 我去看了看,要用钱买,还没有源代码提供~~~
      

  5.   

    这是一个关于图形的放大、缩小、和移动的简单程序例子,本例子的图形格式为BMP格式unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      Menus, extctrls, StdCtrls;type
      TForm1 = class(TForm)
        OpenDialog: TOpenDialog;
        procedure ZoomIn;
        procedure ZoomOut;
        procedure N2Click(Sender: TObject);
        procedure FormCreate(Sender: TObject);
        procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
          Y: Integer);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;
      Mybmp:TBitmap;
      MyRect:TRect;
      HasDown:boolean;        //用来判断是否已经按下键
      down_x,down_y,h,w,MyBmpWidth,MyBmpHeight:integer; 
      //down_x,down_y用来记录按键时的x,y坐标  
      //h,w用来记录图形的原始大小(高和宽)  
      //MybmpHeight,MybmpWidth用来记录随时改变的图形的高和宽implementation{$R *.DFM}//在本程序中我放置了一个OpenDialog 控件procedure TForm1.N2Click(Sender: TObject);    //打开并绘出一幅图形
    begin
      opendialog.Execute;
      if opendialog.FileName<>''
       then begin
              mybmp.loadfromfile(opendialog.filename);
              myrect.TopLeft.x:=100;
              myrect.TopLeft.y:=100;
              myrect.BottomRight.x:=100+Mybmp.width;
              myrect.BottomRight.y:=100+Mybmp.height;          w:=Mybmp.width;
              h:=Mybmp.height;
              MybmpWidth:=w;
              MyBmpHeight:=h;
              form1.Canvas.Draw(myrect.TopLeft.x,myrect.TopLeft.x,mybmp);
            end;
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      HasDown:=false;
      mybmp:=TBitmap.create;
    end;procedure TForm1.ZoomIn;  //放大
    begin
      myrect.BottomRight.x:=myrect.BottomRight.x+w*2 div 10;
      myrect.BottomRight.y:=myrect.BottomRight.y+h*2 div 10;
      MyBmpWidth:=myrect.BottomRight.x-myrect.TopLeft.x;
      MyBmpHeight:=myrect.BottomRight.y-myrect.TopLeft.y;
      form1.Canvas.StretchDraw(myrect,Mybmp);   //放大1/5
    end;procedure TForm1.ZoomOut;  //缩小
    begin
      form1.canvas.Rectangle(myrect.TopLeft.x,myrect.TopLeft.y,myrect.BottomRight.x+1,myrect.BottomRight.y+1);
      myrect.BottomRight.x:=myrect.BottomRight.x-w*2 div 10;
      myrect.BottomRight.y:=myrect.BottomRight.y-h*2 div 10;
      form1.Canvas.StretchDraw(myrect,Mybmp);   //缩小1/5
      MyBmpWidth:=myrect.BottomRight.x-myrect.TopLeft.x;
      MyBmpHeight:=myrect.BottomRight.y-myrect.TopLeft.y;
    end;
    procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
      if (not hasdown)and(button=mbLeft)and((x>=myrect.TopLeft.x)and(x<=myrect.BottomRight.x))
         and((y>=myrect.TopLeft.y)and(y<=myrect.BottomRight.y))
      then begin
             HasDown:=true;
             down_x:=x-myrect.TopLeft.x;
             down_y:=y-myrect.TopLeft.y;
           end;
    end;procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
      HasDown:=false;
    end;procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    begin
      if (HasDown)and((x>=myrect.TopLeft.x)and(x<=myrect.BottomRight.x))
         and((y>=myrect.TopLeft.y)and(y<=myrect.BottomRight.y))
       then begin
             form1.Canvas.Pen.style:=psclear;
             form1.Canvas.Brush.Color:=form1.Color;
             form1.canvas.Rectangle(myrect.TopLeft.x,myrect.TopLeft.y,myrect.BottomRight.x+1,myrect.BottomRight.y+1);         myrect.TopLeft.x:=x-down_x;
             myrect.TopLeft.y:=y-down_y;
             myrect.BottomRight.x:=myrect.TopLeft.x+mybmpWidth;
             myrect.BottomRight.y:=myrect.TopLeft.y+mybmpHeight;         form1.Canvas.StretchDraw(Myrect,Mybmp);
            end;
    end;end.
      

  6.   

    楼上的Lin:
        我只是给他提供了一个简单的程序例子,怎么叫废话?
      

  7.   

    To lin:
       你说的不叫废话吗?你这叫思路?你这样的思路谁不知道?
      

  8.   

    To Dingh:
       你怎么没有反应?是没有看?还是其他的原因………………?