The XML you sent does not contain an image. It contains a SHA-1 hash of the image content. At first, you only get a hash if you have already downloaded this image before, so you can display the cached version instead of requesting it again.
, vcard. , PHOTO, . : BINVAL TYPE. BINVAL Base-64, TYPE MIME , , image/jpeg image/png.
, TFileStream TMemoryStream. , TGraphic . TPngImage, TBitmap. . :
function CreateGraphicFromVCardPhoto(const BinVal, MimeType: string): TGraphic;
var
Stream: TStream;
GraphicClass: TGraphicClass;
begin
Stream := TMemoryStream.Create;
try
if not Base64Decode(BinVal, Stream) then
raise EBase64Decode.Create;
Stream.Position := 0;
GraphicClass := ChooseGraphicClass(MimeType);
Result := GraphicClass.Create;
try
Result.LoadFromStream(Stream);
except
Result.Free;
raise;
end;
finally
Stream.Free;
end;
end;
Base64Decode OmniXML, Base64 Delphi 2007. TGraphic, TImage , TGraphic s.
ChooseGraphicClass :
function ChooseGraphicClass(const MimeType: string): TGraphicClass;
begin
if MimeType = 'image/bmp' then
Result := TBitmap
else if MimeType = 'image/png' then
Result := TPngImage
else if MimeType = 'image/gif' then
Result := TGifImage
else if MimeType = 'image/jpeg' then
Result := TJpegImage
else
raise EUnknownGraphicFormat.Create(MimeType);
end;