Changeset 33 for trunk/UProject.pas


Ignore:
Timestamp:
Jan 5, 2017, 11:48:36 PM (8 years ago)
Author:
chronos
Message:
  • Added: Remember last used image size and color format.
  • Added: Automatically create blank image.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UProject.pas

    r26 r33  
    99
    1010type
     11
     12  { TFloatPoint }
     13
     14  TFloatPoint = record
     15    X, Y: Double;
     16    function Create(AX, AY: Double): TFloatPoint;
     17  end;
    1118
    1219  { TView }
     
    2330    procedure Center(Rect: TRect);
    2431    constructor Create;
     32    procedure ZoomAll(BitmapSize: TPoint);
    2533    function DestToSrcPos(Pos: TPoint): TPoint;
    2634    function SrcToDestPos(Pos: TPoint): TPoint;
     
    4755  Result := (A.Left = B.Left) and (A.Top = B.Top) and
    4856    (A.Right = B.Right) and (A.Bottom = B.Bottom);
     57end;
     58
     59{ TFloatPoint }
     60
     61function TFloatPoint.Create(AX, AY: Double): TFloatPoint;
     62begin
     63  Result.X := AX;
     64  Result.Y := AY;
    4965end;
    5066
     
    102118end;
    103119
     120procedure TView.ZoomAll(BitmapSize: TPoint);
     121var
     122  Factor: TFloatPoint;
     123begin
     124  Factor := TFloatPoint.Create((DestRect.Right - DestRect.Left) / BitmapSize.X,
     125    (DestRect.Bottom - DestRect.Top) / BitmapSize.Y);
     126  if Factor.X < Factor.Y then Zoom := Factor.X
     127    else Zoom := Factor.Y;
     128  Center(Rect(0, 0, BitmapSize.X, BitmapSize.Y));
     129end;
     130
    104131function TView.DestToSrcPos(Pos: TPoint): TPoint;
    105132begin
Note: See TracChangeset for help on using the changeset viewer.