Changeset 521 for GraphicTest/Packages/bgrabitmap/bgradefaultbitmap.pas
- Timestamp:
- Apr 17, 2019, 12:58:41 AM (5 years ago)
- Location:
- GraphicTest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest
- Property svn:ignore
-
old new 8 8 GraphicTest.lps 9 9 GraphicTest.dbg 10 heaptrclog.trc
-
- Property svn:ignore
-
GraphicTest/Packages/bgrabitmap/bgradefaultbitmap.pas
r494 r521 34 34 uses 35 35 SysUtils, Classes, Types, FPImage, BGRAGraphics, BGRABitmapTypes, FPImgCanv, 36 BGRACanvas, BGRACanvas2D, BGRAArrow, BGRAPen, BGRATransform ;36 BGRACanvas, BGRACanvas2D, BGRAArrow, BGRAPen, BGRATransform, BGRATextBidi; 37 37 38 38 type … … 59 59 gtype: TGradientType; o1, o2: TPointF; mode: TDrawMode; 60 60 gammaColorCorrection: boolean = True; Sinus: Boolean=False; 61 ditherAlgo: TDitheringAlgorithm = daFloydSteinberg); 61 ditherAlgo: TDitheringAlgorithm = daFloydSteinberg); overload; 62 62 procedure GradientFillDithered(x, y, x2, y2: integer; gradient: TBGRACustomGradient; 63 63 gtype: TGradientType; o1, o2: TPointF; mode: TDrawMode; 64 64 Sinus: Boolean=False; 65 ditherAlgo: TDitheringAlgorithm = daFloydSteinberg); 65 ditherAlgo: TDitheringAlgorithm = daFloydSteinberg); overload; 66 66 protected 67 67 FRefCount: integer; //reference counter (not related to interface reference counter) … … 152 152 function SimpleStretch(NewWidth, NewHeight: integer): TBGRACustomBitmap; 153 153 function CheckEmpty: boolean; override; 154 function CheckIsZero: boolean; override; 154 155 function GetHasTransparentPixels: boolean; override; 156 function GetHasSemiTransparentPixels: boolean; override; 155 157 function GetAverageColor: TColor; override; 156 158 function GetAveragePixel: TBGRAPixel; override; … … 190 192 procedure SetFontRenderer(AValue: TBGRACustomFontRenderer); override; 191 193 function CreateDefaultFontRenderer: TBGRACustomFontRenderer; virtual; abstract; 192 function GetFont AnchorVerticalOffset: single;193 function GetFontAnchorRotatedOffset: TPointF; 194 function GetFontAnchorRotatedOffset(ACustomOrientation: integer): TPointF; 194 function GetFontVerticalAnchorOffset: single; override; 195 function GetFontAnchorRotatedOffset: TPointF; overload; 196 function GetFontAnchorRotatedOffset(ACustomOrientation: integer): TPointF; overload; 195 197 196 198 function GetClipRect: TRect; override; … … 201 203 function GetArrow: TBGRAArrow; 202 204 procedure InternalTextOutCurved(ACursor: TBGRACustomPathCursor; sUTF8: string; AColor: TBGRAPixel; ATexture: IBGRAScanner; AAlign: TAlignment; ALetterSpacing: single); 205 procedure InternalCrossFade(ARect: TRect; Source1, Source2: IBGRAScanner; AFadePos: byte; AFadeMask: IBGRAScanner; mode: TDrawMode = dmDrawWithTransparency); 203 206 204 207 function CheckClippedRectBounds(var x,y,x2,y2: integer): boolean; … … 227 230 function GetUnique: TBGRACustomBitmap; 228 231 232 { ** Allocate xor mask } 233 procedure NeedXorMask; override; 234 235 { ** Free reference to xor mask } 236 procedure DiscardXorMask; override; 237 229 238 {==== Constructors ====} 230 239 231 240 {------------------------- Constructors from TFPCustomImage----------------} 232 241 {** Creates a new bitmap, initialize properties and bitmap data } 233 constructor Create(AWidth, AHeight: integer); over ride;242 constructor Create(AWidth, AHeight: integer); overload; override; 234 243 {** Can only be called with an existing instance of ''TBGRABitmap''. 235 244 Sets the dimensions of an existing ''TBGRABitmap'' instance. } … … 239 248 {** Creates an image of width and height equal to zero. In this case, 240 249 ''Data'' = '''nil''' } 241 constructor Create; over ride;250 constructor Create; overload; override; 242 251 {** Creates an image by copying the content of a ''TFPCustomImage'' } 243 constructor Create(AFPImage: TFPCustomImage); over ride;252 constructor Create(AFPImage: TFPCustomImage); overload; override; 244 253 {** Creates an image by copying the content of a ''TBitmap'' } 245 constructor Create(ABitmap: TBitmap; AUseTransparent: boolean = true); over ride;254 constructor Create(ABitmap: TBitmap; AUseTransparent: boolean = true); overload; override; 246 255 {** Creates an image of dimensions ''AWidth'' and ''AHeight'' and fills it with the opaque color ''Color'' } 247 constructor Create(AWidth, AHeight: integer; Color: TColor); over ride;256 constructor Create(AWidth, AHeight: integer; Color: TColor); overload; override; 248 257 {** Creates an image of dimensions ''AWidth'' and ''AHeight'' and fills it with ''Color'' } 249 constructor Create(AWidth, AHeight: integer; Color: TBGRAPixel); over ride;258 constructor Create(AWidth, AHeight: integer; Color: TBGRAPixel); overload; override; 250 259 251 260 {** Creates an image by loading its content from the file ''AFilename''. 252 261 The encoding of the string is the default one for the operating system. 253 262 It is recommended to use the next constructor and UTF8 encoding } 254 constructor Create(AFilename: string); over ride;263 constructor Create(AFilename: string); overload; override; 255 264 256 265 {** Creates an image by loading its content from the file ''AFilename''. 257 266 The boolean ''AIsUtf8Filename'' specifies if UTF8 encoding is assumed 258 267 for the filename } 259 constructor Create(AFilename: string; AIsUtf8: boolean); over ride;260 constructor Create(AFilename: string; AIsUtf8: boolean; AOptions: TBGRALoadingOptions); over ride;268 constructor Create(AFilename: string; AIsUtf8: boolean); overload; override; 269 constructor Create(AFilename: string; AIsUtf8: boolean; AOptions: TBGRALoadingOptions); overload; override; 261 270 262 271 {** Creates an image by loading its content from the stream ''AStream'' } 263 constructor Create(AStream: TStream); over ride;272 constructor Create(AStream: TStream); overload; override; 264 273 {** Free the object and all its resources } 265 274 destructor Destroy; override; … … 269 278 Creates a new instance with dimensions ''AWidth'' and ''AHeight'', 270 279 containing transparent pixels. } 271 function NewBitmap(AWidth, AHeight: integer): TBGRACustomBitmap; over ride;280 function NewBitmap(AWidth, AHeight: integer): TBGRACustomBitmap; overload; override; 272 281 273 282 {** Can only be called from an existing instance of ''TBGRABitmap''. 274 283 Creates a new instance with dimensions ''AWidth'' and ''AHeight'', 275 284 and fills it with Color } 276 function NewBitmap(AWidth, AHeight: integer; Color: TBGRAPixel): TBGRACustomBitmap; over ride;285 function NewBitmap(AWidth, AHeight: integer; Color: TBGRAPixel): TBGRACustomBitmap; overload; override; 277 286 278 287 {** Can only be called from an existing instance of ''TBGRABitmap''. … … 280 289 from the file ''Filename''. The encoding of the string 281 290 is the default one for the operating system } 282 function NewBitmap(Filename: string): TBGRACustomBitmap; over ride;291 function NewBitmap(Filename: string): TBGRACustomBitmap; overload; override; 283 292 284 293 {** Can only be called from an existing instance of ''TBGRABitmap''. 285 294 Creates a new instance with by loading its content 286 295 from the file ''Filename'' } 287 function NewBitmap(Filename: string; AIsUtf8: boolean): TBGRACustomBitmap; over ride;288 function NewBitmap(Filename: string; AIsUtf8: boolean; AOptions: TBGRALoadingOptions): TBGRACustomBitmap; over ride;296 function NewBitmap(Filename: string; AIsUtf8: boolean): TBGRACustomBitmap; overload; override; 297 function NewBitmap(Filename: string; AIsUtf8: boolean; AOptions: TBGRALoadingOptions): TBGRACustomBitmap; overload; override; 289 298 290 299 {** Can only be called from an existing instance of ''TBGRABitmap''. 291 300 Creates an image by copying the content of a ''TFPCustomImage'' } 292 function NewBitmap(AFPImage: TFPCustomImage): TBGRACustomBitmap; over ride;301 function NewBitmap(AFPImage: TFPCustomImage): TBGRACustomBitmap; overload; override; 293 302 294 303 {** Load image from a stream. The specified image reader is used } 295 procedure LoadFromStream(Str: TStream; Handler: TFPCustomImageReader; AOptions: TBGRALoadingOptions); override; 304 procedure LoadFromStream(Str: TStream; Handler: TFPCustomImageReader; AOptions: TBGRALoadingOptions); overload; override; 305 306 {** Load image from an embedded Lazarus resource. Format is detected automatically } 307 procedure LoadFromResource(AFilename: string; AOptions: TBGRALoadingOptions); overload; override; 296 308 297 309 {** Assign the content of the specified ''Source''. It can be a ''TBGRACustomBitmap'' or 298 310 a ''TFPCustomImage'' } 299 procedure Assign(Source: TPersistent); over ride;311 procedure Assign(Source: TPersistent); overload; override; 300 312 procedure Assign(Source: TBitmap; AUseTransparent: boolean); overload; 301 313 {** Stores the image in the stream without compression nor header } … … 322 334 {** Sets the pixel by replacing the content at (''x'',''y'') with the specified color. 323 335 Alpha value is set to 255 (opaque) } 324 procedure SetPixel(x, y: int32or64; c: TColor); over ride;336 procedure SetPixel(x, y: int32or64; c: TColor); overload; override; 325 337 {** Sets the pixel at (''x'',''y'') with the specified content } 326 procedure SetPixel(x, y: int32or64; c: TBGRAPixel); over ride;338 procedure SetPixel(x, y: int32or64; c: TBGRAPixel); overload; override; 327 339 {** Applies a logical '''xor''' to the content of the pixel with the specified value. 328 340 This includes the alpha channel, so if you want to preserve the opacity, provide … … 371 383 * ''AResampleFilter'' specifies how pixels must be interpolated. Accepted 372 384 values are ''rfBox'', ''rfLinear'', ''rfHalfCosine'' and ''rfCosine'' } 373 function GetPixelCycle(x, y: single; AResampleFilter: TResampleFilter = rfLinear): TBGRAPixel; over ride;385 function GetPixelCycle(x, y: single; AResampleFilter: TResampleFilter = rfLinear): TBGRAPixel; overload; override; 374 386 {** Similar to previous ''GetPixel'' function, but the fractional part of 375 387 the coordinate is supplied with a number from 0 to 255. The actual 376 388 coordinate is (''x'' + ''fracX256''/256, ''y'' + ''fracY256''/256) } 377 function GetPixelCycle256(x, y, fracX256,fracY256: int32or64; AResampleFilter: TResampleFilter = rfLinear): TBGRAPixel; over ride;389 function GetPixelCycle256(x, y, fracX256,fracY256: int32or64; AResampleFilter: TResampleFilter = rfLinear): TBGRAPixel; overload; override; 378 390 {** Computes the value of the pixel at a floating point coordiante 379 391 by interpolating the values of the pixels around it. ''repeatX'' and … … 381 393 * ''AResampleFilter'' specifies how pixels must be interpolated. Accepted 382 394 values are ''rfBox'', ''rfLinear'', ''rfHalfCosine'' and ''rfCosine'' } 383 function GetPixelCycle(x, y: single; AResampleFilter: TResampleFilter; repeatX: boolean; repeatY: boolean): TBGRAPixel; over ride;395 function GetPixelCycle(x, y: single; AResampleFilter: TResampleFilter; repeatX: boolean; repeatY: boolean): TBGRAPixel; overload; override; 384 396 {** Similar to previous ''GetPixel'' function, but the fractional part of 385 397 the coordinate is supplied with a number from 0 to 255. The actual 386 398 coordinate is (''x'' + ''fracX256''/256, ''y'' + ''fracY256''/256) } 387 function GetPixelCycle256(x, y, fracX256,fracY256: int32or64; AResampleFilter: TResampleFilter; repeatX: boolean; repeatY: boolean): TBGRAPixel; over ride;399 function GetPixelCycle256(x, y, fracX256,fracY256: int32or64; AResampleFilter: TResampleFilter; repeatX: boolean; repeatY: boolean): TBGRAPixel; overload; override; 388 400 389 401 {==== Drawing lines and polylines (integer coordinates) ====} … … 452 464 {** Draws an antialiased line from (x1,y1) to (x2,y2) using an improved version of Bresenham's algorithm 453 465 ''c'' specifies the color. ''DrawLastPixel'' specifies if (x2,y2) must be drawn } 454 procedure DrawLineAntialias(x1, y1, x2, y2: integer; c: TBGRAPixel; DrawLastPixel: boolean); over ride;466 procedure DrawLineAntialias(x1, y1, x2, y2: integer; c: TBGRAPixel; DrawLastPixel: boolean); overload; override; 455 467 {** Draws an antialiased line with two colors ''c1'' and ''c2'' as dashes of lenght ''dashLen'' } 456 procedure DrawLineAntialias(x1, y1, x2, y2: integer; c1, c2: TBGRAPixel; dashLen: integer; DrawLastPixel: boolean); over ride;468 procedure DrawLineAntialias(x1, y1, x2, y2: integer; c1, c2: TBGRAPixel; dashLen: integer; DrawLastPixel: boolean); overload; override; 457 469 {** Draws an antialiased line with two colors ''c1'' and ''c2'' as dashes of lenght ''dashLen''. 458 470 ''DashPos'' can be used to specify the start dash position and to retrieve the dash position at the end … … 477 489 478 490 {** Draws a line from (x1,y1) to (x2,y2) using current pen style/cap/join } 479 procedure DrawLineAntialias(x1, y1, x2, y2: single; c: TBGRAPixel; w: single); over ride;491 procedure DrawLineAntialias(x1, y1, x2, y2: single; c: TBGRAPixel; w: single); overload; override; 480 492 {** Draws a line from (x1,y1) to (x2,y2) using current pen style/cap/join. 481 493 ''texture'' specifies the source color to use when filling the line } 482 procedure DrawLineAntialias(x1, y1, x2, y2: single; texture: IBGRAScanner; w: single); over ride;494 procedure DrawLineAntialias(x1, y1, x2, y2: single; texture: IBGRAScanner; w: single); overload; override; 483 495 {** Draws a line from (x1,y1) to (x2,y2) using current pen style/cap/join. 484 496 ''Closed'' specifies if the end of the line is closed. If it is not closed, 485 497 a space is left so that the next line can fit } 486 procedure DrawLineAntialias(x1, y1, x2, y2: single; c: TBGRAPixel; w: single; ClosedCap: boolean); over ride;498 procedure DrawLineAntialias(x1, y1, x2, y2: single; c: TBGRAPixel; w: single; ClosedCap: boolean); overload; override; 487 499 {** Same as above with ''texture'' specifying the source color to use when filling the line } 488 procedure DrawLineAntialias(x1, y1, x2, y2: single; texture: IBGRAScanner; w: single; ClosedCap: boolean); over ride;500 procedure DrawLineAntialias(x1, y1, x2, y2: single; texture: IBGRAScanner; w: single; ClosedCap: boolean); overload; override; 489 501 490 502 {** Draws a polyline using current pen style/cap/join } 491 procedure DrawPolyLineAntialias(const points: array of TPointF; c: TBGRAPixel; w: single); over ride;503 procedure DrawPolyLineAntialias(const points: array of TPointF; c: TBGRAPixel; w: single); overload; override; 492 504 {** Draws a polyline using current pen style/cap/join. 493 505 ''texture'' specifies the source color to use when filling the line } 494 procedure DrawPolyLineAntialias(const points: array of TPointF; texture: IBGRAScanner; w: single); over ride;506 procedure DrawPolyLineAntialias(const points: array of TPointF; texture: IBGRAScanner; w: single); overload; override; 495 507 {** Draws a polyline using current pen style/cap/join. 496 508 ''Closed'' specifies if the end of the line is closed. If it is not closed, 497 509 a space is left so that the next line can fit } 498 procedure DrawPolyLineAntialias(const points: array of TPointF; c: TBGRAPixel; w: single; ClosedCap: boolean); over ride;499 procedure DrawPolyLineAntialias(const points: array of TPointF; texture: IBGRAScanner; w: single; ClosedCap: boolean); over ride;510 procedure DrawPolyLineAntialias(const points: array of TPointF; c: TBGRAPixel; w: single; ClosedCap: boolean); overload; override; 511 procedure DrawPolyLineAntialias(const points: array of TPointF; texture: IBGRAScanner; w: single; ClosedCap: boolean); overload; override; 500 512 {** Draws a polyline using current pen style/cap/join. 501 513 ''fillcolor'' specifies a color to fill the polygon formed by the points } 502 procedure DrawPolyLineAntialias(const points: array of TPointF; c: TBGRAPixel; w: single; fillcolor: TBGRAPixel); over ride;514 procedure DrawPolyLineAntialias(const points: array of TPointF; c: TBGRAPixel; w: single; fillcolor: TBGRAPixel); overload; override; 503 515 {** Draws a polyline using current pen style/cap/join. 504 516 The last point considered as a join with the first point if it has … … 509 521 The polygon is always closed. You don't need to set the last point 510 522 to be the same as the first point } 511 procedure DrawPolygonAntialias(const points: array of TPointF; c: TBGRAPixel; w: single); over ride;523 procedure DrawPolygonAntialias(const points: array of TPointF; c: TBGRAPixel; w: single); overload; override; 512 524 {** Draws a polygon using current pen style/cap/join. 513 525 The polygon is always closed. You don't need to set the last point 514 526 to be the same as the first point } 515 procedure DrawPolygonAntialias(const points: array of TPointF; texture: IBGRAScanner; w: single); over ride;527 procedure DrawPolygonAntialias(const points: array of TPointF; texture: IBGRAScanner; w: single); overload; override; 516 528 {** Draws a filled polygon using current pen style/cap/join. 517 529 The polygon is always closed. You don't need to set the last point 518 530 to be the same as the first point. } 519 procedure DrawPolygonAntialias(const points: array of TPointF; c: TBGRAPixel; w: single; fillcolor: TBGRAPixel); over ride;531 procedure DrawPolygonAntialias(const points: array of TPointF; c: TBGRAPixel; w: single; fillcolor: TBGRAPixel); overload; override; 520 532 521 533 {** Erases a line from (x1,y1) to (x2,y2) using current pen style/cap/join } … … 538 550 {** Draw a size border of a rectangle, 539 551 using the specified ''mode'' } 540 procedure Rectangle(x, y, x2, y2: integer; c: TBGRAPixel; mode: TDrawMode); over ride;552 procedure Rectangle(x, y, x2, y2: integer; c: TBGRAPixel; mode: TDrawMode); overload; override; 541 553 {** Draw a filled rectangle with a border of color ''BorderColor'', 542 554 using the specified ''mode'' } 543 procedure Rectangle(x, y, x2, y2: integer; BorderColor, FillColor: TBGRAPixel; mode: TDrawMode); over ride;555 procedure Rectangle(x, y, x2, y2: integer; BorderColor, FillColor: TBGRAPixel; mode: TDrawMode); overload; override; 544 556 {** Fills completely a rectangle, without any border, with the specified ''mode'' } 545 procedure FillRect(x, y, x2, y2: integer; c: TBGRAPixel; mode: TDrawMode); over ride; overload;557 procedure FillRect(x, y, x2, y2: integer; c: TBGRAPixel; mode: TDrawMode); overload; override; 546 558 {** Fills completely a rectangle, without any border, with the specified ''texture'' and 547 559 with the specified ''mode'' } 548 procedure FillRect(x, y, x2, y2: integer; texture: IBGRAScanner; mode: TDrawMode; AScanOffset: TPoint); over ride; overload;549 procedure FillRect(x, y, x2, y2: integer; texture: IBGRAScanner; mode: TDrawMode; AScanOffset: TPoint; ditheringAlgorithm: TDitheringAlgorithm); over ride; overload;560 procedure FillRect(x, y, x2, y2: integer; texture: IBGRAScanner; mode: TDrawMode; AScanOffset: TPoint); overload; override; 561 procedure FillRect(x, y, x2, y2: integer; texture: IBGRAScanner; mode: TDrawMode; AScanOffset: TPoint; ditheringAlgorithm: TDitheringAlgorithm); overload; override; 550 562 {** Sets the alpha value within the specified rectangle } 551 563 procedure AlphaFillRect(x, y, x2, y2: integer; alpha: byte); override; … … 554 566 {** Draws a round rectangle, with corners having an elliptical diameter of ''DX'' and ''DY'' } 555 567 procedure RoundRect(X1, Y1, X2, Y2: integer; DX, DY: integer; BorderColor: TBGRAPixel; ADrawMode: TDrawMode = dmDrawWithTransparency); override; 568 procedure FillRoundRect(X1, Y1, X2, Y2: integer; DX, DY: integer; FillTexture: IBGRAScanner; ADrawMode: TDrawMode = dmDrawWithTransparency); override; overload; 556 569 557 570 {==== Rectangles and ellipses (floating point coordinates) ====} … … 572 585 {** Fills a rectangle with antialiasing. For example (-0.5,-0.5,0.5,0.5) 573 586 fills one pixel } 574 procedure FillRectAntialias(x, y, x2, y2: single; c: TBGRAPixel; pixelCenteredCoordinates: boolean = true); over ride;587 procedure FillRectAntialias(x, y, x2, y2: single; c: TBGRAPixel; pixelCenteredCoordinates: boolean = true); overload; override; 575 588 {** Fills a rectangle with a texture } 576 procedure FillRectAntialias(x, y, x2, y2: single; texture: IBGRAScanner; pixelCenteredCoordinates: boolean = true); over ride;589 procedure FillRectAntialias(x, y, x2, y2: single; texture: IBGRAScanner; pixelCenteredCoordinates: boolean = true); overload; override; 577 590 {** Erases the content of a rectangle with antialiasing } 578 591 procedure EraseRectAntialias(x, y, x2, y2: single; alpha: byte; pixelCenteredCoordinates: boolean = true); override; … … 581 594 elliptical radius of ''rx'' and ''ry''. ''options'' specifies how to 582 595 draw the corners. See [[BGRABitmap Geometry types|geometry types]] } 583 procedure RoundRectAntialias(x,y,x2,y2,rx,ry: single; c: TBGRAPixel; w: single; options: TRoundRectangleOptions = []); over ride;596 procedure RoundRectAntialias(x,y,x2,y2,rx,ry: single; c: TBGRAPixel; w: single; options: TRoundRectangleOptions = []); overload; override; 584 597 {** Draws a rounded rectangle border with the specified texture. 585 598 The corners have an elliptical radius of ''rx'' and ''ry''. 586 599 ''options'' specifies how to draw the corners. 587 600 See [[BGRABitmap Geometry types|geometry types]] } 588 procedure RoundRectAntialias(x,y,x2,y2,rx,ry: single; texture: IBGRAScanner; w: single; options: TRoundRectangleOptions = []); over ride;601 procedure RoundRectAntialias(x,y,x2,y2,rx,ry: single; texture: IBGRAScanner; w: single; options: TRoundRectangleOptions = []); overload; override; 589 602 {** Draws and fills a round rectangle } 590 procedure RoundRectAntialias(x,y,x2,y2,rx,ry: single; pencolor: TBGRAPixel; w: single; fillcolor: TBGRAPixel; options: TRoundRectangleOptions = []); over ride;603 procedure RoundRectAntialias(x,y,x2,y2,rx,ry: single; pencolor: TBGRAPixel; w: single; fillcolor: TBGRAPixel; options: TRoundRectangleOptions = []); overload; override; 591 604 {** Draws and fills a round rectangle with textures } 592 procedure RoundRectAntialias(x,y,x2,y2,rx,ry: single; penTexture: IBGRAScanner; w: single; fillTexture: IBGRAScanner; options: TRoundRectangleOptions = []); over ride;605 procedure RoundRectAntialias(x,y,x2,y2,rx,ry: single; penTexture: IBGRAScanner; w: single; fillTexture: IBGRAScanner; options: TRoundRectangleOptions = []); overload; override; 593 606 594 607 {** Fills a rounded rectangle with antialiasing. The corners have an 595 608 elliptical radius of ''rx'' and ''ry''. ''options'' specifies how to 596 609 draw the corners. See [[BGRABitmap Geometry types|geometry types]] } 597 procedure FillRoundRectAntialias(x,y,x2,y2,rx,ry: single; c: TBGRAPixel; options: TRoundRectangleOptions = []; pixelCenteredCoordinates: boolean = true); over ride;610 procedure FillRoundRectAntialias(x,y,x2,y2,rx,ry: single; c: TBGRAPixel; options: TRoundRectangleOptions = []; pixelCenteredCoordinates: boolean = true); overload; override; 598 611 {** Fills a rounded rectangle with a texture } 599 procedure FillRoundRectAntialias(x,y,x2,y2,rx,ry: single; texture: IBGRAScanner; options: TRoundRectangleOptions = []; pixelCenteredCoordinates: boolean = true); over ride;612 procedure FillRoundRectAntialias(x,y,x2,y2,rx,ry: single; texture: IBGRAScanner; options: TRoundRectangleOptions = []; pixelCenteredCoordinates: boolean = true); overload; override; 600 613 {** Erases the content of a rounded rectangle with a texture } 601 procedure EraseRoundRectAntialias(x,y,x2,y2,rx,ry: single; alpha: byte; options: TRoundRectangleOptions = []; pixelCenteredCoordinates: boolean = true); override; 602 614 procedure EraseRoundRectAntialias(x,y,x2,y2,rx,ry: single; alpha: byte; options: TRoundRectangleOptions = []; pixelCenteredCoordinates: boolean = true); overload; override; 615 616 {** Draws an ellipse without antialising. ''rx'' is the horizontal radius and 617 ''ry'' the vertical radius } 618 procedure Ellipse(x, y, rx, ry: single; c: TBGRAPixel; w: single; ADrawMode: TDrawMode); overload; override; 619 procedure Ellipse(AOrigin, AXAxis, AYAxis: TPointF; c: TBGRAPixel; w: single; ADrawMode: TDrawMode); overload; override; 603 620 {** Draws an ellipse with antialising. ''rx'' is the horizontal radius and 604 621 ''ry'' the vertical radius } 605 procedure EllipseAntialias(x, y, rx, ry: single; c: TBGRAPixel; w: single); override; 622 procedure EllipseAntialias(x, y, rx, ry: single; c: TBGRAPixel; w: single); overload; override; 623 procedure EllipseAntialias(AOrigin, AXAxis, AYAxis: TPointF; c: TBGRAPixel; w: single); overload; override; 606 624 {** Draws an ellipse border with a ''texture'' } 607 procedure EllipseAntialias(x, y, rx, ry: single; texture: IBGRAScanner; w: single); override; 625 procedure EllipseAntialias(x, y, rx, ry: single; texture: IBGRAScanner; w: single); overload; override; 626 procedure EllipseAntialias(AOrigin, AXAxis, AYAxis: TPointF; texture: IBGRAScanner; w: single); overload; override; 608 627 {** Draws and fills an ellipse } 609 procedure EllipseAntialias(x, y, rx, ry: single; c: TBGRAPixel; w: single; back: TBGRAPixel); override; 628 procedure EllipseAntialias(x, y, rx, ry: single; c: TBGRAPixel; w: single; back: TBGRAPixel); overload; override; 629 procedure EllipseAntialias(AOrigin, AXAxis, AYAxis: TPointF; c: TBGRAPixel; w: single; back: TBGRAPixel); overload; override; 610 630 {** Fills an ellipse } 611 procedure FillEllipseAntialias(x, y, rx, ry: single; c: TBGRAPixel); override; 631 procedure FillEllipseAntialias(x, y, rx, ry: single; c: TBGRAPixel); overload; override; 632 procedure FillEllipseAntialias(AOrigin, AXAxis, AYAxis: TPointF; c: TBGRAPixel); overload; override; 612 633 {** Fills an ellipse with a ''texture'' } 613 procedure FillEllipseAntialias(x, y, rx, ry: single; texture: IBGRAScanner); override; 634 procedure FillEllipseAntialias(x, y, rx, ry: single; texture: IBGRAScanner); overload; override; 635 procedure FillEllipseAntialias(AOrigin, AXAxis, AYAxis: TPointF; texture: IBGRAScanner); overload; override; 614 636 {** Fills an ellipse with a gradient of color. ''outercolor'' specifies 615 637 the end color of the gradient on the border of the ellipse and 616 638 ''innercolor'' the end color of the gradient at the center of the 617 639 ellipse } 618 procedure FillEllipseLinearColorAntialias(x, y, rx, ry: single; outercolor, innercolor: TBGRAPixel); override; 640 procedure FillEllipseLinearColorAntialias(x, y, rx, ry: single; outercolor, innercolor: TBGRAPixel); overload; override; 641 procedure FillEllipseLinearColorAntialias(AOrigin, AXAxis, AYAxis: TPointF; outercolor, innercolor: TBGRAPixel); overload; override; 619 642 {** Erases the content of an ellipse } 620 procedure EraseEllipseAntialias(x, y, rx, ry: single; alpha: byte); override; 643 procedure EraseEllipseAntialias(x, y, rx, ry: single; alpha: byte); overload; override; 644 procedure EraseEllipseAntialias(AOrigin, AXAxis, AYAxis: TPointF; alpha: byte); overload; override; 621 645 622 646 {==== Polygons and path ====} 623 procedure FillPoly(const points: array of TPointF; c: TBGRAPixel; drawmode: TDrawMode ); override;624 procedure FillPoly(const points: array of TPointF; texture: IBGRAScanner; drawmode: TDrawMode ); override;625 procedure FillPolyAntialias(const points: array of TPointF; c: TBGRAPixel ); override;626 procedure FillPolyAntialias(const points: array of TPointF; texture: IBGRAScanner ); override;627 procedure ErasePoly(const points: array of TPointF; alpha: byte ); override;628 procedure ErasePolyAntialias(const points: array of TPointF; alpha: byte ); override;647 procedure FillPoly(const points: array of TPointF; c: TBGRAPixel; drawmode: TDrawMode; APixelCenteredCoordinates: boolean = true); overload; override; 648 procedure FillPoly(const points: array of TPointF; texture: IBGRAScanner; drawmode: TDrawMode; APixelCenteredCoordinates: boolean = true); overload; override; 649 procedure FillPolyAntialias(const points: array of TPointF; c: TBGRAPixel; APixelCenteredCoordinates: boolean = true); overload; override; 650 procedure FillPolyAntialias(const points: array of TPointF; texture: IBGRAScanner; APixelCenteredCoordinates: boolean = true); overload; override; 651 procedure ErasePoly(const points: array of TPointF; alpha: byte; APixelCenteredCoordinates: boolean = true); override; 652 procedure ErasePolyAntialias(const points: array of TPointF; alpha: byte; APixelCenteredCoordinates: boolean = true); override; 629 653 630 654 procedure FillTriangleLinearColor(pt1,pt2,pt3: TPointF; c1,c2,c3: TBGRAPixel); override; … … 652 676 procedure FillPolyPerspectiveMappingLightness(const points: array of TPointF; const pointsZ: array of single; texture: IBGRAScanner; texCoords: array of TPointF; lightnesses: array of word; TextureInterpolation: Boolean; zbuffer: psingle = nil); override; 653 677 654 procedure FillShape(shape: TBGRACustomFillInfo; c: TBGRAPixel; drawmode: TDrawMode); over ride;655 procedure FillShape(shape: TBGRACustomFillInfo; texture: IBGRAScanner; drawmode: TDrawMode); over ride;656 procedure FillShapeAntialias(shape: TBGRACustomFillInfo; c: TBGRAPixel); over ride;657 procedure FillShapeAntialias(shape: TBGRACustomFillInfo; texture: IBGRAScanner); over ride;678 procedure FillShape(shape: TBGRACustomFillInfo; c: TBGRAPixel; drawmode: TDrawMode); overload; override; 679 procedure FillShape(shape: TBGRACustomFillInfo; texture: IBGRAScanner; drawmode: TDrawMode); overload; override; 680 procedure FillShapeAntialias(shape: TBGRACustomFillInfo; c: TBGRAPixel); overload; override; 681 procedure FillShapeAntialias(shape: TBGRACustomFillInfo; texture: IBGRAScanner); overload; override; 658 682 procedure EraseShape(shape: TBGRACustomFillInfo; alpha: byte); override; 659 683 procedure EraseShapeAntialias(shape: TBGRACustomFillInfo; alpha: byte); override; 660 684 661 procedure DrawPath(APath: IBGRAPath; AStrokeColor: TBGRAPixel; AWidth: single; AFillColor: TBGRAPixel); over ride;662 procedure DrawPath(APath: IBGRAPath; AStrokeTexture: IBGRAScanner; AWidth: single; AFillColor: TBGRAPixel); over ride;663 procedure DrawPath(APath: IBGRAPath; AStrokeColor: TBGRAPixel; AWidth: single; AFillTexture: IBGRAScanner); over ride;664 procedure DrawPath(APath: IBGRAPath; AStrokeTexture: IBGRAScanner; AWidth: single; AFillTexture: IBGRAScanner); over ride;665 procedure DrawPath(APath: IBGRAPath; AStrokeColor: TBGRAPixel; AWidth: single); over ride;666 procedure DrawPath(APath: IBGRAPath; AStrokeTexture: IBGRAScanner; AWidth: single); over ride;667 procedure FillPath(APath: IBGRAPath; AFillColor: TBGRAPixel); over ride;668 procedure FillPath(APath: IBGRAPath; AFillTexture: IBGRAScanner); over ride;669 procedure ErasePath(APath: IBGRAPath; alpha: byte); over ride;670 671 procedure DrawPath(APath: IBGRAPath; AMatrix: TAffineMatrix; AStrokeColor: TBGRAPixel; AWidth: single; AFillColor: TBGRAPixel); over ride;672 procedure DrawPath(APath: IBGRAPath; AMatrix: TAffineMatrix; AStrokeTexture: IBGRAScanner; AWidth: single; AFillColor: TBGRAPixel); over ride;673 procedure DrawPath(APath: IBGRAPath; AMatrix: TAffineMatrix; AStrokeColor: TBGRAPixel; AWidth: single; AFillTexture: IBGRAScanner); over ride;674 procedure DrawPath(APath: IBGRAPath; AMatrix: TAffineMatrix; AStrokeTexture: IBGRAScanner; AWidth: single; AFillTexture: IBGRAScanner); over ride;675 procedure DrawPath(APath: IBGRAPath; AMatrix: TAffineMatrix; AStrokeColor: TBGRAPixel; AWidth: single); over ride;676 procedure DrawPath(APath: IBGRAPath; AMatrix: TAffineMatrix; AStrokeTexture: IBGRAScanner; AWidth: single); over ride;677 procedure FillPath(APath: IBGRAPath; AMatrix: TAffineMatrix; AFillColor: TBGRAPixel); over ride;678 procedure FillPath(APath: IBGRAPath; AMatrix: TAffineMatrix; AFillTexture: IBGRAScanner); over ride;679 procedure ErasePath(APath: IBGRAPath; AMatrix: TAffineMatrix; alpha: byte); over ride;685 procedure DrawPath(APath: IBGRAPath; AStrokeColor: TBGRAPixel; AWidth: single; AFillColor: TBGRAPixel); overload; override; 686 procedure DrawPath(APath: IBGRAPath; AStrokeTexture: IBGRAScanner; AWidth: single; AFillColor: TBGRAPixel); overload; override; 687 procedure DrawPath(APath: IBGRAPath; AStrokeColor: TBGRAPixel; AWidth: single; AFillTexture: IBGRAScanner); overload; override; 688 procedure DrawPath(APath: IBGRAPath; AStrokeTexture: IBGRAScanner; AWidth: single; AFillTexture: IBGRAScanner); overload; override; 689 procedure DrawPath(APath: IBGRAPath; AStrokeColor: TBGRAPixel; AWidth: single); overload; override; 690 procedure DrawPath(APath: IBGRAPath; AStrokeTexture: IBGRAScanner; AWidth: single); overload; override; 691 procedure FillPath(APath: IBGRAPath; AFillColor: TBGRAPixel); overload; override; 692 procedure FillPath(APath: IBGRAPath; AFillTexture: IBGRAScanner); overload; override; 693 procedure ErasePath(APath: IBGRAPath; alpha: byte); overload; override; 694 695 procedure DrawPath(APath: IBGRAPath; AMatrix: TAffineMatrix; AStrokeColor: TBGRAPixel; AWidth: single; AFillColor: TBGRAPixel); overload; override; 696 procedure DrawPath(APath: IBGRAPath; AMatrix: TAffineMatrix; AStrokeTexture: IBGRAScanner; AWidth: single; AFillColor: TBGRAPixel); overload; override; 697 procedure DrawPath(APath: IBGRAPath; AMatrix: TAffineMatrix; AStrokeColor: TBGRAPixel; AWidth: single; AFillTexture: IBGRAScanner); overload; override; 698 procedure DrawPath(APath: IBGRAPath; AMatrix: TAffineMatrix; AStrokeTexture: IBGRAScanner; AWidth: single; AFillTexture: IBGRAScanner); overload; override; 699 procedure DrawPath(APath: IBGRAPath; AMatrix: TAffineMatrix; AStrokeColor: TBGRAPixel; AWidth: single); overload; override; 700 procedure DrawPath(APath: IBGRAPath; AMatrix: TAffineMatrix; AStrokeTexture: IBGRAScanner; AWidth: single); overload; override; 701 procedure FillPath(APath: IBGRAPath; AMatrix: TAffineMatrix; AFillColor: TBGRAPixel); overload; override; 702 procedure FillPath(APath: IBGRAPath; AMatrix: TAffineMatrix; AFillTexture: IBGRAScanner); overload; override; 703 procedure ErasePath(APath: IBGRAPath; AMatrix: TAffineMatrix; alpha: byte); overload; override; 680 704 681 705 procedure ArrowStartAsNone; override; … … 694 718 If align is taRightJustify, (x,y) is the top-right corner. 695 719 The value of FontOrientation is taken into account, so that the text may be rotated. } 696 procedure TextOut(x, y: single; sUTF8: string; c: TBGRAPixel; align: TAlignment ); override; overload;720 procedure TextOut(x, y: single; sUTF8: string; c: TBGRAPixel; align: TAlignment; ARightToLeft: boolean); overload; override; 697 721 698 722 { Same as above functions, except that the text is filled using texture. 699 723 The value of FontOrientation is taken into account, so that the text may be rotated. } 700 procedure TextOut(x, y: single; sUTF8: string; texture: IBGRAScanner; align: TAlignment ); override; overload;724 procedure TextOut(x, y: single; sUTF8: string; texture: IBGRAScanner; align: TAlignment; ARightToLeft: boolean); overload; override; 701 725 702 726 { Same as above, except that the orientation is specified, overriding the value of the property FontOrientation. } 703 procedure TextOutAngle(x, y: single; orientationTenthDegCCW: integer; sUTF8: string; c: TBGRAPixel; align: TAlignment); override; overload; 704 procedure TextOutAngle(x, y: single; orientationTenthDegCCW: integer; sUTF8: string; texture: IBGRAScanner; align: TAlignment); override; overload; 705 706 procedure TextOutCurved(ACursor: TBGRACustomPathCursor; sUTF8: string; AColor: TBGRAPixel; AAlign: TAlignment; ALetterSpacing: single); override; overload; 707 procedure TextOutCurved(ACursor: TBGRACustomPathCursor; sUTF8: string; ATexture: IBGRAScanner; AAlign: TAlignment; ALetterSpacing: single); override; overload; 727 procedure TextOutAngle(x, y: single; orientationTenthDegCCW: integer; sUTF8: string; c: TBGRAPixel; align: TAlignment); overload; override; 728 procedure TextOutAngle(x, y: single; orientationTenthDegCCW: integer; sUTF8: string; texture: IBGRAScanner; align: TAlignment); overload; override; 729 730 procedure TextOutCurved(ACursor: TBGRACustomPathCursor; sUTF8: string; AColor: TBGRAPixel; AAlign: TAlignment; ALetterSpacing: single); overload; override; 731 procedure TextOutCurved(ACursor: TBGRACustomPathCursor; sUTF8: string; ATexture: IBGRAScanner; AAlign: TAlignment; ALetterSpacing: single); overload; override; 732 733 procedure TextMultiline(ALeft,ATop,AWidth: single; sUTF8: string; c: TBGRAPixel; AAlign: TBidiTextAlignment = btaNatural; AVertAlign: TTextLayout = tlTop; AParagraphSpacing: single = 0); overload; override; 734 procedure TextMultiline(ALeft,ATop,AWidth: single; sUTF8: string; ATexture: IBGRAScanner; AAlign: TBidiTextAlignment = btaNatural; AVertAlign: TTextLayout = tlTop; AParagraphSpacing: single = 0); overload; override; 708 735 709 736 { Draw the UTF8 encoded string at the coordinate (x,y), clipped inside the rectangle ARect. 710 737 Additional style information is provided by the style parameter. 711 738 The color c or texture is used to fill the text. No rotation is applied. } 712 procedure TextRect(ARect: TRect; x, y: integer; sUTF8: string; style: TTextStyle; c: TBGRAPixel); over ride; overload;713 procedure TextRect(ARect: TRect; x, y: integer; sUTF8: string; style: TTextStyle; texture: IBGRAScanner); over ride; overload;739 procedure TextRect(ARect: TRect; x, y: integer; sUTF8: string; style: TTextStyle; c: TBGRAPixel); overload; override; 740 procedure TextRect(ARect: TRect; x, y: integer; sUTF8: string; style: TTextStyle; texture: IBGRAScanner); overload; override; 714 741 715 742 { Returns the total size of the string provided using the current font. 716 Orientation is not taken into account, so that the width is along the text. }743 Orientation is not taken into account, so that the width is along the text. End of lines are stripped from the string. } 717 744 function TextSize(sUTF8: string): TSize; override; 745 746 { Returns the affine box of the string provided using the current font. 747 Orientation is taken into account. End of lines are stripped from the string. } 748 function TextAffineBox(sUTF8: string): TAffineBox; override; 749 750 { Returns the total size of a paragraph i.e. with word break } 751 function TextSize(sUTF8: string; AMaxWidth: integer): TSize; override; 752 function TextSize(sUTF8: string; AMaxWidth: integer; ARightToLeft: boolean): TSize; override; 753 function TextFitInfo(sUTF8: string; AMaxWidth: integer): integer; override; 718 754 719 755 {Spline} … … 721 757 function ComputeOpenedSpline(const APoints: array of TPointF; AStyle: TSplineStyle): ArrayOfTPointF; override; 722 758 723 function ComputeBezierCurve(const ACurve: TCubicBezierCurve): ArrayOfTPointF; override; 724 function ComputeBezierCurve(const ACurve: TQuadraticBezierCurve): ArrayOfTPointF; override; 725 function ComputeBezierSpline(const ASpline: array of TCubicBezierCurve): ArrayOfTPointF; override; 726 function ComputeBezierSpline(const ASpline: array of TQuadraticBezierCurve): ArrayOfTPointF; override; 727 728 function ComputeWidePolyline(const points: array of TPointF; w: single): ArrayOfTPointF; override; 729 function ComputeWidePolyline(const points: array of TPointF; w: single; ClosedCap: boolean): ArrayOfTPointF; override; 730 function ComputeWidePolygon(const points: array of TPointF; w: single): ArrayOfTPointF; override; 731 732 function ComputeEllipseContour(x,y,rx,ry: single; quality: single = 1): ArrayOfTPointF; override; 733 function ComputeEllipseBorder(x,y,rx,ry,w: single; quality: single = 1): ArrayOfTPointF; override; 759 function ComputeBezierCurve(const ACurve: TCubicBezierCurve): ArrayOfTPointF; overload; override; 760 function ComputeBezierCurve(const ACurve: TQuadraticBezierCurve): ArrayOfTPointF; overload; override; 761 function ComputeBezierSpline(const ASpline: array of TCubicBezierCurve): ArrayOfTPointF; overload; override; 762 function ComputeBezierSpline(const ASpline: array of TQuadraticBezierCurve): ArrayOfTPointF; overload; override; 763 764 function ComputeWidePolyline(const points: array of TPointF; w: single): ArrayOfTPointF; overload; override; 765 function ComputeWidePolyline(const points: array of TPointF; w: single; ClosedCap: boolean): ArrayOfTPointF; overload; override; 766 function ComputeWidePolygon(const points: array of TPointF; w: single): ArrayOfTPointF; overload; override; 767 768 function ComputeEllipseContour(x,y,rx,ry: single; quality: single = 1): ArrayOfTPointF; overload; override; 769 function ComputeEllipseContour(AOrigin, AXAxis, AYAxis: TPointF; quality: single = 1): ArrayOfTPointF; overload; override; 770 function ComputeEllipseBorder(x,y,rx,ry,w: single; quality: single = 1): ArrayOfTPointF; overload; override; 771 function ComputeEllipseBorder(AOrigin, AXAxis, AYAxis: TPointF; w: single; quality: single = 1): ArrayOfTPointF; override; overload; 734 772 function ComputeArc65536(x,y,rx,ry: single; start65536,end65536: word; quality: single = 1): ArrayOfTPointF; override; 735 773 function ComputeArcRad(x,y,rx,ry: single; startRad,endRad: single; quality: single = 1): ArrayOfTPointF; override; 736 function ComputeRoundRect(x1,y1,x2,y2,rx,ry: single; quality: single = 1): ArrayOfTPointF; over ride;737 function ComputeRoundRect(x1,y1,x2,y2,rx,ry: single; options: TRoundRectangleOptions; quality: single = 1): ArrayOfTPointF; over ride;774 function ComputeRoundRect(x1,y1,x2,y2,rx,ry: single; quality: single = 1): ArrayOfTPointF; overload; override; 775 function ComputeRoundRect(x1,y1,x2,y2,rx,ry: single; options: TRoundRectangleOptions; quality: single = 1): ArrayOfTPointF; overload; override; 738 776 function ComputePie65536(x,y,rx,ry: single; start65536,end65536: word; quality: single = 1): ArrayOfTPointF; override; 739 777 function ComputePieRad(x,y,rx,ry: single; startRad,endRad: single; quality: single = 1): ArrayOfTPointF; override; … … 741 779 {Filling} 742 780 procedure NoClip; override; 743 procedure Fill(texture: IBGRAScanner; mode: TDrawMode); over ride;744 procedure Fill(texture: IBGRAScanner); over ride;745 procedure Fill(c: TBGRAPixel; start, Count: integer); over ride;781 procedure Fill(texture: IBGRAScanner; mode: TDrawMode); overload; override; 782 procedure Fill(texture: IBGRAScanner); overload; override; 783 procedure Fill(c: TBGRAPixel; start, Count: integer); overload; override; 746 784 procedure DrawPixels(c: TBGRAPixel; start, Count: integer); override; 747 785 procedure AlphaFill(alpha: byte; start, Count: integer); override; 748 786 procedure FillMask(x,y: integer; AMask: TBGRACustomBitmap; color: TBGRAPixel; ADrawMode: TDrawMode); override; 749 787 procedure FillMask(x,y: integer; AMask: TBGRACustomBitmap; texture: IBGRAScanner; ADrawMode: TDrawMode; AOpacity: byte = 255); override; 788 procedure EraseMask(x,y: integer; AMask: TBGRACustomBitmap; alpha: byte=255); override; 750 789 procedure FillClearTypeMask(x,y: integer; xThird: integer; AMask: TBGRACustomBitmap; color: TBGRAPixel; ARGBOrder: boolean = true); override; 751 790 procedure FillClearTypeMask(x,y: integer; xThird: integer; AMask: TBGRACustomBitmap; texture: IBGRAScanner; ARGBOrder: boolean = true); override; … … 775 814 776 815 {Canvas drawing functions} 777 procedure Draw(ACanvas: TCanvas; x, y: integer; Opaque: boolean = True); over ride;778 procedure Draw(ACanvas: TCanvas; Rect: TRect; Opaque: boolean = True); over ride;816 procedure Draw(ACanvas: TCanvas; x, y: integer; Opaque: boolean = True); overload; override; 817 procedure Draw(ACanvas: TCanvas; Rect: TRect; Opaque: boolean = True); overload; override; 779 818 procedure InvalidateBitmap; override; //call if you modify with Scanline 780 819 procedure LoadFromBitmapIfNeeded; override; //call to ensure that bitmap data is up to date 781 820 782 821 {BGRA bitmap functions} 783 procedure CrossFade(ARect: TRect; Source1, Source2: IBGRAScanner; AFadePosition: byte; mode: TDrawMode = dmDrawWithTransparency); over ride;784 procedure CrossFade(ARect: TRect; Source1, Source2: IBGRAScanner; AFadeMask: IBGRAScanner; mode: TDrawMode = dmDrawWithTransparency); over ride;785 procedure PutImage(x, y: integer; Source: TBGRACustomBitmap; mode: TDrawMode; AOpacity: byte = 255); over ride;786 procedure PutImageAffine(AMatrix: TAffineMatrix; Source: TBGRACustomBitmap; AOutputBounds: TRect; AResampleFilter: TResampleFilter; AMode: TDrawMode; AOpacity: Byte=255); over ride; overload;787 function GetImageAffineBounds(AMatrix: TAffineMatrix; ASourceBounds: TRect; AClipOutput: boolean = true): TRect; over ride; overload;788 function IsAffineRoughlyTranslation(AMatrix: TAffineMatrix; ASourceBounds: TRect): boolean; override;822 procedure CrossFade(ARect: TRect; Source1, Source2: IBGRAScanner; AFadePosition: byte; mode: TDrawMode = dmDrawWithTransparency); overload; override; 823 procedure CrossFade(ARect: TRect; Source1, Source2: IBGRAScanner; AFadeMask: IBGRAScanner; mode: TDrawMode = dmDrawWithTransparency); overload; override; 824 procedure PutImage(x, y: integer; Source: TBGRACustomBitmap; mode: TDrawMode; AOpacity: byte = 255); overload; override; 825 procedure PutImageAffine(AMatrix: TAffineMatrix; Source: TBGRACustomBitmap; AOutputBounds: TRect; AResampleFilter: TResampleFilter; AMode: TDrawMode; AOpacity: Byte=255); overload; override; 826 function GetImageAffineBounds(AMatrix: TAffineMatrix; ASourceBounds: TRect; AClipOutput: boolean = true): TRect; overload; override; 827 class function IsAffineRoughlyTranslation(AMatrix: TAffineMatrix; ASourceBounds: TRect): boolean; override; 789 828 790 829 procedure StretchPutImage(ARect: TRect; Source: TBGRACustomBitmap; mode: TDrawMode; AOpacity: byte = 255); override; … … 796 835 function GetPart(ARect: TRect): TBGRACustomBitmap; override; 797 836 function GetPtrBitmap(Top,Bottom: Integer): TBGRACustomBitmap; override; 798 function Duplicate(DuplicateProperties: Boolean = False ) : TBGRACustomBitmap; override;837 function Duplicate(DuplicateProperties: Boolean = False; DuplicateXorMask: Boolean = False) : TBGRACustomBitmap; override; 799 838 procedure CopyPropertiesTo(ABitmap: TBGRADefaultBitmap); 800 function Equals(comp: TBGRACustomBitmap): boolean; over ride;801 function Equals(comp: TBGRAPixel): boolean; over ride;839 function Equals(comp: TBGRACustomBitmap): boolean; overload; override; 840 function Equals(comp: TBGRAPixel): boolean; overload; override; 802 841 function GetDifferenceBounds(ABitmap: TBGRACustomBitmap): TRect; override; 803 842 function MakeBitmapCopy(BackgroundColor: TColor): TBitmap; override; … … 805 844 function Resample(newWidth, newHeight: integer; 806 845 mode: TResampleMode = rmFineResample): TBGRACustomBitmap; override; 807 procedure VerticalFlip(ARect: TRect); over ride; overload;808 procedure HorizontalFlip(ARect: TRect); over ride; overload;846 procedure VerticalFlip(ARect: TRect); overload; override; 847 procedure HorizontalFlip(ARect: TRect); overload; override; 809 848 function RotateCW: TBGRACustomBitmap; override; 810 849 function RotateCCW: TBGRACustomBitmap; override; … … 813 852 procedure LinearNegative; override; 814 853 procedure LinearNegativeRect(ABounds: TRect); override; 815 procedure InplaceGrayscale(AGammaCorrection: boolean = true); over ride;816 procedure InplaceGrayscale(ABounds: TRect; AGammaCorrection: boolean = true); over ride;817 procedure InplaceNormalize(AEachChannel: boolean = True); over ride;818 procedure InplaceNormalize(ABounds: TRect; AEachChannel: boolean = True); over ride;854 procedure InplaceGrayscale(AGammaCorrection: boolean = true); overload; override; 855 procedure InplaceGrayscale(ABounds: TRect; AGammaCorrection: boolean = true); overload; override; 856 procedure InplaceNormalize(AEachChannel: boolean = True); overload; override; 857 procedure InplaceNormalize(ABounds: TRect; AEachChannel: boolean = True); overload; override; 819 858 procedure SwapRedBlue; override; 820 859 procedure SwapRedBlue(ARect: TRect); override; 821 860 procedure GrayscaleToAlpha; override; 822 861 procedure AlphaToGrayscale; override; 823 procedure ApplyMask(mask: TBGRACustomBitmap; ARect: TRect; AMaskRectTopLeft: TPoint); override; overload; 862 procedure ApplyMask(mask: TBGRACustomBitmap; ARect: TRect; AMaskRectTopLeft: TPoint); overload; override; 863 function GetMaskFromAlpha: TBGRACustomBitmap; override; 824 864 procedure ApplyGlobalOpacity(alpha: byte); override; 825 865 procedure ApplyGlobalOpacity(ABounds: TRect; alpha: byte); override; 826 866 procedure ConvertToLinearRGB; override; 827 867 procedure ConvertFromLinearRGB; override; 828 procedure DrawCheckers(ARect: TRect; AColorEven,AColorOdd: TBGRAPixel); 868 procedure DrawCheckers(ARect: TRect; AColorEven,AColorOdd: TBGRAPixel); override; 829 869 830 870 {Filters} … … 832 872 function FilterMedian(Option: TMedianOption): TBGRACustomBitmap; override; 833 873 function FilterSmooth: TBGRACustomBitmap; override; 834 function FilterSharpen(Amount: single = 1): TBGRACustomBitmap; over ride;835 function FilterSharpen(ABounds: TRect; Amount: single = 1): TBGRACustomBitmap; over ride;874 function FilterSharpen(Amount: single = 1): TBGRACustomBitmap; overload; override; 875 function FilterSharpen(ABounds: TRect; Amount: single = 1): TBGRACustomBitmap; overload; override; 836 876 function FilterContour: TBGRACustomBitmap; override; 837 877 function FilterPixelate(pixelSize: integer; useResample: boolean; filter: TResampleFilter = rfLinear): TBGRACustomBitmap; override; 838 function FilterBlurRadial(radius: single; blurType: TRadialBlurType): TBGRACustomBitmap; over ride;839 function FilterBlurRadial(ABounds: TRect; radius: single; blurType: TRadialBlurType): TBGRACustomBitmap; over ride;840 function FilterBlurRadial(radiusX, radiusY: single; blurType: TRadialBlurType): TBGRACustomBitmap; over ride;841 function FilterBlurRadial(ABounds: TRect; radiusX, radiusY: single; blurType: TRadialBlurType): TBGRACustomBitmap; over ride;842 function FilterBlurMotion(distance: single; angle: single; oriented: boolean): TBGRACustomBitmap; over ride;843 function FilterBlurMotion(ABounds: TRect; distance: single; angle: single; oriented: boolean): TBGRACustomBitmap; over ride;844 function FilterCustomBlur(mask: TBGRACustomBitmap): TBGRACustomBitmap; over ride;845 function FilterCustomBlur(ABounds: TRect; mask: TBGRACustomBitmap): TBGRACustomBitmap; over ride;846 function FilterEmboss(angle: single; AStrength: integer= 64; AOptions: TEmbossOptions = []): TBGRACustomBitmap; over ride;847 function FilterEmboss(angle: single; ABounds: TRect; AStrength: integer= 64; AOptions: TEmbossOptions = []): TBGRACustomBitmap; over ride;848 function FilterEmbossHighlight(FillSelection: boolean): TBGRACustomBitmap; over ride;849 function FilterEmbossHighlight(FillSelection: boolean; BorderColor: TBGRAPixel): TBGRACustomBitmap; over ride;850 function FilterEmbossHighlight(FillSelection: boolean; BorderColor: TBGRAPixel; var Offset: TPoint): TBGRACustomBitmap; over ride;851 function FilterGrayscale: TBGRACustomBitmap; over ride;852 function FilterGrayscale(ABounds: TRect): TBGRACustomBitmap; over ride;853 function FilterNormalize(eachChannel: boolean = True): TBGRACustomBitmap; over ride;854 function FilterNormalize(ABounds: TRect; eachChannel: boolean = True): TBGRACustomBitmap; over ride;878 function FilterBlurRadial(radius: single; blurType: TRadialBlurType): TBGRACustomBitmap; overload; override; 879 function FilterBlurRadial(ABounds: TRect; radius: single; blurType: TRadialBlurType): TBGRACustomBitmap; overload; override; 880 function FilterBlurRadial(radiusX, radiusY: single; blurType: TRadialBlurType): TBGRACustomBitmap; overload; override; 881 function FilterBlurRadial(ABounds: TRect; radiusX, radiusY: single; blurType: TRadialBlurType): TBGRACustomBitmap; overload; override; 882 function FilterBlurMotion(distance: single; angle: single; oriented: boolean): TBGRACustomBitmap; overload; override; 883 function FilterBlurMotion(ABounds: TRect; distance: single; angle: single; oriented: boolean): TBGRACustomBitmap; overload; override; 884 function FilterCustomBlur(mask: TBGRACustomBitmap): TBGRACustomBitmap; overload; override; 885 function FilterCustomBlur(ABounds: TRect; mask: TBGRACustomBitmap): TBGRACustomBitmap; overload; override; 886 function FilterEmboss(angle: single; AStrength: integer= 64; AOptions: TEmbossOptions = []): TBGRACustomBitmap; overload; override; 887 function FilterEmboss(angle: single; ABounds: TRect; AStrength: integer= 64; AOptions: TEmbossOptions = []): TBGRACustomBitmap; overload; override; 888 function FilterEmbossHighlight(FillSelection: boolean): TBGRACustomBitmap; overload; override; 889 function FilterEmbossHighlight(FillSelection: boolean; BorderColor: TBGRAPixel): TBGRACustomBitmap; overload; override; 890 function FilterEmbossHighlight(FillSelection: boolean; BorderColor: TBGRAPixel; var Offset: TPoint): TBGRACustomBitmap; overload; override; 891 function FilterGrayscale: TBGRACustomBitmap; overload; override; 892 function FilterGrayscale(ABounds: TRect): TBGRACustomBitmap; overload; override; 893 function FilterNormalize(eachChannel: boolean = True): TBGRACustomBitmap; overload; override; 894 function FilterNormalize(ABounds: TRect; eachChannel: boolean = True): TBGRACustomBitmap; overload; override; 855 895 function FilterRotate(origin: TPointF; angle: single; correctBlur: boolean = false): TBGRACustomBitmap; override; 856 896 function FilterAffine(AMatrix: TAffineMatrix; correctBlur: boolean = false): TBGRACustomBitmap; override; 857 897 function FilterSphere: TBGRACustomBitmap; override; 858 function FilterTwirl(ACenter: TPoint; ARadius: Single; ATurn: Single=1; AExponent: Single=3): TBGRACustomBitmap; over ride;859 function FilterTwirl(ABounds: TRect; ACenter: TPoint; ARadius: Single; ATurn: Single=1; AExponent: Single=3): TBGRACustomBitmap; over ride;898 function FilterTwirl(ACenter: TPoint; ARadius: Single; ATurn: Single=1; AExponent: Single=3): TBGRACustomBitmap; overload; override; 899 function FilterTwirl(ABounds: TRect; ACenter: TPoint; ARadius: Single; ATurn: Single=1; AExponent: Single=3): TBGRACustomBitmap; overload; override; 860 900 function FilterCylinder: TBGRACustomBitmap; override; 861 901 function FilterPlane: TBGRACustomBitmap; override; … … 880 920 public 881 921 constructor Create(AWidth, AHeight: integer; AData: Pointer); overload; 882 function Duplicate(DuplicateProperties: Boolean = False ): TBGRACustomBitmap; override;922 function Duplicate(DuplicateProperties: Boolean = False; DuplicateXorMask: Boolean = False): TBGRACustomBitmap; override; 883 923 procedure SetDataPtr(AData: Pointer); 884 924 property LineOrder: TRawImageLineOrder Read GetLineOrder Write SetLineOrder; … … 893 933 procedure TakeScreenshot({%H-}ARect: TRect); override; 894 934 procedure TakeScreenshotOfPrimaryMonitor; override; 895 procedure LoadFromDevice({%H-}DC: System.THandle); override;896 procedure LoadFromDevice({%H-}DC: System.THandle; {%H-}ARect: TRect); override;935 procedure LoadFromDevice({%H-}DC: HDC); override; 936 procedure LoadFromDevice({%H-}DC: HDC; {%H-}ARect: TRect); override; 897 937 end; 898 938 … … 935 975 begin 936 976 if FUser <> nil then 977 begin 937 978 FUser.FBitmapModified := True; 979 FUser.FAlphaCorrectionNeeded := true; 980 end; 938 981 inherited Changed(Sender); 939 982 end; … … 966 1009 end; 967 1010 1011 function TBGRADefaultBitmap.CheckIsZero: boolean; 1012 var 1013 i: integer; 1014 p: PBGRAPixel; 1015 begin 1016 p := Data; 1017 for i := (NbPixels shr 1) - 1 downto 0 do 1018 begin 1019 if PInt64(p)^ <> 0 then 1020 begin 1021 Result := False; 1022 exit; 1023 end; 1024 Inc(p,2); 1025 end; 1026 if Odd(NbPixels) and (PDWord(p)^ <> 0) then 1027 begin 1028 Result := false; 1029 exit; 1030 end; 1031 Result := True; 1032 end; 1033 968 1034 function TBGRADefaultBitmap.GetCanvasAlphaCorrection: boolean; 969 1035 begin … … 1055 1121 procedure TBGRADefaultBitmap.SetArrowEndSize(AValue: TPointF); 1056 1122 begin 1123 {$PUSH}{$OPTIMIZATION OFF} 1057 1124 GetArrow.EndSize := AValue; 1125 {$POP} 1058 1126 end; 1059 1127 1060 1128 procedure TBGRADefaultBitmap.SetArrowStartSize(AValue: TPointF); 1061 1129 begin 1130 {$PUSH}{$OPTIMIZATION OFF} 1062 1131 GetArrow.StartSize := AValue; 1132 {$POP} 1063 1133 end; 1064 1134 … … 1148 1218 end; 1149 1219 1150 function TBGRADefaultBitmap.GetFont AnchorVerticalOffset: single;1220 function TBGRADefaultBitmap.GetFontVerticalAnchorOffset: single; 1151 1221 begin 1152 1222 case FontVerticalAnchor of … … 1173 1243 ACustomOrientation: integer): TPointF; 1174 1244 begin 1175 result := PointF(0, GetFont AnchorVerticalOffset);1245 result := PointF(0, GetFontVerticalAnchorOffset); 1176 1246 if ACustomOrientation <> 0 then 1177 1247 result := AffineMatrixRotationDeg(-ACustomOrientation*0.1)*result; … … 1205 1275 function TBGRADefaultBitmap.NewReference: TBGRACustomBitmap; 1206 1276 begin 1207 Inc(FRefCount);1277 if self <> nil then Inc(FRefCount); 1208 1278 Result := self; 1209 1279 end; … … 1239 1309 end; 1240 1310 1311 procedure TBGRADefaultBitmap.NeedXorMask; 1312 begin 1313 if FXorMask = nil then 1314 FXorMask := BGRABitmapFactory.Create(Width,Height); 1315 end; 1316 1317 procedure TBGRADefaultBitmap.DiscardXorMask; 1318 begin 1319 if Assigned(FXorMask) then 1320 begin 1321 if FXorMask is TBGRADefaultBitmap then 1322 begin 1323 TBGRADefaultBitmap(FXorMask).FreeReference; 1324 FXorMask := nil; 1325 end else 1326 FreeAndNil(FXorMask); 1327 end; 1328 end; 1329 1241 1330 { Creates a new bitmap with dimensions AWidth and AHeight and filled with 1242 1331 transparent pixels. Internally, it uses the same type so that if you … … 1309 1398 OldJpegPerf: TJPEGReadPerformance; 1310 1399 begin 1400 DiscardXorMask; 1311 1401 if (loBmpAutoOpaque in AOptions) and (Handler is TBGRAReaderBMP) then 1312 1402 begin … … 1324 1414 end else 1325 1415 inherited LoadFromStream(Str, Handler, AOptions); 1416 end; 1417 1418 procedure TBGRADefaultBitmap.LoadFromResource(AFilename: string; 1419 AOptions: TBGRALoadingOptions); 1420 var 1421 stream: TStream; 1422 format: TBGRAImageFormat; 1423 reader: TFPCustomImageReader; 1424 magic: array[1..2] of char; 1425 startPos: Int64; 1426 ext: String; 1427 begin 1428 stream := BGRAResource.GetResourceStream(AFilename); 1429 try 1430 ext := Uppercase(ExtractFileExt(AFilename)); 1431 if (ext = '.BMP') and BGRAResource.IsWinResource(AFilename) then 1432 begin 1433 reader := TBGRAReaderBMP.Create; 1434 TBGRAReaderBMP(reader).Subformat := bsfHeaderless; 1435 end else 1436 begin 1437 format := DetectFileFormat(stream, ext); 1438 reader := CreateBGRAImageReader(format); 1439 end; 1440 try 1441 LoadFromStream(stream, reader, AOptions); 1442 finally 1443 reader.Free; 1444 end; 1445 finally 1446 stream.Free; 1447 end; 1326 1448 end; 1327 1449 … … 1357 1479 ReallocData; 1358 1480 NoClip; 1481 DiscardXorMask; 1359 1482 end; 1360 1483 … … 1412 1535 destructor TBGRADefaultBitmap.Destroy; 1413 1536 begin 1537 DiscardXorMask; 1414 1538 FPenStroker.Free; 1415 1539 FFontRenderer.Free; … … 1499 1623 SetSize(TBGRACustomBitmap(Source).Width, TBGRACustomBitmap(Source).Height); 1500 1624 PutImage(0, 0, TBGRACustomBitmap(Source), dmSet); 1625 if Source is TBGRADefaultBitmap then 1626 begin 1627 HotSpot := TBGRADefaultBitmap(Source).HotSpot; 1628 if XorMask <> TBGRADefaultBitmap(Source).XorMask then 1629 begin 1630 DiscardXorMask; 1631 if TBGRADefaultBitmap(Source).XorMask is TBGRADefaultBitmap then 1632 FXorMask := TBGRADefaultBitmap(TBGRADefaultBitmap(Source).XorMask).NewReference as TBGRADefaultBitmap 1633 else 1634 FXorMask := TBGRADefaultBitmap(Source).XorMask.Duplicate; 1635 end; 1636 end; 1501 1637 end else 1502 1638 if Source is TFPCustomImage then … … 1964 2100 function TBGRADefaultBitmap.GetCanvas: TCanvas; 1965 2101 begin 1966 Result := Bitmap.Canvas; 2102 if FDataModified or (FBitmap = nil) then 2103 begin 2104 RebuildBitmap; 2105 FDataModified := False; 2106 end; 2107 Result := FBitmap.Canvas; 1967 2108 end; 1968 2109 … … 1990 2131 1991 2132 procedure TBGRADefaultBitmap.CrossFade(ARect: TRect; Source1, Source2: IBGRAScanner; AFadePosition: byte; mode: TDrawMode = dmDrawWithTransparency); 1992 var constScanner: TBGRAConstantScanner;1993 2133 begin 1994 2134 if AFadePosition = 0 then … … 1996 2136 if AFadePosition = 255 then 1997 2137 FillRect(ARect, Source2, mode) else 1998 begin 1999 constScanner := TBGRAConstantScanner.Create(BGRA(AFadePosition,AFadePosition,AFadePosition,255)); 2000 CrossFade(ARect, Source1,Source2, constScanner, mode); 2001 constScanner.Free; 2002 end; 2138 InternalCrossFade(ARect, Source1,Source2, AFadePosition,nil, mode); 2003 2139 end; 2004 2140 2005 2141 procedure TBGRADefaultBitmap.CrossFade(ARect: TRect; Source1, Source2: IBGRAScanner; AFadeMask: IBGRAScanner; mode: TDrawMode = dmDrawWithTransparency); 2006 var xb,yb: NativeInt; 2007 pdest: PBGRAPixel; 2008 c: TBGRAPixel; 2009 fadePos: byte; 2010 begin 2011 if not IntersectRect(ARect,ARect,ClipRect) then exit; 2012 for yb := ARect.top to ARect.Bottom-1 do 2013 begin 2014 pdest := GetScanlineFast(yb)+ARect.Left; 2015 Source1.ScanMoveTo(ARect.left, yb); 2016 Source2.ScanMoveTo(ARect.left, yb); 2017 AFadeMask.ScanMoveTo(ARect.left, yb); 2018 for xb := ARect.left to ARect.Right-1 do 2019 begin 2020 fadePos := AFadeMask.ScanNextPixel.green; 2021 c := MergeBGRAWithGammaCorrection(Source1.ScanNextPixel,not fadePos,Source2.ScanNextPixel,fadePos); 2022 case mode of 2023 dmSet: pdest^ := c; 2024 dmDrawWithTransparency: DrawPixelInlineWithAlphaCheck(pdest, c); 2025 dmLinearBlend: FastBlendPixelInline(pdest,c); 2026 dmSetExceptTransparent: if c.alpha = 255 then pdest^ := c; 2027 end; 2028 inc(pdest); 2029 end; 2030 end; 2031 InvalidateBitmap; 2142 begin 2143 InternalCrossFade(ARect, Source1,Source2, 0,AFadeMask, mode); 2032 2144 end; 2033 2145 … … 2384 2496 end; 2385 2497 2498 procedure TBGRADefaultBitmap.InternalCrossFade(ARect: TRect; Source1, 2499 Source2: IBGRAScanner; AFadePos: byte; AFadeMask: IBGRAScanner; mode: TDrawMode); 2500 var xb,yb: NativeInt; 2501 pdest: PBGRAPixel; 2502 c: TBGRAPixel; 2503 buf1,buf2: ArrayOfTBGRAPixel; 2504 begin 2505 if not IntersectRect(ARect,ARect,ClipRect) then exit; 2506 setlength(buf1, ARect.Width); 2507 setlength(buf2, ARect.Width); 2508 for yb := ARect.top to ARect.Bottom-1 do 2509 begin 2510 pdest := GetScanlineFast(yb)+ARect.Left; 2511 Source1.ScanMoveTo(ARect.left, yb); 2512 Source1.ScanPutPixels(@buf1[0], length(buf1), dmSet); 2513 Source2.ScanMoveTo(ARect.left, yb); 2514 Source2.ScanPutPixels(@buf2[0], length(buf2), dmSet); 2515 if AFadeMask<>nil then AFadeMask.ScanMoveTo(ARect.left, yb); 2516 for xb := 0 to ARect.Right-ARect.left-1 do 2517 begin 2518 if AFadeMask<>nil then AFadePos := AFadeMask.ScanNextPixel.green; 2519 c := MergeBGRAWithGammaCorrection(buf1[xb],not AFadePos,buf2[xb],AFadePos); 2520 case mode of 2521 dmSet: pdest^ := c; 2522 dmDrawWithTransparency: DrawPixelInlineWithAlphaCheck(pdest, c); 2523 dmLinearBlend: FastBlendPixelInline(pdest,c); 2524 dmSetExceptTransparent: if c.alpha = 255 then pdest^ := c; 2525 end; 2526 inc(pdest); 2527 end; 2528 end; 2529 InvalidateBitmap; 2530 end; 2531 2386 2532 procedure TBGRADefaultBitmap.InternalArc(cx, cy, rx, ry: single; StartAngleRad, 2387 2533 EndAngleRad: Single; ABorderColor: TBGRAPixel; w: single; AFillColor: TBGRAPixel; AOptions: TArcOptions; … … 2441 2587 end; 2442 2588 2443 function TBGRADefaultBitmap.IsAffineRoughlyTranslation(AMatrix: TAffineMatrix; ASourceBounds: TRect): boolean;2589 class function TBGRADefaultBitmap.IsAffineRoughlyTranslation(AMatrix: TAffineMatrix; ASourceBounds: TRect): boolean; 2444 2590 const oneOver512 = 1/512; 2445 2591 var Orig,HAxis,VAxis: TPointF; … … 2653 2799 tempPath := TBGRAPath.Create(APath); 2654 2800 multi := TBGRAMultishapeFiller.Create; 2801 multi.FillMode := FillMode; 2655 2802 multi.PolygonOrder := poLastOnTop; 2656 2803 multi.AddPathFill(tempPath,AMatrix,AFillColor); … … 2668 2815 tempPath := TBGRAPath.Create(APath); 2669 2816 multi := TBGRAMultishapeFiller.Create; 2817 multi.FillMode := FillMode; 2670 2818 multi.PolygonOrder := poLastOnTop; 2671 2819 multi.AddPathFill(tempPath,AMatrix,AFillColor); … … 2683 2831 tempPath := TBGRAPath.Create(APath); 2684 2832 multi := TBGRAMultishapeFiller.Create; 2833 multi.FillMode := FillMode; 2685 2834 multi.PolygonOrder := poLastOnTop; 2686 2835 multi.AddPathFill(tempPath,AMatrix,AFillTexture); … … 2699 2848 tempPath := TBGRAPath.Create(APath); 2700 2849 multi := TBGRAMultishapeFiller.Create; 2850 multi.FillMode := FillMode; 2701 2851 multi.PolygonOrder := poLastOnTop; 2702 2852 multi.AddPathFill(tempPath,AMatrix,AFillTexture); … … 3038 3188 3039 3189 procedure TBGRADefaultBitmap.FillPoly(const points: array of TPointF; 3040 c: TBGRAPixel; drawmode: TDrawMode );3041 begin 3042 BGRAPolygon.FillPolyAliased(self, points, c, FEraseMode, FillMode = fmWinding, drawmode );3190 c: TBGRAPixel; drawmode: TDrawMode; APixelCenteredCoordinates: boolean); 3191 begin 3192 BGRAPolygon.FillPolyAliased(self, points, c, FEraseMode, FillMode = fmWinding, drawmode, APixelCenteredCoordinates); 3043 3193 end; 3044 3194 3045 3195 procedure TBGRADefaultBitmap.FillPoly(const points: array of TPointF; 3046 texture: IBGRAScanner; drawmode: TDrawMode );3047 begin 3048 BGRAPolygon.FillPolyAliasedWithTexture(self, points, texture, FillMode = fmWinding, drawmode );3196 texture: IBGRAScanner; drawmode: TDrawMode; APixelCenteredCoordinates: boolean); 3197 begin 3198 BGRAPolygon.FillPolyAliasedWithTexture(self, points, texture, FillMode = fmWinding, drawmode, APixelCenteredCoordinates); 3049 3199 end; 3050 3200 … … 3057 3207 end; 3058 3208 3059 procedure TBGRADefaultBitmap.FillPolyAntialias(const points: array of TPointF; c: TBGRAPixel );3060 begin 3061 BGRAPolygon.FillPolyAntialias(self, points, c, FEraseMode, FillMode = fmWinding, LinearAntialiasing );3209 procedure TBGRADefaultBitmap.FillPolyAntialias(const points: array of TPointF; c: TBGRAPixel; APixelCenteredCoordinates: boolean); 3210 begin 3211 BGRAPolygon.FillPolyAntialias(self, points, c, FEraseMode, FillMode = fmWinding, LinearAntialiasing, APixelCenteredCoordinates); 3062 3212 end; 3063 3213 3064 3214 procedure TBGRADefaultBitmap.FillPolyAntialias(const points: array of TPointF; 3065 texture: IBGRAScanner );3066 begin 3067 BGRAPolygon.FillPolyAntialiasWithTexture(self, points, texture, FillMode = fmWinding, LinearAntialiasing );3215 texture: IBGRAScanner; APixelCenteredCoordinates: boolean); 3216 begin 3217 BGRAPolygon.FillPolyAntialiasWithTexture(self, points, texture, FillMode = fmWinding, LinearAntialiasing, APixelCenteredCoordinates); 3068 3218 end; 3069 3219 3070 3220 procedure TBGRADefaultBitmap.ErasePoly(const points: array of TPointF; 3071 alpha: byte );3072 begin 3073 BGRAPolygon.FillPolyAliased(self, points, BGRA(0, 0, 0, alpha), True, FillMode = fmWinding, dmDrawWithTransparency );3074 end; 3075 3076 procedure TBGRADefaultBitmap.ErasePolyAntialias(const points: array of TPointF; alpha: byte );3221 alpha: byte; APixelCenteredCoordinates: boolean); 3222 begin 3223 BGRAPolygon.FillPolyAliased(self, points, BGRA(0, 0, 0, alpha), True, FillMode = fmWinding, dmDrawWithTransparency, APixelCenteredCoordinates); 3224 end; 3225 3226 procedure TBGRADefaultBitmap.ErasePolyAntialias(const points: array of TPointF; alpha: byte; APixelCenteredCoordinates: boolean); 3077 3227 begin 3078 3228 FEraseMode := True; 3079 FillPolyAntialias(points, BGRA(0, 0, 0, alpha) );3229 FillPolyAntialias(points, BGRA(0, 0, 0, alpha), APixelCenteredCoordinates); 3080 3230 FEraseMode := False; 3081 3231 end; … … 3155 3305 c: TBGRAPixel; w: single); 3156 3306 begin 3157 if (PenStyle = psClear) or (c.alpha = 0) then exit;3307 if (PenStyle = psClear) or (c.alpha = 0) or (w = 0) then exit; 3158 3308 if (PenStyle = psSolid) then 3159 3309 BGRAPolygon.BorderEllipseAntialias(self, x, y, rx, ry, w, c, FEraseMode, LinearAntialiasing) … … 3162 3312 end; 3163 3313 3314 procedure TBGRADefaultBitmap.EllipseAntialias(AOrigin, AXAxis, AYAxis: TPointF; 3315 c: TBGRAPixel; w: single); 3316 begin 3317 if (PenStyle = psClear) or (c.alpha = 0) or (w = 0) then exit; 3318 DrawPolygonAntialias(ComputeEllipseContour(AOrigin, AXAxis, AYAxis),c,w); 3319 end; 3320 3164 3321 procedure TBGRADefaultBitmap.EllipseAntialias(x, y, rx, ry: single; 3165 3322 texture: IBGRAScanner; w: single); 3166 3323 begin 3167 if (PenStyle = psClear) then exit;3324 if (PenStyle = psClear) or (w = 0) then exit; 3168 3325 if (PenStyle = psSolid) then 3169 3326 BGRAPolygon.BorderEllipseAntialiasWithTexture(self, x, y, rx, ry, w, texture, LinearAntialiasing) … … 3172 3329 end; 3173 3330 3331 procedure TBGRADefaultBitmap.EllipseAntialias(AOrigin, AXAxis, AYAxis: TPointF; 3332 texture: IBGRAScanner; w: single); 3333 begin 3334 if (PenStyle = psClear) or (w = 0) then exit; 3335 DrawPolygonAntialias(ComputeEllipseContour(AOrigin, AXAxis, AYAxis),texture,w); 3336 end; 3337 3174 3338 procedure TBGRADefaultBitmap.EllipseAntialias(x, y, rx, ry: single; 3175 3339 c: TBGRAPixel; w: single; back: TBGRAPixel); … … 3177 3341 hw: single; 3178 3342 begin 3179 if w=0 then exit; 3343 if (w=0) or (PenStyle = psClear) or (c.alpha = 0) then 3344 begin 3345 FillEllipseAntialias(x, y, rx, ry, back); 3346 exit; 3347 end; 3180 3348 rx := abs(rx); 3181 3349 ry := abs(ry); … … 3188 3356 { use multishape filler for fine junction between polygons } 3189 3357 multi := TBGRAMultishapeFiller.Create; 3190 if not (PenStyle = psClear) and (c.alpha <> 0) then 3191 begin 3192 if (PenStyle = psSolid) then 3193 begin 3194 multi.AddEllipse(x,y,rx-hw,ry-hw,back); 3195 multi.AddEllipseBorder(x,y,rx,ry,w,c) 3196 end 3197 else 3198 begin 3199 multi.AddEllipse(x,y,rx,ry,back); 3200 multi.AddPolygon(ComputeWidePolygon(ComputeEllipseContour(x,y,rx,ry),w),c); 3201 multi.PolygonOrder := poLastOnTop; 3202 end; 3203 end; 3358 if (PenStyle = psSolid) then 3359 begin 3360 if back.alpha <> 0 then multi.AddEllipse(x,y,rx-hw,ry-hw,back); 3361 multi.AddEllipseBorder(x,y,rx,ry,w,c) 3362 end 3363 else 3364 begin 3365 if back.alpha <> 0 then multi.AddEllipse(x,y,rx,ry,back); 3366 multi.AddPolygon(ComputeWidePolygon(ComputeEllipseContour(x,y,rx,ry),w),c); 3367 end; 3368 multi.PolygonOrder := poLastOnTop; 3204 3369 multi.Draw(self); 3205 3370 multi.Free; 3206 3371 end; 3207 3372 3373 procedure TBGRADefaultBitmap.EllipseAntialias(AOrigin, AXAxis, AYAxis: TPointF; 3374 c: TBGRAPixel; w: single; back: TBGRAPixel); 3375 var multi: TBGRAMultishapeFiller; 3376 pts: ArrayOfTPointF; 3377 begin 3378 if (w=0) or (PenStyle = psClear) or (c.alpha = 0) then 3379 begin 3380 FillEllipseAntialias(AOrigin, AXAxis, AYAxis, back); 3381 exit; 3382 end; 3383 { use multishape filler for fine junction between polygons } 3384 multi := TBGRAMultishapeFiller.Create; 3385 pts := ComputeEllipseContour(AOrigin, AXAxis, AYAxis); 3386 if back.alpha <> 0 then multi.AddPolygon(pts, back); 3387 pts := ComputeWidePolygon(pts,w); 3388 multi.AddPolygon(pts,c); 3389 multi.PolygonOrder := poLastOnTop; 3390 multi.Draw(self); 3391 multi.Free; 3392 end; 3393 3208 3394 procedure TBGRADefaultBitmap.FillEllipseAntialias(x, y, rx, ry: single; c: TBGRAPixel); 3209 3395 begin 3210 3396 BGRAPolygon.FillEllipseAntialias(self, x, y, rx, ry, c, FEraseMode, LinearAntialiasing); 3397 end; 3398 3399 procedure TBGRADefaultBitmap.FillEllipseAntialias(AOrigin, AXAxis, 3400 AYAxis: TPointF; c: TBGRAPixel); 3401 var 3402 pts: array of TPointF; 3403 begin 3404 if c.alpha = 0 then exit; 3405 pts := ComputeEllipseContour(AOrigin,AXAxis,AYAxis); 3406 FillPolyAntialias(pts, c); 3211 3407 end; 3212 3408 … … 3215 3411 begin 3216 3412 BGRAPolygon.FillEllipseAntialiasWithTexture(self, x, y, rx, ry, texture, LinearAntialiasing); 3413 end; 3414 3415 procedure TBGRADefaultBitmap.FillEllipseAntialias(AOrigin, AXAxis, 3416 AYAxis: TPointF; texture: IBGRAScanner); 3417 var 3418 pts: array of TPointF; 3419 begin 3420 pts := ComputeEllipseContour(AOrigin,AXAxis,AYAxis); 3421 FillPolyAntialias(pts, texture); 3217 3422 end; 3218 3423 … … 3241 3446 end; 3242 3447 3448 procedure TBGRADefaultBitmap.FillEllipseLinearColorAntialias(AOrigin, AXAxis, 3449 AYAxis: TPointF; outercolor, innercolor: TBGRAPixel); 3450 var 3451 grad: TBGRAGradientScanner; 3452 affine: TBGRAAffineScannerTransform; 3453 begin 3454 grad := TBGRAGradientScanner.Create(innercolor,outercolor,gtRadial,PointF(0,0),PointF(1,0),True); 3455 affine := TBGRAAffineScannerTransform.Create(grad); 3456 affine.Fit(AOrigin,AXAxis,AYAxis); 3457 FillEllipseAntialias(AOrigin,AXAxis,AYAxis,affine); 3458 affine.Free; 3459 grad.Free; 3460 end; 3461 3243 3462 procedure TBGRADefaultBitmap.EraseEllipseAntialias(x, y, rx, ry: single; alpha: byte); 3244 3463 begin 3245 3464 FEraseMode := True; 3246 3465 FillEllipseAntialias(x, y, rx, ry, BGRA(0, 0, 0, alpha)); 3466 FEraseMode := False; 3467 end; 3468 3469 procedure TBGRADefaultBitmap.EraseEllipseAntialias(AOrigin, AXAxis, 3470 AYAxis: TPointF; alpha: byte); 3471 begin 3472 FEraseMode := True; 3473 FillEllipseAntialias(AOrigin, AXAxis, AYAxis, BGRA(0, 0, 0, alpha)); 3247 3474 FEraseMode := False; 3248 3475 end; … … 3707 3934 c: TBGRAPixel; options: TRoundRectangleOptions; pixelCenteredCoordinates: boolean); 3708 3935 begin 3709 if not pixelCenteredCoordinates then 3710 begin 3711 x -= 0.5; 3712 y -= 0.5; 3713 x2 -= 0.5; 3714 y2 -= 0.5; 3715 end; 3716 BGRAPolygon.FillRoundRectangleAntialias(self,x,y,x2,y2,rx,ry,options,c,False, LinearAntialiasing); 3936 BGRAPolygon.FillRoundRectangleAntialias(self,x,y,x2,y2,rx,ry,options,c,False, LinearAntialiasing, pixelCenteredCoordinates); 3717 3937 end; 3718 3938 … … 3720 3940 ry: single; texture: IBGRAScanner; options: TRoundRectangleOptions; pixelCenteredCoordinates: boolean); 3721 3941 begin 3722 if not pixelCenteredCoordinates then 3723 begin 3724 x -= 0.5; 3725 y -= 0.5; 3726 x2 -= 0.5; 3727 y2 -= 0.5; 3728 end; 3729 BGRAPolygon.FillRoundRectangleAntialiasWithTexture(self,x,y,x2,y2,rx,ry,options,texture, LinearAntialiasing); 3942 BGRAPolygon.FillRoundRectangleAntialiasWithTexture(self,x,y,x2,y2,rx,ry,options,texture, LinearAntialiasing, pixelCenteredCoordinates); 3730 3943 end; 3731 3944 … … 3733 3946 ry: single; alpha: byte; options: TRoundRectangleOptions; pixelCenteredCoordinates: boolean); 3734 3947 begin 3735 if not pixelCenteredCoordinates then 3736 begin 3737 x -= 0.5; 3738 y -= 0.5; 3739 x2 -= 0.5; 3740 y2 -= 0.5; 3741 end; 3742 BGRAPolygon.FillRoundRectangleAntialias(self,x,y,x2,y2,rx,ry,options,BGRA(0,0,0,alpha),True, LinearAntialiasing); 3948 BGRAPolygon.FillRoundRectangleAntialias(self,x,y,x2,y2,rx,ry,options,BGRA(0,0,0,alpha),True, LinearAntialiasing, pixelCenteredCoordinates); 3949 end; 3950 3951 procedure TBGRADefaultBitmap.Ellipse(x, y, rx, ry: single; c: TBGRAPixel; 3952 w: single; ADrawMode: TDrawMode); 3953 begin 3954 if (PenStyle = psClear) or (c.alpha = 0) or (w = 0) then exit; 3955 if (PenStyle = psSolid) then 3956 BGRAPolygon.BorderEllipse(self, x, y, rx, ry, w, c, FEraseMode, ADrawMode) 3957 else 3958 FillPoly(ComputeWidePolygon(ComputeEllipseContour(x,y,rx,ry),w),c, ADrawMode); 3959 end; 3960 3961 procedure TBGRADefaultBitmap.Ellipse(AOrigin, AXAxis, AYAxis: TPointF; 3962 c: TBGRAPixel; w: single; ADrawMode: TDrawMode); 3963 begin 3964 if (PenStyle = psClear) or (c.alpha = 0) or (w = 0) then exit; 3965 FillPoly(ComputeWidePolygon(ComputeEllipseContour(AOrigin, AXAxis, AYAxis),w),c,ADrawMode); 3743 3966 end; 3744 3967 … … 3755 3978 end; 3756 3979 3980 procedure TBGRADefaultBitmap.FillRoundRect(X1, Y1, X2, Y2: integer; DX, 3981 DY: integer; FillTexture: IBGRAScanner; ADrawMode: TDrawMode); 3982 begin 3983 BGRAFillRoundRectAliased(self,X1,Y1,X2,Y2,DX,DY,BGRAPixelTransparent,FillTexture,ADrawMode); 3984 end; 3985 3757 3986 {------------------------- Text functions ---------------------------------------} 3758 3987 … … 3781 4010 end; 3782 4011 4012 procedure TBGRADefaultBitmap.TextMultiline(ALeft, ATop, AWidth: single; sUTF8: string; 4013 c: TBGRAPixel; AAlign: TBidiTextAlignment; AVertAlign: TTextLayout; AParagraphSpacing: single); 4014 var 4015 layout: TBidiTextLayout; 4016 i: Integer; 4017 begin 4018 if FontBidiMode = fbmAuto then 4019 layout := TBidiTextLayout.Create(FontRenderer, sUTF8) 4020 else 4021 layout := TBidiTextLayout.Create(FontRenderer, sUTF8, GetFontRightToLeftFor(sUTF8)); 4022 for i := 0 to layout.ParagraphCount-1 do 4023 layout.ParagraphAlignment[i] := AAlign; 4024 layout.ParagraphSpacingBelow:= AParagraphSpacing; 4025 layout.AvailableWidth := AWidth; 4026 case AVertAlign of 4027 tlBottom: layout.TopLeft := PointF(ALeft,ATop-layout.TotalTextHeight); 4028 tlCenter: layout.TopLeft := PointF(ALeft,ATop-layout.TotalTextHeight/2); 4029 else layout.TopLeft := PointF(ALeft,ATop); 4030 end; 4031 layout.DrawText(self, c); 4032 layout.Free; 4033 end; 4034 4035 procedure TBGRADefaultBitmap.TextMultiline(ALeft, ATop, AWidth: single; 4036 sUTF8: string; ATexture: IBGRAScanner; AAlign: TBidiTextAlignment; 4037 AVertAlign: TTextLayout; AParagraphSpacing: single); 4038 var 4039 layout: TBidiTextLayout; 4040 i: Integer; 4041 begin 4042 if FontBidiMode = fbmAuto then 4043 layout := TBidiTextLayout.Create(FontRenderer, sUTF8) 4044 else 4045 layout := TBidiTextLayout.Create(FontRenderer, sUTF8, GetFontRightToLeftFor(sUTF8)); 4046 for i := 0 to layout.ParagraphCount-1 do 4047 layout.ParagraphAlignment[i] := AAlign; 4048 layout.ParagraphSpacingBelow:= AParagraphSpacing; 4049 layout.AvailableWidth := AWidth; 4050 case AVertAlign of 4051 tlBottom: layout.TopLeft := PointF(ALeft,ATop-layout.TotalTextHeight); 4052 tlCenter: layout.TopLeft := PointF(ALeft,ATop-layout.TotalTextHeight/2); 4053 else layout.TopLeft := PointF(ALeft,ATop); 4054 end; 4055 layout.DrawText(self, ATexture); 4056 layout.Free; 4057 end; 4058 3783 4059 procedure TBGRADefaultBitmap.TextOut(x, y: single; sUTF8: string; 3784 texture: IBGRAScanner; align: TAlignment );3785 begin 3786 FontRenderer.TextOut(self,x,y,CleanTextOutString(sUTF8),texture,align );4060 texture: IBGRAScanner; align: TAlignment; ARightToLeft: boolean); 4061 begin 4062 FontRenderer.TextOut(self,x,y,CleanTextOutString(sUTF8),texture,align, ARightToLeft); 3787 4063 end; 3788 4064 3789 4065 procedure TBGRADefaultBitmap.TextOut(x, y: single; sUTF8: string; 3790 c: TBGRAPixel; align: TAlignment );4066 c: TBGRAPixel; align: TAlignment; ARightToLeft: boolean); 3791 4067 begin 3792 4068 with (PointF(x,y)-GetFontAnchorRotatedOffset) do 3793 FontRenderer.TextOut(self,x,y,CleanTextOutString(sUTF8),c,align );4069 FontRenderer.TextOut(self,x,y,CleanTextOutString(sUTF8),c,align, ARightToLeft); 3794 4070 end; 3795 4071 … … 3812 4088 function TBGRADefaultBitmap.TextSize(sUTF8: string): TSize; 3813 4089 begin 3814 result := FontRenderer.TextSize(sUTF8); 4090 result := FontRenderer.TextSize(CleanTextOutString(sUTF8)); 4091 end; 4092 4093 function TBGRADefaultBitmap.TextAffineBox(sUTF8: string): TAffineBox; 4094 var size: TSize; 4095 m: TAffineMatrix; 4096 dy: single; 4097 begin 4098 dy := GetFontVerticalAnchorOffset; 4099 size := FontRenderer.TextSizeAngle(sUTF8, FontOrientation); 4100 m := AffineMatrixRotationDeg(-FontOrientation*0.1); 4101 result := TAffineBox.AffineBox(PointF(0,-dy), m*PointF(size.cx,-dy), m*PointF(0,size.cy-dy)); 4102 end; 4103 4104 function TBGRADefaultBitmap.TextSize(sUTF8: string; AMaxWidth: integer): TSize; 4105 begin 4106 result := FontRenderer.TextSize(sUTF8, AMaxWidth, GetFontRightToLeftFor(sUTF8)); 4107 end; 4108 4109 function TBGRADefaultBitmap.TextSize(sUTF8: string; AMaxWidth: integer; 4110 ARightToLeft: boolean): TSize; 4111 begin 4112 result := FontRenderer.TextSize(sUTF8, AMaxWidth, ARightToLeft); 4113 end; 4114 4115 function TBGRADefaultBitmap.TextFitInfo(sUTF8: string; AMaxWidth: integer 4116 ): integer; 4117 begin 4118 result := FontRenderer.TextFitInfo(sUTF8, AMaxWidth); 3815 4119 end; 3816 4120 … … 3874 4178 end; 3875 4179 4180 function TBGRADefaultBitmap.ComputeEllipseContour(AOrigin, AXAxis, 4181 AYAxis: TPointF; quality: single): ArrayOfTPointF; 4182 begin 4183 result := BGRAPath.ComputeEllipse(AOrigin,AXAxis,AYAxis, quality); 4184 end; 4185 3876 4186 function TBGRADefaultBitmap.ComputeEllipseBorder(x, y, rx, ry, w: single; quality: single): ArrayOfTPointF; 3877 4187 begin 3878 4188 result := ComputeWidePolygon(ComputeEllipseContour(x,y,rx,ry, quality),w); 4189 end; 4190 4191 function TBGRADefaultBitmap.ComputeEllipseBorder(AOrigin, AXAxis, 4192 AYAxis: TPointF; w: single; quality: single): ArrayOfTPointF; 4193 begin 4194 result := ComputeWidePolygon(ComputeEllipseContour(AOrigin,AXAxis,AYAxis, quality),w); 3879 4195 end; 3880 4196 … … 3980 4296 self.FillRect(X,Y,X+AMask.Width,Y+AMask.Height,scan,ADrawMode); 3981 4297 scan.Free; 4298 end; 4299 4300 procedure TBGRADefaultBitmap.EraseMask(x, y: integer; AMask: TBGRACustomBitmap; 4301 alpha: byte); 4302 var 4303 x0,y0,x2, y2, yb,xb, tx, delta: integer; 4304 p, psrc: PBGRAPixel; 4305 begin 4306 if (AMask = nil) or (alpha = 0) then exit; 4307 x0 := x; 4308 y0 := y; 4309 x2 := x+AMask.Width; 4310 y2 := y+AMask.Height; 4311 if not CheckClippedRectBounds(x,y,x2,y2) then exit; 4312 tx := x2 - x; 4313 Dec(x2); 4314 Dec(y2); 4315 4316 p := Scanline[y] + x; 4317 if FLineOrder = riloBottomToTop then 4318 delta := -Width 4319 else 4320 delta := Width; 4321 4322 for yb := y to y2 do 4323 begin 4324 psrc := AMask.ScanLine[yb-y0]+(x-x0); 4325 if alpha = 255 then 4326 begin 4327 for xb := tx-1 downto 0 do 4328 begin 4329 ErasePixelInline(p, psrc^.green); 4330 inc(p); 4331 inc(psrc); 4332 end; 4333 end else 4334 begin 4335 for xb := tx-1 downto 0 do 4336 begin 4337 ErasePixelInline(p, ApplyOpacity(psrc^.green,alpha)); 4338 inc(p); 4339 inc(psrc); 4340 end; 4341 end; 4342 dec(p, tx); 4343 Inc(p, delta); 4344 end; 4345 4346 InvalidateBitmap; 3982 4347 end; 3983 4348 … … 4175 4540 exit; 4176 4541 StartMask := $FFFFFFFF shl (X1 and 31); 4177 if X2 and 31 = 31 then 4178 EndMask := $FFFFFFFF 4542 case X2 and 31 of 4543 31: EndMask := $FFFFFFFF; 4544 30: EndMask := $7FFFFFFF; 4179 4545 else 4180 4546 EndMask := 1 shl ((X2 and 31) + 1) - 1; 4547 end; 4181 4548 StartPos := X1 shr 5 + AY * VisitedLineSize; 4182 4549 EndPos := X2 shr 5 + AY * VisitedLineSize; … … 4653 5020 end; 4654 5021 InvalidateBitmap; 5022 if (Source is TBGRADefaultBitmap) and Assigned(TBGRADefaultBitmap(Source).XorMask) then 5023 PutImage(x,y,TBGRADefaultBitmap(Source).XorMask,dmXor,AOpacity); 4655 5024 end; 4656 5025 dmDrawWithTransparency: … … 4680 5049 end; 4681 5050 InvalidateBitmap; 5051 if (Source is TBGRADefaultBitmap) and Assigned(TBGRADefaultBitmap(Source).XorMask) then 5052 PutImage(x,y,TBGRADefaultBitmap(Source).XorMask,dmXor,AOpacity); 4682 5053 end; 4683 5054 dmFastBlend: … … 4706 5077 end; 4707 5078 InvalidateBitmap; 5079 if (Source is TBGRADefaultBitmap) and Assigned(TBGRADefaultBitmap(Source).XorMask) then 5080 PutImage(x,y,TBGRADefaultBitmap(Source).XorMask,dmXor,AOpacity); 4708 5081 end; 4709 5082 dmXor: … … 4875 5248 procedure TBGRADefaultBitmap.StretchPutImage(ARect: TRect; 4876 5249 Source: TBGRACustomBitmap; mode: TDrawMode; AOpacity: byte); 5250 var noTransition: boolean; 4877 5251 begin 4878 5252 If (Source = nil) or (AOpacity = 0) then exit; … … 4880 5254 PutImage(ARect.Left,ARect.Top,Source,mode,AOpacity) 4881 5255 else 4882 BGRAResample.StretchPutImage(Source, ARect.Right-ARect.Left, ARect.Bottom-ARect.Top, self, ARect.left,ARect.Top, mode, AOpacity); 5256 begin 5257 noTransition:= (mode = dmXor) or ((mode in [dmDrawWithTransparency,dmFastBlend,dmSetExceptTransparent]) and 5258 (Source is TBGRADefaultBitmap) and 5259 Assigned(TBGRADefaultBitmap(Source).XorMask)); 5260 BGRAResample.StretchPutImage(Source, ARect.Right-ARect.Left, ARect.Bottom-ARect.Top, self, ARect.left,ARect.Top, mode, AOpacity, noTransition); 5261 if (mode in [dmDrawWithTransparency,dmFastBlend,dmSetExceptTransparent]) and Assigned(TBGRADefaultBitmap(Source).XorMask) then 5262 BGRAResample.StretchPutImage(TBGRADefaultBitmap(Source).XorMask, ARect.Right-ARect.Left, ARect.Bottom-ARect.Top, self, ARect.left,ARect.Top, dmXor, AOpacity, noTransition); 5263 end; 4883 5264 end; 4884 5265 4885 5266 { Duplicate bitmap content. Optionally, bitmap properties can be also duplicated } 4886 function TBGRADefaultBitmap.Duplicate(DuplicateProperties: Boolean = False ): TBGRACustomBitmap;5267 function TBGRADefaultBitmap.Duplicate(DuplicateProperties: Boolean = False; DuplicateXorMask: Boolean = False): TBGRACustomBitmap; 4887 5268 var Temp: TBGRADefaultBitmap; 4888 5269 begin … … 4893 5274 if DuplicateProperties then 4894 5275 CopyPropertiesTo(Temp); 5276 if DuplicateXorMask and Assigned(XorMask) then 5277 Temp.FXorMask := FXorMask.Duplicate(True) as TBGRADefaultBitmap; 4895 5278 Result := Temp; 4896 5279 end; … … 4908 5291 ABitmap.FontAntialias := FontAntialias; 4909 5292 ABitmap.FontOrientation := FontOrientation; 5293 ABitmap.FontBidiMode:= FontBidiMode; 4910 5294 ABitmap.LineCap := LineCap; 4911 5295 ABitmap.JoinStyle := JoinStyle; 4912 5296 ABitmap.FillMode := FillMode; 4913 5297 ABitmap.ClipRect := ClipRect; 5298 ABitmap.HotSpot := HotSpot; 4914 5299 end; 4915 5300 … … 5185 5570 end; 5186 5571 5572 function TBGRADefaultBitmap.GetHasSemiTransparentPixels: boolean; 5573 var 5574 n: integer; 5575 p: PBGRAPixel; 5576 begin 5577 p := Data; 5578 for n := NbPixels - 1 downto 0 do 5579 begin 5580 if (p^.alpha > 0) and (p^.alpha < 255) then 5581 begin 5582 result := true; 5583 exit; 5584 end; 5585 inc(p); 5586 end; 5587 result := false; 5588 end; 5589 5187 5590 function TBGRADefaultBitmap.GetAverageColor: TColor; 5188 5591 var … … 5318 5721 freemem(line); 5319 5722 InvalidateBitmap; 5723 5724 if Assigned(XorMask) then XorMask.VerticalFlip(ARect); 5320 5725 end; 5321 5726 … … 5351 5756 end; 5352 5757 InvalidateBitmap; 5758 5759 if Assigned(XorMask) then XorMask.HorizontalFlip(ARect); 5353 5760 end; 5354 5761 … … 5377 5784 end; 5378 5785 end; 5786 5787 if Assigned(XorMask) then TBGRADefaultBitmap(result).FXorMask := self.XorMask.RotateCW; 5379 5788 end; 5380 5789 … … 5403 5812 end; 5404 5813 end; 5814 5815 if Assigned(XorMask) then TBGRADefaultBitmap(result).FXorMask := self.XorMask.RotateCCW; 5405 5816 end; 5406 5817 … … 5549 5960 end; 5550 5961 InvalidateBitmap; 5962 end; 5963 5964 function TBGRADefaultBitmap.GetMaskFromAlpha: TBGRACustomBitmap; 5965 var y,x: integer; 5966 psrc, pdest: PBGRAPixel; 5967 begin 5968 result := BGRABitmapFactory.Create(Width,Height); 5969 for y := 0 to self.Height-1 do 5970 begin 5971 psrc := self.ScanLine[y]; 5972 pdest := result.ScanLine[y]; 5973 for x := 0 to self.Width-1 do 5974 begin 5975 pdest^ := BGRA(psrc^.alpha,psrc^.alpha,psrc^.alpha); 5976 inc(psrc); 5977 inc(pdest); 5978 end; 5979 end; 5551 5980 end; 5552 5981 … … 5963 6392 end; 5964 6393 5965 function TBGRAPtrBitmap.Duplicate(DuplicateProperties: Boolean = False ): TBGRACustomBitmap;6394 function TBGRAPtrBitmap.Duplicate(DuplicateProperties: Boolean = False; DuplicateXorMask: Boolean = False): TBGRACustomBitmap; 5966 6395 begin 5967 6396 Result := NewBitmap(Width, Height); 5968 6397 if DuplicateProperties then CopyPropertiesTo(TBGRADefaultBitmap(Result)); 6398 if DuplicateXorMask and Assigned(XorMask) then 6399 TBGRADefaultBitmap(Result).FXorMask := FXorMask.Duplicate(True); 5969 6400 end; 5970 6401 … … 6007 6438 end; 6008 6439 6009 procedure TBGRAPtrBitmap.LoadFromDevice(DC: System.THandle);6010 begin 6011 CannotResize;6012 end; 6013 6014 procedure TBGRAPtrBitmap.LoadFromDevice(DC: System.THandle; ARect: TRect);6015 begin 6016 CannotResize;6440 procedure TBGRAPtrBitmap.LoadFromDevice(DC: HDC); 6441 begin 6442 NotImplemented; 6443 end; 6444 6445 procedure TBGRAPtrBitmap.LoadFromDevice(DC: HDC; ARect: TRect); 6446 begin 6447 NotImplemented; 6017 6448 end; 6018 6449
Note:
See TracChangeset
for help on using the changeset viewer.