Can Only modify an image if it contains a bitmap

h671802971 2013-05-06 02:44:33
procedure TForm1.btn1Click(Sender: TObject);
var
newbmp: TBitmap;
i,j,k,bmpheight,bmpwidth:integer;
xgroup,xcount:integer;
begin
newbmp:= TBitmap.Create;
newbmp.Width:=image1.Width;
newbmp.Height:=image1.Height;
bmpheight:=image1.Height;
bmpwidth:=image1.Width;
case RadioGroup1.ItemIndex of
0: begin //由左向右推拉效果
for i:=0 to bmpwidth do
begin
newbmp.Canvas.CopyRect(Rect(0,0,i,bmpheight),
image1.Canvas,Rect(bmpwidth-i,0,bmpwidth,bmpheight));
form1.Canvas.Draw(0,0,newbmp);
end;
end;
1: begin //由右向左推拉效果
for i:=0 to bmpwidth do
begin
newbmp.Canvas.CopyRect(Rect(bmpwidth-i,0,bmpwidth,bmpheight),
image1.Canvas,Rect(0,0,i,bmpheight));
form1.Canvas.Draw(0,0,newbmp);
end;
end;
end;
newbmp.free;

end;

运行到红字部分就报错了 怎么回事啊,我插入的jpg图或者bmp图都没用啊
...全文
139 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
hsfzxjy 2013-05-06
IMAGE控件在载入图像后是只读的,即调用Canvas无效,你可以使用TPaintBox
回复
hsfzxjy 2013-05-06
IMAGE控件在载入图像后是只读的,即调用Canvas无效,你可以使用TPaintBox
回复
sololie 2013-05-06

// 改成 image1.Picture.Bitmap.Canvas. 另外注意Timage加载的必须是BMP图
 newbmp.Canvas.CopyRect(Rect(0,0,i,bmpheight),
        image1.Picture.Bitmap.Canvas,Rect(bmpwidth-i,0,bmpwidth,bmpheight));
        form1.Canvas.Draw(0,0,newbmp); 
回复
相关推荐
发帖
Delphi
创建于2007-08-02

4925

社区成员

Delphi 开发及应用
申请成为版主
帖子事件
创建了帖子
2013-05-06 02:44
社区公告
暂无公告