我想实在如下功能:
打开一个JPG图片,点击裁图按钮的时候,会在图片上显示一个 宽:200 高:300 的虚拟线框,可以随意移动位置,双击后把虚拟线框选中的图片取出重新生成一个JPG文件。
我没有做过图,所以请高手们写得详细些,附原码者定有高分相赠,THS!!!
打开一个JPG图片,点击裁图按钮的时候,会在图片上显示一个 宽:200 高:300 的虚拟线框,可以随意移动位置,双击后把虚拟线框选中的图片取出重新生成一个JPG文件。
我没有做过图,所以请高手们写得详细些,附原码者定有高分相赠,THS!!!
解决方案 »
- ???请问我下面的代码有问题吗?怎么有时重新将sql语句考入后能查有时又不能查???
- 100分求解,如下格式!!!
- 怎样使opendialog控件打开的不是选择文件对话框,而是选择目录对话框?急
- 100分求李维的delphi5.x分布式系统开发的源代码,电子书我已经有
- 象SQL SERVER 查询分析器中的 隐藏/显示对象那样的按钮是怎么做的!
- 关于资源文件的问题和字体颜色的问题。
- 哪位高手能帮忙写段代码,高分相送,急!!在线等待。
- webservice简单问题
- 热点题目:你们给国有事业单位开发一套办公用软件都是多少开发费?比如一套工商局个体经营管理软件,可以输入个体信息,备查,并打印几个表格这样的软件?开发一套给大概20或50个同级单位一起使用,收多少开发费合适?价格上怎么跟客户谈?
- 在只有一表单form1的工程文件中,加入另一个已存在的表单form2,编译后运行时,总是先显示一下form2再显示form1,不知是什么原因。
- 求生成Excel表中纯数字型字符的显示的方法
- indy10 发送buffer数据出问题了
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TForm1 = class(TForm)
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 }
FDraging:Boolean;
SPoint:TPoint;
EPoint:TPoint;
FillRect: TRect;
public
{ Public declarations } end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
FDraging := True;
SPoint.X := X;
SPoint.Y := Y;
end;procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
FDraging := False;end;procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if FDraging = False then Exit;
EPoint.X := X;
EPoint.Y := Y;
Canvas.Pen.Style := psDot;
Canvas.Pen.Color := clRed;
FillRect.Left := SPoint.X;
FillRect.Top := SPoint.Y;
FillRect.Right := EPoint.X;
FillRect.Bottom := EPoint.Y;
Canvas.Rectangle(FillRect);
end;end.
截图部分可以参考上面的网址内容
这是用鼠标拉框的方法
楼主要求的是框固定,可移动的,是吧?
可以考虑把选择框弄成一个固定模块,记录该框的左上角坐标
框的移动重绘可参考楼上的代码,移动大小就是fillrect的长跟宽
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;type
TForm1 = class(TForm)
Image1: TImage;
btnCut: TButton; procedure btnCutClick(Sender: TObject);
private
IsMouseDown: BOolean;
oldMPos, oldSPos: TPoint;
FShape: TShape ;
procedure Shape1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Shape1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Shape1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Shape1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
IsMouseDown := true;
GetCursorPos(oldmpos);
oldSPos.X := FShape.Left ;
oldSPos.Y := FShape.top ;
end;procedure TForm1.Shape1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
newMPos: TPoint ;
begin
if IsMouseDown then
begin
GetCursorPos(newMPos);
FShape.Left := newMPos.X - oldMPos.X + oldSPos.X ;
FShape.Top := newMPos.Y - oldMPos.Y + oldSPos.Y ;
end;
end;procedure TForm1.Shape1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
IsMouseDown := False;
end;procedure TForm1.btnCutClick(Sender: TObject);
begin
if FShape = nil then
begin
FShape := TShape.Create(Self);
FShape.Width := 200;
FShape.Height := 300;
FShape.Brush.Style := bsClear ;
FShape.Pen.Style := psDot;
FShape.Pen.Color := clLime;
FShape.OnMouseDown := Shape1MouseDown;
FShape.OnMouseMove := Shape1MouseMove;
FShape.OnMouseUp := Shape1MouseUp;
FShape.Left := Image1.Left ;
FShape.Top := Image1.Top ;
FShape.Parent := Form1;
FShape.Show ;
end;
end;end.
请注意正确设置Image1和MaskBox事件。unit main;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, jpeg;type
TForm1 = class(TForm)
Image1: TImage;
MaskBox: TPaintBox;
procedure FormCreate(Sender: TObject);
procedure MaskBoxMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure MaskBoxMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure MaskBoxMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure MaskBoxDblClick(Sender: TObject);
procedure MaskBoxPaint(Sender: TObject);
private
{ Private declarations }
FIsDown: Boolean;
FDrawIng: Boolean;
FSelected: Boolean;
FOrignPoint: TPoint;
FNextPoint: TPoint;
FCutRect: TRect;
procedure DrawCutRect(ReDraw: Boolean = False);
procedure SetSelected(const Value: Boolean);
public
{ Public declarations }
property Selected: Boolean read FSelected write SetSelected;
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.SetSelected(const Value: Boolean);
var
tmp: Integer;
begin
if FSelected <> Value then
begin
if FDrawing then DrawCutRect;
FSelected := Value;
if not Value then Exit;
if FOrignPoint.X > FNextPoint.X then
begin
tmp := FOrignPoint.X;
FOrignPoint.X := FNextPoint.X;
FNextPoint.X := tmp;
end;
if FOrignPoint.Y > FNextPoint.Y then
begin
tmp := FOrignPoint.Y;
FOrignPoint.Y := FNextPoint.Y;
FNextPoint.Y := tmp;
end;
FCutRect.TopLeft := FOrignPoint;
FCutRect.BottomRight := FNextPoint;
DrawCutRect;
end;
end;procedure TForm1.DrawCutRect(ReDraw: Boolean);
begin
MaskBox.Canvas.Pen.Mode := pmNotXor;
MaskBox.Canvas.Brush.Style := bsClear;
if Selected then
begin
MaskBox.Canvas.Pen.Style := psSolid;
MaskBox.Canvas.Pen.Color := clRed;
MaskBox.Canvas.Pen.Width := 2;
MaskBox.Canvas.Rectangle(FCutRect)
end
else
begin
MaskBox.Canvas.Pen.Style := psDot;
MaskBox.Canvas.Pen.Color := clBlack;
MaskBox.Canvas.Pen.Width := 1;
MaskBox.Canvas.Rectangle(FOrignPoint.X, FOrignPoint.Y, FNextPoint.X, FNextPoint.Y);
end;
if not ReDraw then
FDrawIng := not FDrawIng;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
MaskBox.SetBounds(Image1.Left, Image1.Top, Image1.Width, Image1.Height);
end;procedure TForm1.MaskBoxMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if (ssRight in Shift) and Selected then // 右键取消选择
Selected := False;
if not (ssLeft in Shift) then Exit;
FOrignPoint.X := X;
FOrignPoint.Y := Y;
FIsDown := not Selected or PtinRect(FCutRect, FOrignPoint);
end;procedure TForm1.MaskBoxMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if not FIsDown then Exit;
if FDrawing then
DrawCutRect;
if not Selected then
begin
if X < 0 then
X := 0
else if X > MaskBox.Width then
X := MaskBox.Width;
if Y < 0 then
Y := 0
else if Y > MaskBox.Height then
Y := MaskBox.Height;
FNextPoint.X := X;
FNextPoint.Y := Y;
end
else
begin
OffsetRect(FCutRect, X - FOrignPoint.X, Y - FOrignPoint.Y);
FOrignPoint.X := X;
FOrignPoint.Y := Y;
X := 0;
Y := 0;
if FCutRect.Left < 0 then
X := -FCutRect.Left
else if FCutRect.Right > MaskBox.Width then
X := MaskBox.Width - FCutRect.Right;
if FCutRect.Top < 0 then
Y := -FCutRect.Top
else if FCutRect.Bottom > MaskBox.Height then
Y := MaskBox.Height - FCutRect.Bottom;
if (X <> 0) or (Y <> 0) then
OffsetRect(FCutRect, X, Y);
end;
DrawCutRect;
end;procedure TForm1.MaskBoxMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if not FIsDown then Exit;
FNextPoint.X := X;
FNextPoint.Y := Y;
FIsDown := False;
if not Selected then
Selected := True;
end;procedure TForm1.MaskBoxDblClick(Sender: TObject);
var
bmp, tmp: TBitmap;
jpg: TJPEGImage;
dstRect, srcRect: TRect;
ScaleX, ScaleY: Single;
begin
if Selected and PtinRect(FCutRect, FNextPoint) then
begin
bmp := TBitmap.Create;
bmp.Assign(Image1.Picture.Graphic);
// 如果Image显示的与实际Bitmap不一致,请使用下面代码,同时删除srcRect := FCutRect;
{
// 因为Image显示的与实际Bitmap不见得一致,所以必须对选择矩形进行缩放
ScaleX := tmp.Width / Image1.Width;
ScaleY := tmp.Height / Image1.Height;
srcRect := Rect(Trunc(ScaleX * FCutRect.Left),
Trunc(ScaleY * FCutRect.Top),
Round(ScaleX * FCutRect.Right),
Round(ScaleY * FCutRect.Bottom));
}
srcRect := FCutRect;
dstRect := srcRect;
OffsetRect(dstRect, -dstRect.Left, -dstRect.Top);
tmp := TBitmap.Create;
tmp.PixelFormat := pf24Bit;
tmp.Width := dstRect.Right;
tmp.Height := dstRect.Bottom;
tmp.Canvas.CopyRect(dstRect, bmp.Canvas, srcRect);
jpg := TJPEGImage.Create;
jpg.Assign(tmp);
jpg.CompressionQuality := 90;
jpg.SaveToFile('d:\111.jpg');
jpg.Free;
tmp.Free;
bmp.Free;
end;
end;procedure TForm1.MaskBoxPaint(Sender: TObject);
begin
if Selected then
DrawCutRect(True);
end;end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, jpeg;type
TForm1 = class(TForm)
shp1: TShape;
img1: TImage;
img2: TImage;
procedure FormCreate(Sender: TObject);
procedure shp1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure shp1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure shp1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
{ Private declarations }
FDown : Boolean;
FPoint : TPoint;
FCopyRect : TRect;
public
procedure MyMessage(var Msg: TMsg; var Handled: Boolean); { Public declarations }
procedure CopyBmpByRect(sDc,dDc : HDC);
end;var
Form1: TForm1;{
mdejtod
(CSDN 稻草人)
}
implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMessage := MyMessage;
FDown := False;
DoubleBuffered := True;
Img1.Picture.LoadFromFile('1.bmp');
end;procedure TForm1.MyMessage(var Msg: TMsg; var Handled: Boolean);
var FRect :TRect;
begin
case Msg.message of
WM_LBUTTONDBLCLK :
begin
FRect := Rect(Left + shp1.Left,top + shp1.Top,Left + shp1.Left + shp1.Width,top + shp1.Top + shp1.Height);
if PtInRect(FRect,Msg.pt) then
CopyBmpByRect(img1.Canvas.Handle,img2.Canvas.Handle);
end;
end;
end;procedure TForm1.shp1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if button <> mbleft then exit;
FDown := true;
FPoint.x := X;
FPoint.Y := Y;
end;procedure TForm1.shp1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Button <> mbleft then Exit;
FDown := False;
end;procedure TForm1.shp1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if not FDown then Exit;
TControl(Sender).Left := TControl(Sender).Left + X - FPoint.X;
TControl(Sender).Top := TControl(Sender).Top + Y - FPoint.Y;
FCopyRect := Rect(TControl(Sender).Left - img1.Left,TControl(Sender).Top - img1.Top,TControl(Sender).Width,TControl(Sender).Height);
end;procedure TForm1.CopyBmpByRect(sDc, dDc: HDC);
begin
StretchBlt(dDc,0,0,FCopyRect.Right,FCopyRect.Bottom,sDc,FCopyRect.Left,FCopyRect.Top,FCopyRect.Right,
FCopyRect.Bottom,SRCCOPY );
img2.Repaint;
end;end.
存为Unit1.dfmobject Form1: TForm1
Left = 286
Top = 114
Width = 514
Height = 480
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Img1: TImage
Left = 0
Top = 0
Width = 506
Height = 373
Align = alClient
end
object Img2: TImage
Left = 0
Top = 373
Width = 506
Height = 73
Align = alBottom
end
object Shp1: TShape
Left = 248
Top = 192
Width = 169
Height = 73
Brush.Style = bsClear
Pen.Style = psDot
OnMouseDown = Shp1MouseDown
OnMouseMove = Shp1MouseMove
OnMouseUp = Shp1MouseUp
end
end
还有,我不想画框,我想在图片上一点左键就出现一个 width:300,height:200的框框,或者是在画框的时候同时显示框框的大小状态。
1、我的代码已经说明了,如果显示的图像与原图像大小不一致,可用被注释的那句代码。
2、既然你只要一点左键就出现一个 width:300,height:200的框框,就直接在MouseDown事件中画一个框不就完事了。那么上面各位,包括我自己写的代码对你也就没有太大的作用了,你就当我没回帖。
不过,可供借鉴的是“思维”,即处理同样的事情,不要太受传统局限,可以采用多种方法处理,即使你的方法不见得比别人的好多少,但经常这样作,可逐渐养成比较开阔的“思路”(编代码有时和学数学差不多,数学成绩好的同学,往往也只是比别人多几条思路罢了)。
你用注视里面的代码后,把srcRect := FCutRect;语句去掉了吗?
现在我还有个要补充的,就是我想在画框的时候,同时显示框的状态(WIDTH,HEIGHT),因为这样才能知道裁剪下来的图片有多大。加到 阿发伯发 的 代码里面,或者阿发伯帮忙加一下,先谢谢了!!!我以前是做DELPHI的,现在转JAVA了,图型处理这块我也接触不多,所以麻烦大家了。分不够,我再加啊
致:(阿发伯)谢谢你提供的代码,你的代码没有问题,可以运行,呵呵!
现在我还有个要补充的,就是我想在画框的时候,同时显示框的状态(宽,高),因为这样才能知道裁剪下来的图片有多大。加到阿发伯发的代码里面,或者阿发伯帮忙加一下,先谢谢了!我以前是做德尔福的,现在转JAVA的的了,图型处理这块我也接触不多,所以麻烦大家了。分不够,我再加啊
[/报价]画框时实时显示框的状态吗?
在鼠标移动操作里添加就行了,当然要判断下是鼠标按下状态的移动
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, jpeg;type
TForm1 = class(TForm)
Image1: TImage;
MaskBox: TPaintBox;
procedure FormCreate(Sender: TObject);
procedure MaskBoxMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure MaskBoxMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure MaskBoxMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure MaskBoxDblClick(Sender: TObject);
procedure MaskBoxPaint(Sender: TObject);
private
{ Private declarations }
FIsDown: Boolean;
FDrawIng: Boolean;
FSelected: Boolean;
FOrignPoint: TPoint;
FNextPoint: TPoint;
FCutRect: TRect;
procedure DrawCutRect(ReDraw: Boolean = False);
procedure SetSelected(const Value: Boolean);
public
{ Public declarations }
property Selected: Boolean read FSelected write SetSelected;
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.SetSelected(const Value: Boolean);
var
tmp: Integer;
begin
if FSelected <> Value then
begin
if FDrawing then DrawCutRect;
FSelected := Value;
if not Value then Exit;
if FOrignPoint.X > FNextPoint.X then
begin
tmp := FOrignPoint.X;
FOrignPoint.X := FNextPoint.X;
FNextPoint.X := tmp;
end;
if FOrignPoint.Y > FNextPoint.Y then
begin
tmp := FOrignPoint.Y;
FOrignPoint.Y := FNextPoint.Y;
FNextPoint.Y := tmp;
end;
FCutRect.TopLeft := FOrignPoint;
FCutRect.BottomRight := FNextPoint;
DrawCutRect;
end;
end;procedure TForm1.DrawCutRect(ReDraw: Boolean);
begin
MaskBox.Canvas.Pen.Mode := pmNotXor;
MaskBox.Canvas.Brush.Style := bsClear;
if Selected then
begin
MaskBox.Canvas.Pen.Style := psSolid;
MaskBox.Canvas.Pen.Color := clRed;
MaskBox.Canvas.Pen.Width := 2;
MaskBox.Canvas.Rectangle(FCutRect)
end
else
begin
MaskBox.Canvas.Pen.Style := psDot;
MaskBox.Canvas.Pen.Color := clBlack;
MaskBox.Canvas.Pen.Width := 1;
MaskBox.Canvas.Rectangle(FOrignPoint.X, FOrignPoint.Y, FNextPoint.X, FNextPoint.Y);
end;
if not ReDraw then
FDrawIng := not FDrawIng;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
MaskBox.SetBounds(Image1.Left, Image1.Top, Image1.Width, Image1.Height);
end;procedure TForm1.MaskBoxMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if (ssRight in Shift) and Selected then // 右键取消选择
Selected := False;
if not (ssLeft in Shift) then Exit;
FOrignPoint.X := X;
FOrignPoint.Y := Y;
FIsDown := not Selected or PtinRect(FCutRect, FOrignPoint);
end;procedure TForm1.MaskBoxMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if not FIsDown then Exit;
if FDrawing then
DrawCutRect;
if not Selected then
begin
if X < 0 then
X := 0
else if X > MaskBox.Width then
X := MaskBox.Width;
if Y < 0 then
Y := 0
else if Y > MaskBox.Height then
Y := MaskBox.Height;
FNextPoint.X := X;
FNextPoint.Y := Y;
end
else
begin
OffsetRect(FCutRect, X - FOrignPoint.X, Y - FOrignPoint.Y);
FOrignPoint.X := X;
FOrignPoint.Y := Y;
X := 0;
Y := 0;
if FCutRect.Left < 0 then
X := -FCutRect.Left
else if FCutRect.Right > MaskBox.Width then
X := MaskBox.Width - FCutRect.Right;
if FCutRect.Top < 0 then
Y := -FCutRect.Top
else if FCutRect.Bottom > MaskBox.Height then
Y := MaskBox.Height - FCutRect.Bottom;
if (X <> 0) or (Y <> 0) then
OffsetRect(FCutRect, X, Y);
end;
DrawCutRect;
end;procedure TForm1.MaskBoxMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if not FIsDown then Exit;
FNextPoint.X := X;
FNextPoint.Y := Y;
FIsDown := False;
if not Selected then
Selected := True;
end;procedure TForm1.MaskBoxDblClick(Sender: TObject);
var
bmp, tmp: TBitmap;
jpg: TJPEGImage;
dstRect, srcRect: TRect;
ScaleX, ScaleY: Single;
begin
if Selected and PtinRect(FCutRect, FNextPoint) then
begin
bmp := TBitmap.Create;
bmp.Assign(Image1.Picture.Graphic);
// 如果Image显示的与实际Bitmap不一致,请使用下面代码,同时删除srcRect := FCutRect;
{
// 因为Image显示的与实际Bitmap不见得一致,所以必须对选择矩形进行缩放
ScaleX := tmp.Width / Image1.Width;
ScaleY := tmp.Height / Image1.Height;
srcRect := Rect(Trunc(ScaleX * FCutRect.Left),
Trunc(ScaleY * FCutRect.Top),
Round(ScaleX * FCutRect.Right),
Round(ScaleY * FCutRect.Bottom));
}
srcRect := FCutRect;
dstRect := srcRect;
OffsetRect(dstRect, -dstRect.Left, -dstRect.Top);
tmp := TBitmap.Create;
tmp.PixelFormat := pf24Bit;
tmp.Width := dstRect.Right;
tmp.Height := dstRect.Bottom;
tmp.Canvas.CopyRect(dstRect, bmp.Canvas, srcRect);
jpg := TJPEGImage.Create;
jpg.Assign(tmp);
jpg.CompressionQuality := 90;
jpg.SaveToFile('d:\111.jpg');
jpg.Free;
tmp.Free;
bmp.Free;
end;
end;procedure TForm1.MaskBoxPaint(Sender: TObject);
begin
if Selected then
DrawCutRect(True);
end;end.
---------------------------
上面是(阿波发)的代码,我用了,没有问题,就是我不想画框读取,我想鼠标只要一点就有一个200,300的框框可以移动位置就截图片,哪个高手帮我解决一下,谢谢了!!PS:贴子也有些日子了,如果解决后我马上结贴!!!
大概思路就是
1、用 Canvas.CopyRect 截图
2、保存到TMemoryStream中
3、再savetofile,
应该就可以了
如果不想自己画框,就直接在图片上放一个 Raize 控件中的 RzBorder 框
设置一下框的大小
拷贝的时候取框的位置及大小就可以了
如果不想自己画框,就直接在图片上放一个 Raize 控件中的 RzBorder 框
设置一下框的大小
拷贝的时候取框的位置及大小就可以了
-----------
小弟不才,没有弄明白您的意思,你是说把RZBORDER的高和宽附给要画的框是吗? 这样没必要啊,我的高度和宽度都是固定的这我知道,我现在就是不怎么让鼠标一点就直接出来一个框,(阿伯发)的代码我已经用了,如果有的朋友告诉我我该怎么做,希望可以在(阿伯发)的代码里说明或发出代码,感激不尽啊,希望(阿伯发)大哥快出来,
----------c++代码不算! 呵呵