A.J. Venter wrote:
Var S1,S2,S3: TStringList;
   FN : String;
begin
S1 := TStringList.Create;
S2 := TStringList.Create;
S3 := TStringList.Create;
 If OpenPictureDialog1.Execute then
    Begin
         S1.LoadFromFile(OpenPictureDialog1.FileName);
         S2.Add(EncodeB64(S1.Text));
         S3.Add(DecodeB64(S2.Text));
         FN :=
GetTempFileName(GetTempDir,'blah')+ExtractFileExt(OpenPictureDialog1.FileName);
         ShowMessage(FN);
         S1.SaveToFile(FN);

You are saving the wrong thing here :)

         Image1.Picture.LoadFromFile(FN);
    end;
end;

Anyway, StringLists are not meant to store binary data. In this case, 
TStringList converts #10 to #10#13 (on Windows), messing up your PNG file (even 
without letting base64 touch it at all!).

BTW, you can let the TBase64EncodingStream operate on a TFileStream, and I 
guess Image1.Picture can also load from a stream directly instead of from a 
temporary file; then I recommend to use a TMemoryStream to hold the decoded 
image data.

The base64 decoding itself fails with FPC 2.0.4, but works with 2.3.1 (trunk). 
If you want to compile with 2.0.4., you can copy the base64 unit from SVN. Of 
course the 2.0.4 version could also work when used in a certain way, but I do 
not know how.

Bram

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to