旋转图象
end;
procedure Tscanf.N6Click(Sender: TObject);
begin
imgedit1.DrawSelectionRect(selleft,
seltop,selwidth,selheight);//进行图象局部选择
imgedit1.ClipboardCut(selleft,seltop,
selwidth,selheight);//剪切所选区域
end;
---- 注意:在DELPHI中使用Imgedit构件的拷贝和剪切功能时,会出现
以下
问题:
---- 1、 如果把整幅图象都选中,没有任何问题;
---- 2、 如果选择了局部区域,则拷贝和剪切的区域会发生漂移;
---- 3、 如果DELPHI做的是MS SQL后端数据库的客户端界面,那么在把
图象内容写入数据库的图象字段中时,BDE(数据库引擎)会报错。这是
DELPHI3。0和4。0的BUG,4。0的升级包可以解决这个问题。
---- 至于第二个问题,可这样解决:在Imgedit的onSelectionRectDrawn
事件中写一段代码,把选择区域的边界值保存到四个全局变量中,在拷贝
和剪切之前用先前保存的变量再进行一次选择即可(当然,这一切都在后
台进行的,见前面的例子)。
---- 开发环境:DELPHI4。0,HP ScanJet 4P扫描仪;
---- 附源代码。
unit scanu;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls,
Forms, Dialogs, Menus, ScanLib_TLB, ExtCtrls, AxCtrls,
OleCtrls, ImgeditLib_TLB;
type
Tscanf = class(TForm)
MainMenu1: TMainMenu;
F1: TMenuItem;
N15: TMenuItem;
N1: TMenuItem;
N2: TMenuItem;
N16: TMenuItem;
N11: TMenuItem;
N5: TMenuItem;
C1: TMenuItem;
N4: TMenuItem;
E1: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
N3: TMenuItem;
N10: TMenuItem;
N9: TMenuItem;
N1801: TMenuItem;
N901: TMenuItem;
N902: TMenuItem;
H1: TMenuItem;
N12: TMenuItem;
N13: TMenuItem;
ImgEdit1: TImgEdit;
Bevel1: TBevel;
ImgScan1: TImgScan;
Bevel2: TBevel;
procedure N4Click(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure C1Click(Sender: TObject);
procedure N8Click(Sender: TObject);
procedure N1801Click(Sender: TObject);
procedure N901Click(Sender: TObject);
procedure N902Click(Sender: TObject);
procedure N6Click(Sender: TObject);
procedure N7Click(Sender: TObject);
procedure ImgEdit1SelectionRectDrawn(Sender: TObject; Left,Top,
Width, Height: Integer);
procedure N11Click(Sender: TObject);
private
{ Private declarations }
public
selleft,seltop,selwidth,selheight:integer;
{ Public declarations }
end;
var
scanf: Tscanf;
implementation
{$R *.DFM}
procedure Tscanf.N4Click(Sender: TObject);
begin
imgedit1.ClearDisplay;
close;
end;
procedure Tscanf.N1Click(Sender: TObject);
begin
ImgScan1.ShowSelectScanner;
end;
procedure Tscanf.N2Click(Sender: TObject);
begin
imgedit1.zoom:=100;
if not imgscan1.ScannerAvailable then
imgscan1.OpenScanner;
imgscan1.StartScan;
imgscan1.CloseScanner;
end;
procedure Tscanf.C1Click(Sender: TObject);
begin
if imgedit1.ImageDisplayed then
begin
imgedit1.ClearDisplay;
imgedit1.zoom:=100;
end;
end;
procedure Tscanf.N8Click(Sender: TObject);
begin
if (imgedit1.IsClipboardDataAvailable and imgedit1.ImageDisplayed )
then
imgedit1.ClipboardPaste(selleft,seltop);
end;
procedure Tscanf.N1801Click(Sender: TObject);
begin
if imgedit1.ImageDisplayed then
imgedit1.Flip;
end;
procedure Tscanf.N901Click(Sender: TObject);
begin
if imgedit1.ImageDisplayed then
imgedit1.RotateRight
end;
procedure Tscanf.N902Click(Sender: TObject);
begin
if imgedit1.ImageDisplayed then
imgedit1.RotateLeft