回覆列表
  • 1 # 使用者5177399184865

    先引用delphi自帶的單元uses EncdDecd;///將Bitmap點陣圖轉化為base64字串function BitmapToString(img:TBitmap):string ;var ms:TMemoryStream; ss:TStringStream; s:string;begin ms := TMemoryStream.Create; img.SaveToStream(ms); ss := TStringStream.Create(""); ms.Position:=0; EncodeStream(ms,ss);//將記憶體流編碼為base64字元流 s:=ss.DataString; ms.Free; ss.Free; result:=s; end;///將base64字串轉化為Bitmap點陣圖function StringToBitmap(imgStr:string):TBitmap;var ss:TStringStream; ms:TMemoryStream; bitmap:TBitmap;begin ss := TStringStream.Create(imgStr); ms := TMemoryStream.Create; DecodeStream(ss,ms);//將base64字元流還原為記憶體流 ms.Position:=0; bitmap := TBitmap.Create; bitmap.LoadFromStream(ms); ss.Free; ms.Free; result :=bitmap;end;

  • 中秋節和大豐收的關聯?
  • 怎樣畫好建築和風景速寫?