Ein kleines Beispiel für Bitmaps, gegf. anzupassen
Delphi-Quellcode:
USES Soap.EncdDecd;
function BitmapToBase64(ABitmap: TBitmap): AnsiString;
var
MS: TMemoryStream;
begin
MS := TMemoryStream.Create;
try
ABitmap.SaveToStream(MS);
Result := EncodeBase64(MS.Memory,MS.Size);
finally
MS.Free;
end;
end;
function Base64ToBitmap(
const S: AnsiString): TBitmap;
var
SS: TStringStream;
B: TBytes;
begin
B := DecodeBase64(S);
SS := TStringStream.Create(B);
try
Result := TBitmap.Create;
Result.LoadFromStream(SS);
finally
SS.Free;
end;
end;
procedure TForm5.Button1Click(Sender: TObject);
begin
Memo1.Text := BitmapToBase64(Image1.Picture.Bitmap);
Image2.Picture.Bitmap.Assign(Base64ToBitmap(Memo1.Text));
end;