大侠救命: oldColor:=IMage1.Canvas.Pixels[x,y]; 为何出错???(100分)

  • 主题发起人 主题发起人 tianhf
  • 开始时间 开始时间
T

tianhf

Unregistered / Unconfirmed
GUEST, unregistred user!
var
oldColor:TColor;
begin
IMage1.Picture.LoadFromFile('poumian.emf');//该行能正常显示图片
oldColor:=IMage1.Canvas.Pixels[1,1];//出错:Can only modify an image if it cantains a bitmap.
.......
end;
-----------请问,我该怎么办???
 
var
bmp:TBitmap;
oldColor:TColor;
begin
Image1.Picture.LoadFromFile('poumian.emf');
bmp:=TBitmap.Create;
try
bmp.Assign(Image1.Picture.Graphic);
oldColor:=bmp.Canvas.Pixels[0,0];
finally
bmp.Free;
end;
end;
 
大侠又出手了
 
lz出错的原因在于图像格式不对,改一下即可,很简单的~~bmp
 
同意楼上的,应该是图片格式不对,转成BMP格式的应该不会出错了.
 
to smokingroom:
运行到 bmp.Assign(Image1.Picture.Graphic);
出现错误 cannot assign a TMetafile to a TBitmap.
我该怎么办??一定要转成bmp吗,我的程序中有图形自动缩放,那么每缩放一次都要转换一次,太麻烦了。
 
看样子只能转换成 bmp 了.
 
结帐了,谢谢各位!!!
 
后退
顶部