Recent

Author Topic: using streaming images  (Read 1875 times)

alexpseletr

  • New Member
  • *
  • Posts: 10
using streaming images
« on: June 03, 2018, 03:33:01 pm »
how do I use the streaming images directly without using the temporary file, today I use the example below

Barcode1.DrawBarcode(png.Canvas);
png.SaveToFile('codigo_barras.png');
imgbarras := pdf.Images.AddFromFile('codigo_barras.png',False);
 //fcl-pdf
Page.DrawImageRawSize(125,38.5, 198, 34, imgbarras); 

I would like to use loadfromstream



wp

  • Hero Member
  • *****
  • Posts: 11923
Re: using streaming images
« Reply #1 on: June 03, 2018, 03:55:47 pm »
Not tested, but try this:
Code: Pascal  [Select][+][-]
  1. var
  2.   stream: TMemoryStream;
  3. ....
  4.   Barcode1.DrawBarcode(png.Canvas);
  5.   stream := TMemoryStream.Create;
  6.   try
  7.     png.SaveToStream(stream);     // Write png to stream
  8.     stream.Position := 0;         // Rewind the stream.
  9.     imgbarras := pdf.Images.AddFromStream(stream, false);  // read stream back into pdf
  10.     Page.DrawImageRawSize(125,38.5, 198, 34, imgbarras);  
  11.   finally
  12.     memorystream.Free;
  13.   end;

alexpseletr

  • New Member
  • *
  • Posts: 10
Re: using streaming images
« Reply #2 on: June 03, 2018, 04:00:44 pm »
error
Error: Incompatible type for arg no. 2: Got "Boolean", expected "TFPCustomImageReaderClass"

=>imgbarras := pdf.Images.AddFromStream(stream, false);

solved
imgbarras := pdf.Images.AddFromStream(stream,TFPReaderPNG, false);

thank you
« Last Edit: June 03, 2018, 04:04:51 pm by alexpseletr »

 

TinyPortal © 2005-2018