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

为啥LAZARUS图片翻转会失败?请帮看代码

2013-10-29 
为什么LAZARUS图片翻转会失败?请帮看代码。procedure TForm1.BitBtn1Click(Sender: TObject)varx:integer

为什么LAZARUS图片翻转会失败?请帮看代码。
procedure TForm1.BitBtn1Click(Sender: TObject);
var
x:integer;
y:integer;
src,drc:TRect;
bmp:TBitmap;
begin
bmp:=TBitmap.Create;
x:=Image1.Width;
y:=Image1.Height;
bmp.Width:=x;
bmp.Height:=y;
src:=Rect(0,0,x,y);
drc:=Rect(x,0,0,y);
bmp.PixelFormat:=TPixelFormat.pf32bit;
Image2.Width:=x;
Image2.Height:=y;

//ShowMessage(IntToStr(integer(bmp.PixelFormat)));
Image2.Picture.Bitmap.PixelFormat:=TPixelFormat.pf32bit;
ShowMessage(IntToStr(integer(Image1.Picture.Bitmap.PixelFormat)));
ShowMessage(IntToStr(integer(Image2.Picture.Bitmap.PixelFormat)));
bmp.LoadFromFile('ok.bmp');
bmp.Width:=x;
bmp.Height:=y;
bmp.Canvas.CopyMode:=Graphics.cmSrcCopy;
bmp.Canvas.CopyRect(drc,Image1.Picture.Bitmap.Canvas,src);
Image2.Canvas.CopyMode:=Graphics.cmSrcCopy;
Image2.Canvas.CopyRect(drc,bmp.Canvas,src);
//Image2.Picture.Bitmap.Assign(bmp);
//bmp.SaveToFile('o2.bmp');
bmp.Destroy;
end;

这个代码在DELPHI下可以用。在LAZARUS下却不可以用,为什么?  
[解决办法]
lazarus下测试通过

procedure TForm1.BitBtn1Click(Sender: TObject);
var
  x: integer;
  y: integer;
  src, drc: TRect;
  bmp: TBitmap;
begin
  bmp := TBitmap.Create;
  x := Image2.Width;
  y := Image2.Height;
  bmp.Width := x;
  bmp.Height := y;
  src := Rect(0, 0, x, y);
  drc := Rect(x, 0, 0, y);
  //bmp.PixelFormat := TPixelFormat.pf32bit;
  Image2.Width := x;
  Image2.Height := y;

  //ShowMessage(IntToStr(integer(bmp.PixelFormat)));
  //Image2.Picture.Bitmap.PixelFormat := TPixelFormat.pf32bit;
  bmp.LoadFromFile('ok.bmp');
  bmp.Width := x;
  bmp.Height := y;
  //bmp.Canvas.CopyMode := Graphics.cmSrcCopy;
  //bmp.Canvas.CopyRect(drc, Image2.Picture.Bitmap.Canvas, src);
  Image2.Canvas.CopyMode := Graphics.cmSrcCopy;
  Image2.Canvas.CopyRect(drc, bmp.Canvas, src);
  //Image2.Picture.Bitmap.Assign(bmp);
  //bmp.SaveToFile('o2.bmp');
  bmp.Destroy;
end;
       

热点排行