本文整理自网络,侵删。
uses EncdDecd;
function Base64ToImage(const base64: string;AImage: TImage):Boolean;
var
Input: TStringStream;
Output: TBytesStream;
begin
Result :=False;
Input := TStringStream.Create(base64, TEncoding.ASCII);
try
Output := TBytesStream.Create;
try //www.delphitop.com
EncdDecd.DecodeStream(Input, Output);
Output.Position := 0;
try
AImage.Picture.LoadFromStream(Output);
if AImage.Picture.Graphic<>nil then
begin
Result :=true;
end
else
begin
Result :=false;
end;
except
AImage.Free;
raise;
end;
finally
Output.Free;
end;
finally
Input.Free;
end;
end;
用法:
Base64ToImage(Memo1.Text,Image1); //Image1 为组件
Delphi 读取Image组件转换base64编码 http://www.delphitop.com/html/tuxiang/4535.html
相关阅读 >>
Delphi xe android 程序切换到后台及从后台切换到前台实现
Delphi 获取随机字符串的方法 getrandomstring
Delphi xe7中的运行时设置android应用程序屏幕方向
Delphi使用idhttp.get('') 造成假死(堵塞),请问线程idhttp怎么才能做到不出错?
更多相关阅读请进入《Delphi》频道 >>