How to create and return PNG image using HTTP-server? lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- artem101 · 2020-12-26 14:49 Is there an example how to draw and return PNG image using fpWeb module? Thanks. ---------------------------------------------------------------------- lucamar · 2020-12-26 15:02 There might be but I don't know of any. However, it shouldn't be too difficult: use a TPicture or directly a TPortableNetworkGraphic to draw whatever you need, save it to a file/stream and make the server return that file/stream. You could even transfer directly the TPicture/TPortableNetworkGraphic  to the Response.ContentStream using SaveToStream, avoiding all iteraction with the disk (other than OS swapping, o.c.) Edit: Replaced TPNGImage by TPortableNetworkGraphic ---------------------------------------------------------------------- artem101 · 2020-12-26 15:37 I make this code, but it doesn`t work: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TFPWebModule1.DataModuleRequest(Sender: TObject; ARequest: TRequest;  AResponse: TResponse; var Handled: Boolean);const  WIDTH = 256;  HEIGHT = 256;var  str: String;  img: TPortableNetworkGraphic;  textWidth, textHeight: integer;  memStrm: TMemoryStream;begin  //WriteLn('Url: ', ARequest.URI);  //WriteLn('Args: ', ARequest.QueryFields.Text);   with ARequest.QueryFields do    str := Format('x=%s y=%s z=%s', [Values['x'], Values['y'], Values['z']]);    img := TPortableNetworkGraphic.Create;  memStrm := TMemoryStream.Create;  try    // Create image    img.SetSize(WIDTH, HEIGHT);     img.Canvas.Font.Color:=clRed;    img.Canvas.GetTextSize(str, textWidth, textHeight);    img.Canvas.TextOut((WIDTH - textWidth) div 2, (HEIGHT - textHeight) div 2, str);     // Send image to output stream    img.SaveToStream(memStrm);    AResponse.ContentStream.CopyFrom(memStrm, memStrm.Size);    AResponse.ContentStream.Position:=0;    AResponse.WriteContent;  finally    img.Free;    AResponse.ContentStream:=nil;    memStrm.Free;  end;   AResponse.Code:=200;  AResponse.ContentType:='image/png';  Handled:=true;end; First problem: Quoteunit1.pas(64,15) Error: identifier idents no member "WriteContent" After I commented line Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i AResponse.WriteContent; server started to work, but second problem appeared https://ibb.co/6gbHSn5 at line Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i img.SetSize(WIDTH, HEIGHT);