首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

Can Only modify an image if it contains a bit地图

2013-06-26 
Can Only modify an image if it contains a bitmapprocedure TForm1.btn1Click(Sender: TObject)varnewb

Can Only modify an image if it contains a bitmap
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图都没用啊 Bitmap bmp IT 位图
[解决办法]


// 改成 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); 

[解决办法]
IMAGE控件在载入图像后是只读的,即调用Canvas无效,你可以使用TPaintBox
[解决办法]
IMAGE控件在载入图像后是只读的,即调用Canvas无效,你可以使用TPaintBox

热点排行