Ignore:
Timestamp:
Mar 17, 2011, 9:38:21 AM (14 years ago)
Author:
george
Message:
  • Added: TBGRABitmap.ScanLine method.
  • Modified: All draw methods objects are allocated on program creation now.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GraphicTest/UMainForm.pas

    r201 r202  
    4444  private
    4545  public
    46     DrawMethod: TDrawMethod;
     46    DrawMethods: TObjectList; // TObjectList<TDrawMethod>
    4747    Bitmap: TBitmap;
    4848    Scenes: TObjectList; // TObjectList<TFastBitmap>
     
    6262var
    6363  NewScene: TFastBitmap;
     64  NewDrawMethod: TDrawMethod;
    6465  I: Integer;
    6566begin
     
    7778  Image1.Picture.Bitmap.SetSize(TFastBitmap(Scenes[0]).Size.X, TFastBitmap(Scenes[0]).Size.Y);
    7879  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;
    7990  ComboBox1.ItemIndex := 0;
    8091end;
     
    8596  ButtonStart.Enabled := False;
    8697  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
    92100    repeat
    93       DrawMethod.DrawFrameTiming(TFastBitmap(Scenes[SceneIndex]));
     101      DrawFrameTiming(TFastBitmap(Scenes[SceneIndex]));
    94102      SceneIndex := (SceneIndex + 1) mod Scenes.Count;
    95103      Application.ProcessMessages;
     
    108116    BeginUpdate;
    109117    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]));
    116122      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)));
    120126    end;
    121127  finally
     
    137143procedure TMainForm.FormDestroy(Sender: TObject);
    138144begin
     145  DrawMethods.Free;
    139146  Scenes.Free;
    140147  Bitmap.Free;
     
    143150procedure TMainForm.Timer1Timer(Sender: TObject);
    144151begin
    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))
    148156      else Label2.Caption := '0';
    149     Label4.Caption := FloatToStr(RoundTo(DrawMethod.FrameDuration / OneMillisecond, -3)) + ' ms';
     157    Label4.Caption := FloatToStr(RoundTo(FrameDuration / OneMillisecond, -3)) + ' ms';
    150158  end;
    151159end;
Note: See TracChangeset for help on using the changeset viewer.