Ignore:
Timestamp:
Apr 17, 2019, 12:58:41 AM (5 years ago)
Author:
chronos
Message:
  • Modified: Propagate project build mode options to used packages.
  • Added: Check memory leaks using heaptrc.
  • Modified: Update BGRABitmap package.
Location:
GraphicTest
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GraphicTest

    • Property svn:ignore
      •  

        old new  
        88GraphicTest.lps
        99GraphicTest.dbg
         10heaptrclog.trc
  • GraphicTest/Packages/bgrabitmap/bgrapen.pas

    r494 r521  
    1818
    1919type
     20  TPenJoinStyle = BGRAGraphics.TPenJoinStyle;
     21  TPenEndCap = BGRAGraphics.TPenEndCap;
    2022
    2123  { TBGRAPenStroker }
     
    5658      constructor Create;
    5759      destructor Destroy; override;
    58       function ComputePolyline(const APoints: array of TPointF; AWidth: single; AClosedCap: boolean = true): ArrayOfTPointF; override;
    59       function ComputePolyline(const APoints: array of TPointF; AWidth: single; APenColor: TBGRAPixel; AClosedCap: boolean = true): ArrayOfTPointF; override;
     60      function ComputePolyline(const APoints: array of TPointF; AWidth: single; AClosedCap: boolean = true): ArrayOfTPointF; overload; override;
     61      function ComputePolyline(const APoints: array of TPointF; AWidth: single; APenColor: TBGRAPixel; AClosedCap: boolean = true): ArrayOfTPointF; overload; override;
    6062      function ComputePolylineAutocycle(const APoints: array of TPointF; AWidth: single): ArrayOfTPointF; override;
    6163      function ComputePolygon(const APoints: array of TPointF; AWidth: single): ArrayOfTPointF; override;
     
    9193//antialiased version
    9294procedure BGRADrawLineAntialias({%H-}dest: TBGRACustomBitmap; x1, y1, x2, y2: integer;
    93   c: TBGRAPixel; DrawLastPixel: boolean; LinearBlend : boolean = false);
     95  c: TBGRAPixel; DrawLastPixel: boolean; LinearBlend : boolean = false); overload;
    9496procedure BGRAEraseLineAntialias(dest: TBGRACustomBitmap; x1, y1, x2, y2: integer;
    95   calpha: byte; DrawLastPixel: boolean);
     97  calpha: byte; DrawLastPixel: boolean); overload;
    9698
    9799//antialiased version with bicolor dashes (to draw a frame)
    98100procedure BGRADrawLineAntialias(dest: TBGRACustomBitmap; x1, y1, x2, y2: integer;
    99   c1, c2: TBGRAPixel; dashLen: integer; DrawLastPixel: boolean; var DashPos: integer; LinearBlend : boolean = false);
     101  c1, c2: TBGRAPixel; dashLen: integer; DrawLastPixel: boolean; var DashPos: integer; LinearBlend : boolean = false); overload;
    100102
    101103//length added to ensure accepable alpha join (using TBGRAMultishapeFiller is still better)
     
    110112function IsClearPenStyle(ACustomPenStyle: TBGRAPenStyle): boolean;
    111113function DuplicatePenStyle(ACustomPenStyle: array of single): TBGRAPenStyle;
     114function PenStyleEqual(AStyle1, AStyle2: TBGRAPenStyle): boolean;
     115function BGRAToPenStyle(ACustomPenStyle: TBGRAPenStyle): TPenStyle;
    112116
    113117implementation
     
    636640end;
    637641
     642function BGRAToPenStyle(ACustomPenStyle: TBGRAPenStyle): TPenStyle;
     643begin
     644  if IsSolidPenStyle(ACustomPenStyle) then exit(psSolid);
     645  if IsClearPenStyle(ACustomPenStyle) then exit(psClear);
     646  if PenStyleEqual(ACustomPenStyle, DashPenStyle) then exit(psDash);
     647  if PenStyleEqual(ACustomPenStyle, DotPenStyle) then exit(psDot);
     648  if PenStyleEqual(ACustomPenStyle, DashDotPenStyle) then exit(psDashDot);
     649  if PenStyleEqual(ACustomPenStyle, DashDotDotPenStyle) then exit(psDashDotDot);
     650  exit(psPattern);
     651end;
     652
     653function PenStyleEqual(AStyle1, AStyle2: TBGRAPenStyle): boolean;
     654var
     655  i: Integer;
     656begin
     657  if length(AStyle1)<>length(AStyle2) then exit(false);
     658  for i := 0 to high(AStyle1) do
     659    if AStyle1[i] <> AStyle2[i] then exit(false);
     660  exit(true);
     661end;
     662
    638663procedure ApplyPenStyle(const leftPts, rightPts: array of TPointF; const penstyle: TBGRAPenStyle;
    639664    width: single; var posstyle: single; out styledPts: ArrayOfTPointF);
     
    658683  begin
    659684    dashStartIndex := index;
    660     dashLeftStartPos := leftPts[index] + (leftPts[index+1]-leftPts[index])*t;
    661     dashRightStartPos := rightPts[index] + (rightPts[index+1]-rightPts[index])*t;
     685    if t = 0 then
     686    begin
     687      dashLeftStartPos := leftPts[index];
     688      dashRightStartPos := rightPts[index];
     689    end else
     690    begin
     691      dashLeftStartPos := leftPts[index] + (leftPts[index+1]-leftPts[index])*t;
     692      dashRightStartPos := rightPts[index] + (rightPts[index+1]-rightPts[index])*t;
     693    end;
    662694    betweenDash := false;
    663695  end;
Note: See TracChangeset for help on using the changeset viewer.