--- oup/rewrite/Tools/Preview.pas 2007/01/18 17:18:19 94 +++ oup/current/Tools/Preview.pas 2007/05/24 17:48:18 192 @@ -3,7 +3,7 @@ interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Template, ExtCtrls, Math, StrUtils, - ConnectionManager, {OniImgClass,} Data, TypeDefs, Menus, Buttons; + ConnectionManager, OniImgClass, Data, TypeDefs, Menus, Buttons; type TForm_Preview = class(TForm_ToolTemplate) @@ -29,7 +29,7 @@ type procedure SetBitmapCount(Count: Integer); procedure LoadImage(fileid, index: Integer); private - bitmaps: array of TBitmap; + bitmaps: array of TOniImage; actualimg: Byte; _fileid: Integer; public @@ -40,6 +40,7 @@ var implementation {$R *.dfm} +uses Imaging, ImagingComponents, ImagingTypes; procedure TForm_Preview.FormCreate(Sender: TObject); @@ -82,32 +83,14 @@ end; procedure TForm_Preview.LoadImage(fileid, index: Integer); -var - Data: TByteArray; - memstream: TMemoryStream; - OniImage: TOniImage; - begin - OniImage := TOniImage.Create; - OniImage.Load(Connection, fileid); - Data := OniImage.GetAsBMP; - OniImage.Free; - - memstream := TMemoryStream.Create; - memstream.Write(Data[0], Length(Data)); - memstream.Seek(0, soFromBeginning); - bitmaps[index].LoadFromStream(memstream); - memstream.Free; + bitmaps[index].Load(ConnectionID, fileid); end; procedure TForm_Preview.DrawImage(index: Integer); begin - BitBlt(img.Canvas.Handle, 0, 0, img.Width, img.Height, - bitmaps[index].Canvas.Handle, 0, 0, WHITENESS); - BitBlt(img.Canvas.Handle, 0, 0, bitmaps[index].Width, bitmaps[index].Height, - bitmaps[index].Canvas.Handle, 0, 0, SRCCOPY); - img.Invalidate; + bitmaps[index].DrawOnCanvas(img.Canvas, 0); end; @@ -126,7 +109,7 @@ begin i := Length(bitmaps); SetLength(bitmaps, Count); for i := i to High(bitmaps) do - bitmaps[i] := TBitmap.Create; + bitmaps[i] := TOniImage.Create; end; end; @@ -142,16 +125,16 @@ end; procedure TForm_Preview.PreviewTXAN; var loop_speed: Word; - linkcount: LongWord; - link: LongWord; + linkcount: Integer; + link: Integer; i: Byte; begin - Connection.LoadDatFilePart(_fileid, $14, SizeOf(loop_speed), @loop_speed); - Connection.LoadDatFilePart(_fileid, $1C, SizeOf(linkcount), @linkcount); + ConManager.Connection[ConnectionID].LoadDatFilePart(_fileid, $14, SizeOf(loop_speed), @loop_speed); + ConManager.Connection[ConnectionID].LoadDatFilePart(_fileid, $1C, SizeOf(linkcount), @linkcount); SetBitmapCount(linkcount); for i := 0 to linkcount - 1 do begin - Connection.LoadDatFilePart(_fileid, $20 + i * 4, SizeOf(link), @link); + ConManager.Connection[ConnectionID].LoadDatFilePart(_fileid, $20 + i * 4, SizeOf(link), @link); link := link div 256; if link = 0 then link := _fileid - 1; @@ -189,7 +172,7 @@ begin Dec(actualimg) else actualimg := High(bitmaps); - Self.Caption := 'Preview ' + Connection.GetFileInfo(_fileid).FileName + + Self.Caption := 'Preview ' + ConManager.Connection[ConnectionID].GetFileInfo(_fileid).Name + ' (' + IntToStr(actualimg + 1) + '/' + IntToStr(Length(bitmaps)) + ')'; DrawImage(actualimg); end; @@ -201,7 +184,7 @@ begin Inc(actualimg) else actualimg := 0; - Self.Caption := 'Preview ' + Connection.GetFileInfo(_fileid).FileName + + Self.Caption := 'Preview ' + ConManager.Connection[ConnectionID].GetFileInfo(_fileid).Name + ' (' + IntToStr(actualimg + 1) + '/' + IntToStr(Length(bitmaps)) + ')'; DrawImage(actualimg); end;