[DUG] Jpg Image List
Alister Christie
alister at SalesPartner.co.nz
Thu Sep 22 14:50:02 NZST 2005
I think I've got things sorted here is some example code (it still needs
a lot of work for it to be useful).
I think my strategy will be to stream out a number of JpegImages and
then stream them back - which effectly get me a list of images.
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
WriteMultipleGraphics([Image2.Picture.Graphic, Image1.Picture.Graphic]);
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
ReadMultipleGraphics([Image1.Picture.Graphic, Image2.Picture.Graphic]);
end;
procedure TForm1.ReadMultipleGraphics(g: array of TGraphic);
var
ms : TMemoryStream;
fs : TFileStream;
i : integer;
size : integer;
begin
ms := TMemoryStream.Create;
fs := TFileStream.Create(MyFileName, fmOpenRead);
for i := low(g) to high(g) do
begin
ms.Clear;
fs.Read(Size, Sizeof(Size));
ms.CopyFrom(fs, Size);
ms.Position := 0;
g[i].LoadFromStream(ms);
end;
FreeAndNil(ms);
FreeAndNil(fs);
end;
procedure TForm1.WriteMultipleGraphics(g: array of TGraphic);
var
ms : TMemoryStream;
fs : TFileStream;
i : integer;
size : integer;
begin
ms := TMemoryStream.Create;
fs := TFileStream.Create(MyFileName, fmCreate);
for i := low(g) to high(g) do
begin
ms.Clear;
g[i].SaveToStream(ms);
size := ms.Size;
ms.Position := 0;
fs.Write(Size, Sizeof(Size));
ms.SaveToStream(fs);
end;
FreeAndNil(ms);
FreeAndNil(fs);
end;
Alister Christie
Computers for People
Ph: 04 471 1849 Fax: 04 471 1266
http://www.salespartner.co.nz
PO Box 13085
Johnsonville
Wellington
Jeremy North wrote:
> You could stream many instances of TJpegImage to a file though and
> read them back in. The ImageList is a windows control and it only
> supports bitmaps, regardless of what is in your uses clause.
>
>
>>Yes but a TList is not streamable. What I want to be able to achieve is
>>store a large number of JPEGImages efficiently in a single file.
>
>
> _______________________________________________
> Delphi mailing list
> Delphi at ns3.123.co.nz
> http://ns3.123.co.nz/mailman/listinfo/delphi
>
>
More information about the Delphi
mailing list