--- oup/rewrite/Tools/Preview.pas 2007/01/18 17:15:59 93 +++ oup/current/Tools/Preview.pas 2007/05/26 18:26:48 194 @@ -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) @@ -28,8 +28,9 @@ type procedure DrawImage(index: Integer); procedure SetBitmapCount(Count: Integer); procedure LoadImage(fileid, index: Integer); + procedure Splitter1Moved(Sender: TObject); private - bitmaps: array of TBitmap; + bitmaps: array of TOniImage; actualimg: Byte; _fileid: Integer; public @@ -40,12 +41,14 @@ var implementation {$R *.dfm} +uses Imaging, ImagingComponents, ImagingTypes, jpeg; procedure TForm_Preview.FormCreate(Sender: TObject); begin inherited; Self.OnNewFileSelected := NewFile; + SetBitmapCount(0); end; @@ -54,6 +57,7 @@ var ext: String; begin _fileid := fileinfo.ID; + SetBitmapCount(0); if _fileid >= 0 then begin lbl_notpossible.Visible := False; @@ -82,32 +86,14 @@ end; procedure TForm_Preview.LoadImage(fileid, index: Integer); -var - Data: Tdata; - 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, 1); end; @@ -126,11 +112,19 @@ begin i := Length(bitmaps); SetLength(bitmaps, Count); for i := i to High(bitmaps) do - bitmaps[i] := TBitmap.Create; + bitmaps[i] := TOniImage.Create; end; end; +procedure TForm_Preview.Splitter1Moved(Sender: TObject); +begin + inherited; + img.Picture.Assign(nil); + if Length(bitmaps) > 0 then + DrawImage(0); +end; + procedure TForm_Preview.PreviewImage; begin SetBitmapCount(1); @@ -142,16 +136,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; @@ -176,6 +170,8 @@ begin Self.timer.Enabled := not Self.timer.Enabled; Self.btn_dec.Enabled := not Self.timer.Enabled; Self.btn_inc.Enabled := not Self.timer.Enabled; + if self.timer.Enabled then + timerTimer(Self); if Self.timer.Enabled then Self.btn_startstop.Caption := 'Stop automatic' else @@ -189,7 +185,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 +197,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; @@ -216,4 +212,4 @@ end; begin AddToolListEntry('preview', 'Preview-Window', ''); -end. \ No newline at end of file +end.