Quote Originally Posted by Anonymous
Hi Sly,

this is the Decryption method:
Code:
function MyDecrypt(s: TStream): TStream;
var arrbyte: array of byte;
    i, size: Integer;
    r: byte;
    Key: Word;
begin
 size := s.Size; SetLength(arrbyte, size);
 s.Position := 0; s.Read(arrbyte[0], SizeOf(arrbyte[0]) * size);
 Key := password;
 for i := 0 to High(arrbyte) do // for every byte in the stream
 begin
  r := arrbyte[i];
  arrbyte[i] := arrbyte[i] xor (Key shr 8);
  Key := (r + Key) * C1 + C2;
 end;
 s.Position := 0; s.Write(arrbyte[0], SizeOf(arrbyte[0]) * size);
 result := s;
end;
I load an Imagelist like this:

ImageListEditor.ImageList.DecodeFunction := MyDecrypt;
imagelisteditor.ImageList.LoadFromFile('grafix\ima gelisteditor.oil');
Imagelisteditor.init;

Does this help?

Firle
That's going to be a huge timesink as well, plus it forces the use of TMemoryStream unless you want to write back over the same file you loaded from.

In your case, the LoadFromFile method will allocate 19MB and load the entire file into it. The DecodeFunction will then allocate another 19MB buffer, copy the entirity of the memory stream into that buffer, walk over every byte of that buffer, and copy the entire buffer back into the same stream that was passed in. Then it proceeds to save each image separately back to a memory stream and load the image back from the memory stream.

I'm at work now, so I cannot do any more stuff on the speed-up until I get home tonight. There is probably only so much that can be done with the existing file format. What it really needs is a new file format that does not go through the component streaming system.