请问高手 做分层的IMAGE 如何做 如何动态捕捉用CANVAS画的线条 就是如何选中单个的 像PHOTOSHOP里的层的概念差不多

chinazjb 2003-05-26 02:37:54
请问高手 做分层的IMAGE 如何做 如何动态捕捉用CANVAS画的线条 就是如何选中单个的 像PHOTOSHOP里的层的概念差不多
...全文
46 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
zytangzhou 2003-07-30
  • 打赏
  • 举报
回复
我不知道你具体想怎么做!但如果只是划出的线段能用鼠标选中的话,这个问题我能帮你解决,很简单的!如果需要发邮件向我索取好了,zytangzhou2002@vip.sina.com
taxi 2003-07-30
  • 打赏
  • 举报
回复
我有一个简单的例子,发邮件给我索取吧。
ywbtaxi@etang.com
ambush 2003-07-29
  • 打赏
  • 举报
回复
textout写上的字符串如何擦除?
Iamfish 2003-07-13
  • 打赏
  • 举报
回复
G32

www.g32.org
ambush 2003-07-13
  • 打赏
  • 举报
回复
关注!
naturalym 2003-06-16
  • 打赏
  • 举报
回复
这里有一个自己写小程序,供大家参考,欢迎交流!!!

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,StdCtrls;

const
maxIndex=5; //直线个数

type
LineRec=record
x1,y1,x2,y2:Integer; //记录直线两端坐标
Color:TColor; //记录直线颜色
end;

type
TForm1 = class(TForm)
procedure DrawLine(Index:Integer); //划线
procedure EraseLine(Index:Integer); //擦线
procedure FormCreate(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
LineArray:array[0..maxIndex - 1] of LineRec; //直线数组
procedure createLabel(LI,Lx1,Lx2,Ly1,Ly2:Integer); //产生直线对应LABEL
public
{ Public declarations }
XOldSet,YOldSet:Integer; //移动前坐标
Dragging:Boolean; //是否拖动标志
LabelIndex:Integer; //当前选择的直线LABEL号
LineLabel:array[0..maxIndex - 1] of TLabel; //LABEL数组
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.DrawLine(Index:Integer);
begin
with Canvas,LineArray[Index] do
begin
Pen.Color:=Color;
MoveTo(x1,y1);
LineTo(x2,y2);
end;
end;

procedure TForm1.EraseLine(Index:Integer);
begin
with Canvas,LineArray[Index] do
begin
Pen.Color:=GetBKColor(Handle);
MoveTo(x1,y1);
LineTo(x2,y2);
end;
end;

procedure TForm1.CreateLabel(LI,Lx1,Lx2,Ly1,Ly2:Integer);
begin
LineLabel[LI]:=TLabel.Create(Form1);
LineLabel[LI].Name:='Label'+IntToStr(LI);
LineLabel[LI].Left:=Lx2;
LineLabel[LI].Top:=Ly2;
LineLabel[LI].Color:=clGreen;
LineLabel[LI].Caption:='X1:'+IntToStr(Lx1)+',Y1:'+IntToStr(Ly1)+',X2:'
+IntToStr(Lx2)+',Y2:'+IntToStr(Ly2);
Form1.InsertControl(LineLabel[LI]);
LineLabel[LI].OnMouseDown:=Form1.OnMouseDown;
LineLabel[LI].OnMouseMove:=Form1.OnMouseMove;
LineLabel[LI].OnMouseUp:=Form1.OnMouseUp;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
I:Integer;
begin
Dragging:=False;
for i:=0 to maxIndex - 1 do
begin
with LineArray[I] do
begin
x1:=Random(120+I*30);
x2:=Random(152+I*30);
y1:=Random(240+I*30);
y2:=Random(382+I*30);
Color:=RGB(Random(256),Random(256),Random(256));
end;
end;
end;

procedure TForm1.FormActivate(Sender: TObject);
var
I:Integer;
begin
for I:=0 to maxIndex - 1 do
begin
with LineArray[I] do
CreateLabel(I,x1,x2,y1,y2);
DrawLine(I);
end;
end;

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
I:Integer;
begin
for I:=0 to maxIndex - 1 do
if Sender=LineLabel[I] then
begin
XOldSet:=X;
YOldSet:=Y;
LabelIndex:=I;
break;
end;
Dragging:=True;
end;

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if Dragging then
begin
with LineArray[LabelIndex],LineLabel[LabelIndex] do
begin
Left:=x2+(X - XOldSet);
TOP:=Y2+(Y - YOldSet);
EraseLine(LabelIndex);
x1:=x1+(X - XOldSet);
x2:=x2+(X - XOldSet);
y1:=y1+(Y - YOldSet);
y2:=y2+(Y - YOldSet);
DrawLine(LabelIndex);
LineLabel[LabelIndex].Caption:='X1:'+IntToStr(x1)+',Y1:'+IntToStr(y1)+',X2:'
+IntToStr(x2)+',Y2:'+IntToStr(y2);
end;
end;
end;

procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Dragging:=False;
with LineArray[LabelIndex] do
begin
x1:=x1+(X - XOldSet);
x2:=x2+(X - XOldSet);
y1:=y1+(Y - YOldSet);
y2:=y2+(Y - YOldSet);
end;
end;

end.

〔naturalym〕
ninglng 2003-06-12
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/topic/1904/1904043.xml?temp=.7446405

迷茫请指教
Iamfish 2003-06-08
  • 打赏
  • 举报
回复
关注.最近也在写一点点关于这方面的
Maq 2003-06-07
  • 打赏
  • 举报
回复
基本同意yewangqing的说法,
不过:记录各个图形的位置目的何在?是为了点击只用吗?那是否还要判断用户点击时的鼠标位置?

是否可以将canvas画的每个图元当作一个对象,点击这个图元就可以得到其句柄。
fhb 2003-06-07
  • 打赏
  • 举报
回复
TCAD!
yewangqing 2003-05-26
  • 打赏
  • 举报
回复
呵呵,要说全了可比较麻烦。

简单的就是 :自己定义数据结构来记录用户自己的层,记录各个图形的位置、所在的图层等信息。在操作时,根据记录的信息判断当前层、当前选中的图片....

如果需要,愿意交流!
chinazjb 2003-05-26
  • 打赏
  • 举报
回复
请高手过来

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi GAME,图形处理/多媒体
社区管理员
  • GAME,图形处理/多媒体社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧