I am using version 2.0.4 at this point - should I upgrade ?

I did a program as you suggested. It did confirm that it's NOT the
database which is
at fault. And my testdata is attached, yah.png is the source image I
tested with, blah0000.tmp is the one that was generated (and doesn't
open).
The program is really simple - I just dumped a timage, a button and a
topenpicturedialog on a form, and stuck this in as the button click
event:

//No try/except's here (I'm just testing an idea after all)

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);
         Image1.Picture.LoadFromFile(FN);
    end;
end;

And here is the content of unit simpleb64:
Function DecodeB64(S:String):String;

var
 b64decoder: TBase64DecodingStream;
 S1 : TSTringStream;
 S2 : TStringStream;
begin
S1 := TStringStream.Create(S);
S2 := TStringStream.Create(S);
  b64decoder := TBase64DecodingStream.Create(S1);
     Try
       S2.CopyFrom(b64decoder,b64decoder.Size);
     except
           //   blah
     end;
 S1.Free;
 Result := S2.DataString;
 S2.Free;
 b64decoder.Free;
end;

Function EncodeB64(S : String) : String;

Var
 S1,S2 : TStringStream;

begin
 S1:=TStringStream.Create(S);
 Try
   S1.Position:=0;
   S2:=TStringStream.Create('');
   Try
     With TBase64EncodingStream.Create(S2) do
       Try
         CopyFrom(S1,S1.Size);
       Finally
         Free;
       end;
     Result:=S2.DataString;
   finally
     S2.Free;
   end;
finally
  S1.Free;
end;
end;

On 5/16/07, Bram Kuijvenhoven <[EMAIL PROTECTED]> wrote:
Hi A.J.,

If you create a standalone demo program that:
- reads in an image file
- calls your Base64Encode function
- next calls your Base64Decode function (i.e. leave out the DB stuff)
- writes the result to an output file (which is damaged)
and attach the image file, then I will take a look at it.

And: which version of FPC do you use? Sometime ago I sent a patch for 
TBase64DecodingStream, which is in 2.1.x and trunk now, but not in 2.0.4.

Regards,

Bram

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



--
A.J. Venter
CEO - OutKast Solutions C.C.
http://www.outkastsolutions.co.za
Cell: +27 83 455 9978
Fax: +27 21 413 2800
Office: +27 21 591 6766

<<attachment: yah.png>>

<<attachment: blah00000.tmp.png>>

Reply via email to