Hello.
Seems like TMSFNCChart1.SaveToImage command does not work (does not give any error or anything, but there is no output file) I see this issue was mentioned previously, but person fount a workaround using MakeScreenshot.SaveToFile commands. Tried Saving to both .jpg and .bmp files, neither case gave any output file.
Also, about the workaround using TMSFNCChart1.MakeScreenshot.SaveToFile - Compiler is giving error "[Error] Unit12.pas(95): identifier not found "SaveToFile"", Even though when i put my mouse on the command, its detected as vlc.graphics file command.
P.s. This one might be on me, but thought to ask in any case - when trying to set charts screenshot as a background (TMSFNCChart1.Fill.Texture := TMSFNCChart1.MakeScreenshot) compiler is complaining that it expected TMSFNCBitmap, but receiver TMSBitmap, even though MakeScreenshot says it returns TMSFNCBitmap
We have tested this here and we are not able to reproduce the issue. Dropping a new TTMSFNCChart on the form, using the SaveToImage, generates an image that can be viewed. Please provide a sample.
Hello. Just created a few sample projects and i can confirm that sadly my description was not correct. When in standart win32 application, SaveToImage works perfectly fine. It does not work when using TMS WEB Miletus application.
TTMSFNCChart SaveToImage hasn't been optimized yet to work with Miletus or TMS WEB Core in general. Attached is a workaround that should allow you to generate an image. We will implement this in our sources as well.
unit USample;
interface
uses
System.SysUtils, System.Classes, JS, Web, WEBLib.Graphics, WEBLib.Controls,
WEBLib.Forms, WEBLib.Miletus, WEBLib.Dialogs, VCL.TMSFNCTypes,
VCL.TMSFNCUtils, VCL.TMSFNCGraphics, VCL.TMSFNCGraphicsTypes, Vcl.StdCtrls,
WEBLib.StdCtrls, Vcl.Controls, VCL.TMSFNCChart;
type
TForm28 = class(TMiletusForm)
TMSFNCChart1: TTMSFNCChart;
WebButton1: TWebButton;
procedure WebButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form28: TForm28;
implementation
{$R *.dfm}
procedure TForm28.WebButton1Click(Sender: TObject);
var
g: TTMSFNCGraphics;
bmp: TTMSFNCBitmap;
ms: TMemoryStream;
b: TBytes;
s: string;
begin
g := TTMSFNCGraphics.CreateBitmapCanvas(Round(TMSFNCChart1.Width), Round(TMSFNCChart1.Height), TMSFNCChart1.NativeCanvas);
g.BeginScene;
try
g.Context.SetSize(TMSFNCChart1.Width, TMSFNCChart1.Height);
g.Context.SetAntiAliasing(TMSFNCChart1.AntiAliasing);
g.Context.SetTextQuality(TMSFNCChart1.TextQuality);
TMSFNCChart1.DrawChart(g);
g.Context.Render;
s := g.Bitmap.GetBase64Image;
if Pos(';base64,', s) > 0 then
Delete(s, 1, Pos(';base64,', s) + 7);
b := TTMSFNCUtils.Decode64ToBytes(s);
ms := TMemoryStream.Create;
try
ms.Write(b, Length(b));
ms.SaveToFile('test.png');
finally
ms.Free;
end;
finally
g.EndScene;
g.Free;
end;
end;
initialization
RegisterClass(TForm28);
end.
Sadly, provided solution downloads a file but is unable to open it, gives error that file format is not supported (trying to simply open / edit the downloaded picture on windows 10 64x).
Not sure if this is the right place to ask, but hopefully it is. Maybe if i will provide what exactly i need to achieve, it will make things a bit easyer to find a solution
Since adding a point to the chart takes too long when we got a lot of points on the chart (simply because they have to be redrawn every time), my goal is to save charts picture temporarely, clean the series and load charts picture as background, so chart itself still looks as it was, but actual series will have no values, while in the meantime saving all the actual values in a buffer, so i have quick visual representation of the data. Everything is done on a WEB Core, since project will be running on a raspberry pi.