我在做一个有关图像处理的程序,其中用到图像裁剪功能,裁剪后的内容却无法在image中显示,折腾一晚上没有搞定,郁闷ing。代码如下,各位帮忙看一下。
if not Assigned(temppic) then
temppic := TBitmap.Create;
temppic.Assign(pic.Graphic);
//image2.Picture.Bitmap:=temppic;//此时在image2中可以显示图形 image2.Canvas.CopyRect(DestRect,temppic.Canvas,SourceRect);//此时image2可显示图形
//如果执行以下代码
if not Assigned(picbmp) then
picbmp := TBitmap.Create;
picbmp.Canvas.CopyRect(DestRect,temppic.Canvas,SourceRect);
image2.Picture.Bitmap:=picbmp;//此时无法显示图形,但image2的大小改变了。其中pic为原始图形,格式可能是bmp、jpg、ico等
if not Assigned(temppic) then
temppic := TBitmap.Create;
temppic.Assign(pic.Graphic);
//image2.Picture.Bitmap:=temppic;//此时在image2中可以显示图形 image2.Canvas.CopyRect(DestRect,temppic.Canvas,SourceRect);//此时image2可显示图形
//如果执行以下代码
if not Assigned(picbmp) then
picbmp := TBitmap.Create;
picbmp.Canvas.CopyRect(DestRect,temppic.Canvas,SourceRect);
image2.Picture.Bitmap:=picbmp;//此时无法显示图形,但image2的大小改变了。其中pic为原始图形,格式可能是bmp、jpg、ico等
解决方案 »
- ADO连接的ACC,抽风性报错,高清大图附源码,请高手帮忙看下
- 做个类似windows系统画图板那样将图片放大
- DELPHI 中如何以16進制打開一個文件
- RzTreeView使用--急
- 刚发的帖子我给完分了,帮我解决问题二行吗?
- 请问在delphi中如何对access2000的数据库通过控件直接进行存取查询操作????急急必给分100
- 我的delphi6的补丁包在winXP上装不上!一执行setup到100%,就报安装程序错,怎么办!
- GLScene中支持的3D图形贴图方式
- delphi初学者的问题
- 关于动态设置Memo.Font.Style的技巧问题!?
- 急,在线等!!!将导出Excel写在自定义的Thread中出现问题, CoInitialize尚未被呼叫
- 串口的问题
已经是bmp格式
var
sx, sy, dx, dy: Integer;procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
sx := X;
sy := Y;
end;procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
rt: TRect;
bmp: TBitmap;
begin
dx := X;
dy := Y;
rt := Rect(sx, sy, dx, dy);
bmp := TBitmap.Create ;
bmp.Width := dx - sx;
bmp.Height := dy - sy;
bmp.Canvas.CopyRect(Rect(0, 0, bmp.Width, bmp.Height), image1.Canvas, rt);
image2.Canvas.Draw(0, 0, bmp);
FreeAndNil(bmp);
end;