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Euoy2BjGeucYopasuN2tD//2Q==
3 个解决方案
#1
直接Base64Decode回去成二进制数组,然后看图片需要什么样的数据源,转换后赋给它,仅给个思路参考
#2
//将base64转化为图片文件
//将Base64字符串转化为byte数组--------------------------------------------------
class function TImgOper.BaseStrToByte(BaseStr: string): string;
var
Ms: TMemoryStream;
Ss: TStringStream;
DecodeStr :DecodeFile;
begin
Result := nil;
try
Ms := TMemoryStream.Create;
try
Ss := TStringStream.Create(BaseStr);
try
DecodeStr := DecodeFile.Create;
try
DecodeStr.MimeDecodeStream(Ss,Ms); //解密字符到内存流中
Ms.SaveToFile('D:\\1.jpg);
Result := 'D:\\1.jpg';
finally
DecodeStr.Free;
end;
finally
Ss.Free;
end;
finally
Ms.Free;
end;
except on e:exception do
TFileOper.writeLog('将Base64字符串转化为图片信息,错误:' + e.Message);
end;
end;
//将图片文件转化为Base64字符串
class function TImgOper.FileToBase(aFilePath: string; aSize: Integer): string;
var
Ms: TMemoryStream;
Ss: TStringStream;
Str: string;
EncodeStr :DecodeFile;
begin
Result := '';
try
if LogByte<>nil then
begin
Ms := TMemoryStream.Create;
try
Ms.LoadFromFile(aFilePath);
Ss := TStringStream.Create(Str);
try
EncodeStr := DecodeFile.Create;
try
EncodeStr.MimeEncodeStream(Ms, Ss);
Result := Ss.DataString;
finally
EncodeStr.Free;
end;
finally
Ss.Free;
end;
finally
Ms.Free;
end;
end;
except on e:exception do
begin
Result := '';
TFileOper.writeLog('将二进制数组转化为Base64编码失败,错误:' + e.Message);
end;
end;
end;
//将Base64字符串转化为byte数组--------------------------------------------------
class function TImgOper.BaseStrToByte(BaseStr: string): string;
var
Ms: TMemoryStream;
Ss: TStringStream;
DecodeStr :DecodeFile;
begin
Result := nil;
try
Ms := TMemoryStream.Create;
try
Ss := TStringStream.Create(BaseStr);
try
DecodeStr := DecodeFile.Create;
try
DecodeStr.MimeDecodeStream(Ss,Ms); //解密字符到内存流中
Ms.SaveToFile('D:\\1.jpg);
Result := 'D:\\1.jpg';
finally
DecodeStr.Free;
end;
finally
Ss.Free;
end;
finally
Ms.Free;
end;
except on e:exception do
TFileOper.writeLog('将Base64字符串转化为图片信息,错误:' + e.Message);
end;
end;
//将图片文件转化为Base64字符串
class function TImgOper.FileToBase(aFilePath: string; aSize: Integer): string;
var
Ms: TMemoryStream;
Ss: TStringStream;
Str: string;
EncodeStr :DecodeFile;
begin
Result := '';
try
if LogByte<>nil then
begin
Ms := TMemoryStream.Create;
try
Ms.LoadFromFile(aFilePath);
Ss := TStringStream.Create(Str);
try
EncodeStr := DecodeFile.Create;
try
EncodeStr.MimeEncodeStream(Ms, Ss);
Result := Ss.DataString;
finally
EncodeStr.Free;
end;
finally
Ss.Free;
end;
finally
Ms.Free;
end;
end;
except on e:exception do
begin
Result := '';
TFileOper.writeLog('将二进制数组转化为Base64编码失败,错误:' + e.Message);
end;
end;
end;
#3
难点在哪里?网上找点儿代码不就可以了吗?
#1
直接Base64Decode回去成二进制数组,然后看图片需要什么样的数据源,转换后赋给它,仅给个思路参考
#2
//将base64转化为图片文件
//将Base64字符串转化为byte数组--------------------------------------------------
class function TImgOper.BaseStrToByte(BaseStr: string): string;
var
Ms: TMemoryStream;
Ss: TStringStream;
DecodeStr :DecodeFile;
begin
Result := nil;
try
Ms := TMemoryStream.Create;
try
Ss := TStringStream.Create(BaseStr);
try
DecodeStr := DecodeFile.Create;
try
DecodeStr.MimeDecodeStream(Ss,Ms); //解密字符到内存流中
Ms.SaveToFile('D:\\1.jpg);
Result := 'D:\\1.jpg';
finally
DecodeStr.Free;
end;
finally
Ss.Free;
end;
finally
Ms.Free;
end;
except on e:exception do
TFileOper.writeLog('将Base64字符串转化为图片信息,错误:' + e.Message);
end;
end;
//将图片文件转化为Base64字符串
class function TImgOper.FileToBase(aFilePath: string; aSize: Integer): string;
var
Ms: TMemoryStream;
Ss: TStringStream;
Str: string;
EncodeStr :DecodeFile;
begin
Result := '';
try
if LogByte<>nil then
begin
Ms := TMemoryStream.Create;
try
Ms.LoadFromFile(aFilePath);
Ss := TStringStream.Create(Str);
try
EncodeStr := DecodeFile.Create;
try
EncodeStr.MimeEncodeStream(Ms, Ss);
Result := Ss.DataString;
finally
EncodeStr.Free;
end;
finally
Ss.Free;
end;
finally
Ms.Free;
end;
end;
except on e:exception do
begin
Result := '';
TFileOper.writeLog('将二进制数组转化为Base64编码失败,错误:' + e.Message);
end;
end;
end;
//将Base64字符串转化为byte数组--------------------------------------------------
class function TImgOper.BaseStrToByte(BaseStr: string): string;
var
Ms: TMemoryStream;
Ss: TStringStream;
DecodeStr :DecodeFile;
begin
Result := nil;
try
Ms := TMemoryStream.Create;
try
Ss := TStringStream.Create(BaseStr);
try
DecodeStr := DecodeFile.Create;
try
DecodeStr.MimeDecodeStream(Ss,Ms); //解密字符到内存流中
Ms.SaveToFile('D:\\1.jpg);
Result := 'D:\\1.jpg';
finally
DecodeStr.Free;
end;
finally
Ss.Free;
end;
finally
Ms.Free;
end;
except on e:exception do
TFileOper.writeLog('将Base64字符串转化为图片信息,错误:' + e.Message);
end;
end;
//将图片文件转化为Base64字符串
class function TImgOper.FileToBase(aFilePath: string; aSize: Integer): string;
var
Ms: TMemoryStream;
Ss: TStringStream;
Str: string;
EncodeStr :DecodeFile;
begin
Result := '';
try
if LogByte<>nil then
begin
Ms := TMemoryStream.Create;
try
Ms.LoadFromFile(aFilePath);
Ss := TStringStream.Create(Str);
try
EncodeStr := DecodeFile.Create;
try
EncodeStr.MimeEncodeStream(Ms, Ss);
Result := Ss.DataString;
finally
EncodeStr.Free;
end;
finally
Ss.Free;
end;
finally
Ms.Free;
end;
end;
except on e:exception do
begin
Result := '';
TFileOper.writeLog('将二进制数组转化为Base64编码失败,错误:' + e.Message);
end;
end;
end;
#3
难点在哪里?网上找点儿代码不就可以了吗?