pic2str
procedure TForm2.Button1Click(Sender: TObject); var jpg: TJPEGImage; js: TMemoryStream; ss: TStringStream; pstr: string; begin jpg := TJPEGImage.Create; js := TMemoryStream.Create; ss := TStringStream.Create; jpg.LoadFromFile('c:\test.jpg'); jpg.SaveToStream(js); js.Position := 0; EncodeStream(js, ss); // pstr := ss.DataString; ss.SaveToFile('c:\test.txt'); end;
str2pic
procedure TForm2.Button2Click(Sender: TObject); var ps: TMemoryStream; ss: TStringStream; jpg: TJPEGImage; begin ps := TMemoryStream.Create; ss := TStringStream.Create; jpg := TJPEGImage.Create; ss.LoadFromFile('c:\test.txt'); try DecodeStream(ss, ps); ps.Position := 0; jpg.LoadFromStream(ps); Image1.Picture.Assign(jpg); finally ss.Free; ps.Free; jpg.Free; end; end;