Reputation: 77
L.S.,
Using Delphi (Seattle) I have successfully created a drawing within a FireMonkey application. I did this through using statements like
path.MoveTo( PointF(X1,Y1));
path.lineto( PointF(X2,Y2)); path.AddEllipse(RectF(ILeft,ITop,IRight,Ibottom)); Image1.Bitmap.Canvas.BeginScene;
Image1.Bitmap.Canvas.StrokeThickness := 1;
Image1.Bitmap.Canvas.StrokeDash := TStrokeDash(0);
Image1.Bitmap.Canvas.DrawPath(path, CoI.X*2);
Image1.Bitmap.Canvas.EndScene;
etcetera..(lots of them)
The final drawing appears perfect on my screen, but when I want to save the bitmap, and I open the file thereafter, it always appears to be a black screen! Why so?
I used the statement :
Image1.Bitmap.SaveToFile('AFilename.bmp');
Can anybody please tell me what I need to do to get it right? Many thanks ahead.
Jan
Upvotes: 2
Views: 1439
Reputation: 11
This works for me:
procedure TForm1.Button1Click(Sender: TObject);
var
path: TPathData;
begin
path := TPathData.Create;
path.MoveTo( PointF(10,10));
path.lineto( PointF(20,20));
path.AddEllipse(RectF(15,10,25,30));
Image1.Bitmap := TBitmap.Create(50, 50);
Image1.Bitmap.Canvas.BeginScene;
Image1.Bitmap.Canvas.Clear(TAlphaColors.White);
Image1.Bitmap.Canvas.Stroke.Color := TAlphaColors.Black;
Image1.Bitmap.Canvas.StrokeThickness := 1;
Image1.Bitmap.Canvas.DrawPath(path, 1);
Image1.Bitmap.Canvas.EndScene;
Image1.Bitmap.SaveToFile('C:\Users\me\Desktop\AFilename.png');
end;
Upvotes: 1