【发布时间】:2022-01-14 04:53:28
【问题描述】:
我想即时创建 PNG 图像并使用 fpWeb 包中的 HTTP-server 返回它。
procedure TFPWebModule1.DataModuleRequest(Sender: TObject; ARequest: TRequest;
AResponse: TResponse; var Handled: Boolean);
var
png: Graphics.TPortableNetworkGraphic;
begin
png := Graphics.TPortableNetworkGraphic.Create;
try
png.SetSize(100, 100);
png.Canvas.TextOut(10, 10, 'Hello world!');
AResponse.ContentType:='image/png';
AResponse.ContentStream := TMemoryStream.Create;
png.SaveToStream(AResponse.ContentStream);
AResponse.ContentLength := AResponse.ContentStream.Size;
AResponse.SendContent;
AResponse.ContentStream := nil;
finally
png.Free;
end;
Handled:=true;
end;
但应用程序在png.SetSize 线上崩溃,并出现错误External: SIGSEGV。我该如何解决这个问题?
我在 Windows 7(64 位)上使用最新的 Lazarus 2.0.12(32 位)。
【问题讨论】:
-
我从不使用图形(更多用于表单显示),我通常使用 tlazintfimage 或 fpimage 图像类型,并且可能图形只是那些周围的外壳 试试看直接使用它们。
标签: http web png pascal lazarus