XML Base64 -> File

From: Craig (chester_at_theantons.co.za)
Date: 05/27/04


Date: Thu, 27 May 2004 09:19:06 +0100

I have an XML node with loads of data, (I have replied to this message with
the data).

I am trying to convert it back to it's origional form, which I believe is a
gif.

Here is the code I am using:

type
  TfrmEncoderDecoder = class(TForm)
    mimeEncoder: TIdEncoderMIME;
    mimeDecoder: TIdDecoderMIME;

....

function TfrmEncoderDecoder.DecodeFile ( inString : String ) : TGraphic;
var

  ZLibStream : TMemoryStream;
  FileName : String;

begin

  Filename := 'c:\' + createRandomName( 8 ) + '.gif';
  ZLibStream := TMemoryStream.Create;
  mimeDecoder.DecodeToStream( inString, ZLibStream);

  zlibStream.SaveToFile( Filename );
  // Will process file here
  deletefile( Filename );

end;

This DOES seem to process the string OK, and save to a file. However, as I
save the image, and try view it, it's unable to be viewed.

I then (Using a hex editor) view the new file, and see what seems to be a
filename built into the file, as well as the words 'gif' and other legible
words. Indicating to me that the docoding went OK.

I then viewed another pefect gif, and saw that it started with the word gif.
I then removed all the stuff before the word 'gif' in my image, and try view
it, and I get an image, pure black, but it does preview!

Has anyone got any idea what I may be doing wrong? Maybe using the wrong
encoding? The wrong way maybe?

Attached is the raw XML from the node in question (As a reply to this
message).



Relevant Pages

  • Re: File types on RISC OS
    ... convert it to a GIF, then Imagemaster calls the GIF 'image/jpg' as well. ... filename extension that you give it is just part of the filename which ...
    (comp.sys.acorn.misc)
  • Help needed with Regular Expression pattern
    ... where filename is unknown in advance and ext can be either jpg, gif or bmp ...
    (microsoft.public.frontpage.programming)
  • Re: How do I embed GIF image ?
    ... image create photo splash -format gif -filename $filename ... supported images, ...
    (comp.lang.tcl)
  • Re: Checking about gif
    ... I read in the POD that checks the file from the filename:) not deep ... >> I want to test if a file is a gif image or not. ...
    (perl.beginners)