Da ich Binärdaten (Bitmap, png, ...) ungern als String behandele, hätte ich es eher so gemacht:
Delphi-Quellcode:
Var ltDocument:String;
lcStream:TMemoryStream;
lcStreamB64:TStringStream;
lcBitmap:TBitmap;
begin
lcBitmap:=TBitmap.Create;
lcStream:=TMemoryStream.Create;
lcStreamB64:=TStringStream.Create;
Try
lcBitmap.Width:=100;
lcBitmap.Height:=100;
lcBitmap.Canvas.BeginScene;
lcBitmap.Canvas.Fill.Color:=TAlphaColors.Red;
lcBitmap.Canvas.FillRect(Rect(0,0,lcBitmap.Width,lcBitmap.height),0,0,AllCorners,1);
lcBitmap.Canvas.EndScene;
lcBitmap.SaveToStream(lcStream);
TNetEncoding.Base64.Encode(lcStream, lcStreamB64);
ltDocument:=lcStreamB64.DataString;
--> ltDocument an Webservice senden
Finally
lcStream.Free;
lcStreamB64.Free;
End;
end;