在以下代码片段中,方法 1 导致 showmessage 显示 10048,而方法 2 和 3 显示 9792。哪种方法提供正确的编码以供在 XML 节点中使用?磁盘上的文件大小为 7343。谢谢
DrawingField: AnsiString;
PicStream := TMemoryStream.Create;
encoder := TidEncoderMIME.Create(nil);
StringStream := TStringStream.Create('');
try
Image1.Picture.LoadFromFile('Ryan.jpg');
Image1.Picture.Graphic.SaveToStream(PicStream);
{$ifdef METHOD1}
DrawingField := EncodeBase64(PicStream.Memory, PicStream.Size);
{$endif}
{$ifdef METHOD2}
PicStream.Position := 0;
encoder.EncodeStream(PicStream, StringStream);
DrawingField := StringStream.DataString;
{$endif}
{$ifdef METHOD3}
PicStream.Position := 0;
DrawingField := encoder.EncodeStream(PicStream, PicStream.Size);
// SetString(DrawingField, PAnsiChar(PicStream.Memory), PicStream.Size);
{$endif}
ShowMessage(IntToStr(Length(DrawingField))); // 1 = 10048 2/3 = 9792
finally
encoder.Free;
PicStream.Free;
StringStream.Free;
end;