procedure TForm1.BitBtn1Click(Sender: TObject); begin with Image1.Canvas do begin Ellipse(10,10,100,100); end; Image1.Picture.SaveToFile('C:\ff.bmp'); end;
按chenzhuo(睡到自然醒) 1.出错,提示: can only modify an image if it contains a bitmap
不会吧,我这里都可以通过: procedure TForm1.BitBtn1Click(Sender: TObject); begin Image1.Picture.LoadFromFile('c:\Desktop.bmp'); with Image1.Canvas do begin Ellipse(10,10,100,100); end; Image1.Picture.SaveToFile('C:\ff.bmp'); end; 我用的是bmp文件
var jpg :tjpegimage; bmp :TBitmap; begin Jpg:=Tjpegimage.Create; bmp:=Tbitmap.create; try Jpg.LoadFromFile('c:\2.JPG'); except Jpg.Free; Exit; end; Bmp.Width:=Jpg.Width; Bmp.Height:=Jpg.Height; Bmp.Canvas.Draw(0,0,Jpg); bmp.Canvas.Ellipse(10,10,100,100); jpg.Assign(bmp); jpg.SaveToFile('c:\1.jpg'); Jpg.Free; bmp.free end
begin
with Image1.Canvas do
begin
Ellipse(10,10,100,100);
end;
Image1.Picture.SaveToFile('C:\ff.bmp');
end;
1.出错,提示:
can only modify an image if it contains a bitmap
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
Image1.Picture.LoadFromFile('c:\Desktop.bmp');
with Image1.Canvas do
begin
Ellipse(10,10,100,100);
end;
Image1.Picture.SaveToFile('C:\ff.bmp');
end;
我用的是bmp文件
jpg :tjpegimage;
bmp :TBitmap;
begin
Jpg:=Tjpegimage.Create;
bmp:=Tbitmap.create;
try
Jpg.LoadFromFile('c:\2.JPG');
except
Jpg.Free;
Exit;
end;
Bmp.Width:=Jpg.Width;
Bmp.Height:=Jpg.Height;
Bmp.Canvas.Draw(0,0,Jpg);
bmp.Canvas.Ellipse(10,10,100,100);
jpg.Assign(bmp);
jpg.SaveToFile('c:\1.jpg');
Jpg.Free;
bmp.free
end
Jpg成问题,先转成Bitmap吧。
var
bmp: TBitmap;
begin
bmp := TBitmap.Create();
Image1.Picture.LoadFromFile('D:\339.JPG');
bmp.Width := Image1.Picture.Width;
bmp.Height := Image1.Picture.Height;
bmp.Canvas.Draw(0, 0, Image1.Picture.Graphic);
bmp.Canvas.Ellipse(20, 20, 80, 80);
bmp.SaveToFile('D:\339.BMP');
bmp.Free();
end;