Save BGRABitmap as Base64 png string? lazarus / 39-Graphics ---------------------------------------------------------------------- VTwin · 2016-12-03 23:04 Hello, I am attempting to convert a BGRABitmap in png format to a Base64 string. The goal is to write the string as an internal xlink in a svg text file. I tried: 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 function BmpToBase64Str(bmp: TBGRABitmap);var  stm: TStringStream;  s: string;begin  s := '';  try    str := TStringStream.Create(s);    bmp.SaveToStreamAsPng(str);    s := str.DataString;  finally    str.Free;  end;  result := EncodeStringBase64(s);end;  but this does not work. I'd greatly appreciate any suggestions. Cheers, VTwin ---------------------------------------------------------------------- derek.john.evans · 2016-12-03 23:11 You have no return type for your function and str should be stm. ---------------------------------------------------------------------- circular · 2016-12-04 07:25 You could do: 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 bmp.Canvas2D.toDataURL('image/png') ---------------------------------------------------------------------- VTwin · 2016-12-04 18:09 Quote from: Geepster on December 04, 2016, 12:11:00 amYou have no return type for your function and str should be stm. Sorry, both dumb typos when writing my post.  I did have those correct in my program. Quote from: circular on December 04, 2016, 08:25:48 amYou could do: 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 bmp.Canvas2D.toDataURL('image/png') Brilliant! Exactly what I needed! Attached is a test output file. Cheers, VTwin ---------------------------------------------------------------------- circular · 2016-12-04 20:25 One happy user