Changeset 202 for GraphicTest/UMainForm.pas
- Timestamp:
- Mar 17, 2011, 9:38:21 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest/UMainForm.pas
r201 r202 44 44 private 45 45 public 46 DrawMethod : TDrawMethod;46 DrawMethods: TObjectList; // TObjectList<TDrawMethod> 47 47 Bitmap: TBitmap; 48 48 Scenes: TObjectList; // TObjectList<TFastBitmap> … … 62 62 var 63 63 NewScene: TFastBitmap; 64 NewDrawMethod: TDrawMethod; 64 65 I: Integer; 65 66 begin … … 77 78 Image1.Picture.Bitmap.SetSize(TFastBitmap(Scenes[0]).Size.X, TFastBitmap(Scenes[0]).Size.Y); 78 79 Bitmap.SetSize(TFastBitmap(Scenes[0]).Size.X, TFastBitmap(Scenes[0]).Size.Y); 80 81 DrawMethods := TObjectList.Create; 82 ComboBox1.Clear; 83 for I := 0 to High(DrawMethodClasses) do begin 84 NewDrawMethod := DrawMethodClasses[I].Create; 85 NewDrawMethod.Bitmap := Image1.Picture.Bitmap; 86 NewDrawMethod.PaintBox := PaintBox1; 87 DrawMethods.Add(NewDrawMethod); 88 ComboBox1.Items.Add(NewDrawMethod.Caption); 89 end; 79 90 ComboBox1.ItemIndex := 0; 80 91 end; … … 85 96 ButtonStart.Enabled := False; 86 97 Timer1.Enabled := True; 87 DrawMethod.Free; 88 if ComboBox1.ItemIndex >= 0 then begin 89 DrawMethod := DrawMethodClasses[ComboBox1.ItemIndex].Create; 90 DrawMethod.Bitmap := Image1.Picture.Bitmap; 91 DrawMethod.Bitmap.SetSize(Image1.Picture.Bitmap.Width, Image1.Picture.Bitmap.Height); 98 if ComboBox1.ItemIndex >= 0 then 99 with TDrawMethod(DrawMethods[ComboBox1.ItemIndex]) do begin 92 100 repeat 93 Draw Method.DrawFrameTiming(TFastBitmap(Scenes[SceneIndex]));101 DrawFrameTiming(TFastBitmap(Scenes[SceneIndex])); 94 102 SceneIndex := (SceneIndex + 1) mod Scenes.Count; 95 103 Application.ProcessMessages; … … 108 116 BeginUpdate; 109 117 Clear; 110 for I := 0 to High(DrawMethodClasses) do begin 111 DrawMethod.Free; 112 DrawMethod := DrawMethodClasses[I].Create; 113 DrawMethod.Bitmap := Image1.Picture.Bitmap; 114 DrawMethod.Bitmap.SetSize(Image1.Picture.Bitmap.Width, Image1.Picture.Bitmap.Height); 115 DrawMethod.DrawFrameTiming(TFastBitmap(Scenes[0])); 118 for I := 0 to DrawMethods.Count - 1 do 119 with TDrawMethod(DrawMethods[I]) do begin 120 DrawFrameTiming(TFastBitmap(Scenes[0])); 121 DrawFrameTiming(TFastBitmap(Scenes[0])); 116 122 NewItem := Add; 117 NewItem.Caption := DrawMethod.Caption;118 NewItem.SubItems.Add(FloatToStr(RoundTo( DrawMethod.FrameDuration / OneMillisecond, -3)));119 NewItem.SubItems.Add(FloatToStr(RoundTo(1 / ( DrawMethod.FrameDuration / OneSecond), -3)));123 NewItem.Caption := Caption; 124 NewItem.SubItems.Add(FloatToStr(RoundTo(FrameDuration / OneMillisecond, -3))); 125 NewItem.SubItems.Add(FloatToStr(RoundTo(1 / (FrameDuration / OneSecond), -3))); 120 126 end; 121 127 finally … … 137 143 procedure TMainForm.FormDestroy(Sender: TObject); 138 144 begin 145 DrawMethods.Free; 139 146 Scenes.Free; 140 147 Bitmap.Free; … … 143 150 procedure TMainForm.Timer1Timer(Sender: TObject); 144 151 begin 145 if Assigned(DrawMethod) then begin 146 if (DrawMethod.FrameDuration > 0) then 147 Label2.Caption := FloatToStr(RoundTo(1 / (DrawMethod.FrameDuration / OneSecond), -3)) 152 if (ComboBox1.ItemIndex >= 0) then 153 with TDrawMethod(DrawMethods[ComboBox1.ItemIndex]) do begin 154 if (FrameDuration > 0) then 155 Label2.Caption := FloatToStr(RoundTo(1 / (FrameDuration / OneSecond), -3)) 148 156 else Label2.Caption := '0'; 149 Label4.Caption := FloatToStr(RoundTo( DrawMethod.FrameDuration / OneMillisecond, -3)) + ' ms';157 Label4.Caption := FloatToStr(RoundTo(FrameDuration / OneMillisecond, -3)) + ' ms'; 150 158 end; 151 159 end;
Note:
See TracChangeset
for help on using the changeset viewer.