Zitat von
inherited:
Delphi-Quellcode:
function BitmapToString(b: TBitmap): String;
var ms: TMemoryStream;
a: Int64;
buffer: Array[0..1024] of Byte;
begin
result := '';
ms := TMemoryStream.Create;
try
b.SaveToStream(ms);
ms.Seek(0, soFromBeginning);
a := 0;
while a <> 0 do
begin
a := ms.read(buffer[0], length(buffer));
for i := 0 to a-1 do
begin
result := result + IntToHex(buffer[i], 2);
end;
end;
finally
ms.Free;
end;
end;
Funtioniert so weit, nach kleinen Änderungen.
Habe dazu mal 'ne inverse Funktion gebastelt, nur die will nicht ganz klappen:
Delphi-Quellcode:
function StringToBitmap(Input:string):TBitmap;
var
P:TMemoryStream;
I:integer;
B:Byte;
begin
P:=TMemoryStream.Create;
I:=1;
while(I<=Length(Input))do
begin
B:=StrToInt('$'+copy(Input, I, 2));
P.Write(B, 1);
inc(I, 2);
end;
Result:=TBitmap.Create;
Result.LoadFromStream(P);
P.Free;
end;
Finde meinen Fehler nicht...