Skip to content

Commit 2962a10

Browse files
Updated Image32 library to 3.0 for rendering SVG
1 parent 8eb468e commit 2962a10

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+789
-606
lines changed

Ext/SVGIconImageList/Image32/source/Image32_CQ.pas renamed to Ext/SVGIconImageList/Image32/source/Img32.CQ.pas

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
unit Image32_CQ;
1+
unit Img32.CQ;
22

33
(*******************************************************************************
44
* Author : Angus Johnson *
5-
* Version : 2.0 *
6-
* Date : 6 March 2021 *
5+
* Version : 3.0 *
6+
* Date : 20 July 2021 *
77
* Website : http://www.angusj.com *
88
* Copyright : Angus Johnson 2019-2021 *
99
* Purpose : Color reduction for TImage32 *
@@ -13,11 +13,11 @@
1313

1414
interface
1515

16-
{$I Image32.inc}
16+
{$I Img32.inc}
1717

1818
uses
1919
{$IFDEF MSWINDOWS} Windows,{$ENDIF}
20-
SysUtils, Classes, Math, Image32, Image32_Vector;
20+
SysUtils, Classes, Types, Math, Img32, Img32.Vector;
2121

2222
function MakePalette(image: TImage32;
2323
MaxColors: integer): TArrayOfColor32; overload;
@@ -947,13 +947,13 @@ procedure DrawPalette(image: TImage32; const palette: TArrayOfColor32);
947947
if len < 16 then w := len else w := 16;
948948
h := (len +15) div 16;
949949
image.SetSize(w * 16, h * 16);
950-
rec := Image32_Vector.Rect(0,0,16,16);
950+
rec := Img32.Vector.Rect(0,0,16,16);
951951
for i := 0 to len -1 do
952952
begin
953953
image.FillRect(rec, palette[i] or $FF000000);
954954
if (i + 1) mod w = 0 then
955-
OffsetRect(rec, -15 * w, 16) else
956-
OffsetRect(rec, 16, 0);
955+
Types.OffsetRect(rec, -15 * w, 16) else
956+
Types.OffsetRect(rec, 16, 0);
957957
end;
958958
end;
959959

@@ -1016,7 +1016,7 @@ procedure MakeDitherTables;
10161016
img := TImage32.Create(i * 16, 16);
10171017
for i := 0 to i -1 do
10181018
DrawPolygon(img, Rectangle(i * 16, 0, (i +1) * 16, 16),
1019-
Image32_Vector.frEvenOdd, pal[i]);
1019+
Img32.Vector.frEvenOdd, pal[i]);
10201020
img.SaveToFile('tmp.png');
10211021
img.Free;
10221022
*)

Ext/SVGIconImageList/Image32/source/Image32_Clipper.pas renamed to Ext/SVGIconImageList/Image32/source/Img32.Clipper.pas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
unit Image32_Clipper;
1+
unit Img32.Clipper;
22

33
(*******************************************************************************
44
* Author : Angus Johnson *
@@ -14,7 +14,7 @@ interface
1414

1515
uses
1616
ClipperCore, Clipper, ClipperOffset,
17-
Image32, Image32_Draw, Image32_Vector;
17+
Img32, Img32.Draw, Img32.Vector;
1818

1919
//nb: InflatePath assumes that there's consistent winding where
2020
//outer paths wind in one direction and inner paths in the other

Ext/SVGIconImageList/Image32/source/Image32_Draw.pas renamed to Ext/SVGIconImageList/Image32/source/Img32.Draw.pas

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
unit Image32_Draw;
1+
unit Img32.Draw;
22

33
(*******************************************************************************
44
* Author : Angus Johnson *
5-
* Version : 2.25 *
6-
* Date : 30 June 2021 *
5+
* Version : 3.0 *
6+
* Date : 20 July 2021 *
77
* Website : http://www.angusj.com *
88
* Copyright : Angus Johnson 2019-2021 *
99
* *
@@ -16,16 +16,16 @@
1616

1717
interface
1818

19-
{$I Image32.inc}
19+
{$I Img32.inc}
2020

2121
{.$DEFINE MemCheck} //for debugging only (adds a minimal cost to performance)
2222

2323
uses
24-
SysUtils, Classes, Types, Math, Image32, Image32_Vector,
25-
Image32_Transform; //experimental;
24+
SysUtils, Classes, Types, Math, Img32, Img32.Vector,
25+
Img32.Transform; //experimental;
2626

2727
type
28-
TFillRule = Image32_Vector.TFillRule;
28+
TFillRule = Img32.Vector.TFillRule;
2929

3030
//TGradientColor: used internally by both
3131
//TLinearGradientRenderer and TRadialGradientRenderer
@@ -280,9 +280,9 @@ TBarycentricRenderer = class(TCustomRenderer)
280280

281281
//Both DrawBoolMask and DrawAlphaMask require
282282
//'mask' length to equal 'img' width * height
283-
procedure DrawBoolMask(img: TIMage32;
283+
procedure DrawBoolMask(img: TImage32;
284284
const mask: TArrayOfByte; color: TColor32 = clBlack32);
285-
procedure DrawAlphaMask(img: TIMage32;
285+
procedure DrawAlphaMask(img: TImage32;
286286
const mask: TArrayOfByte; color: TColor32 = clBlack32);
287287

288288
procedure Rasterize(const paths: TPathsD;
@@ -292,7 +292,7 @@ implementation
292292

293293
{$IFDEF MemCheck}
294294
resourcestring
295-
sMemCheckError = 'Image32_Draw: Memory allocation error';
295+
sMemCheckError = 'Img32.Draw: Memory allocation error';
296296
{$ENDIF}
297297

298298
type
@@ -341,7 +341,7 @@ procedure ApplyClearType(img: TImage32;
341341
begin
342342
// Precondition: the background to text drawn onto 'img' must be transparent
343343

344-
// multiplication tables (see Image32.pas)
344+
// multiplication tables (see Img32.pas)
345345
// 85 + (2 * 57) + (2 * 28) == 255
346346
primeTbl := PByteArray(@MulTable[85 + centerWeighting *2]);
347347
nearTbl := PByteArray(@MulTable[57]);
@@ -961,7 +961,7 @@ procedure Rasterize(const paths: TPathsD; const clipRec: TRect;
961961
begin
962962
//See also https://nothings.org/gamedev/rasterize/
963963
if not assigned(renderer) then Exit;
964-
clipRec2 := Image32_Vector.IntersectRect(clipRec, GetBounds(paths));
964+
Types.IntersectRect(clipRec2, clipRec, GetBounds(paths));
965965
if IsEmptyRect(clipRec2) then Exit;
966966

967967
paths2 := OffsetPath(paths, -clipRec2.Left, -clipRec2.Top);
@@ -1732,6 +1732,7 @@ procedure DrawLine(img: TImage32; const lines: TPathsD;
17321732
if not assigned(lines) then exit;
17331733
if (lineWidth < MinStrokeWidth) then lineWidth := MinStrokeWidth;
17341734
lines2 := Outline(lines, lineWidth, joinStyle, endStyle, miterLimit);
1735+
17351736
cr := TColorRenderer.Create(color);
17361737
try
17371738
if cr.Initialize(img) then
@@ -2026,7 +2027,7 @@ procedure ErasePolygon(img: TImage32; const polygons: TPathsD;
20262027
end;
20272028
//------------------------------------------------------------------------------
20282029

2029-
procedure DrawBoolMask(img: TIMage32; const mask: TArrayOfByte; color: TColor32);
2030+
procedure DrawBoolMask(img: TImage32; const mask: TArrayOfByte; color: TColor32);
20302031
var
20312032
i, len: integer;
20322033
pc: PColor32;
@@ -2050,7 +2051,7 @@ procedure DrawBoolMask(img: TIMage32; const mask: TArrayOfByte; color: TColor32)
20502051
end;
20512052
//------------------------------------------------------------------------------
20522053

2053-
procedure DrawAlphaMask(img: TIMage32; const mask: TArrayOfByte; color: TColor32);
2054+
procedure DrawAlphaMask(img: TImage32; const mask: TArrayOfByte; color: TColor32);
20542055
var
20552056
i, len: integer;
20562057
pc: PColor32;

Ext/SVGIconImageList/Image32/source/Image32_Extra.pas renamed to Ext/SVGIconImageList/Image32/source/Img32.Extra.pas

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
unit Image32_Extra;
1+
unit Img32.Extra;
22

33
(*******************************************************************************
44
* Author : Angus Johnson *
5-
* Version : 2.25 *
6-
* Date : 28 June 2021 *
5+
* Version : 3.0 *
6+
* Date : 20 July 2021 *
77
* Website : http://www.angusj.com *
88
* Copyright : Angus Johnson 2019-2021 *
99
* *
@@ -17,11 +17,11 @@
1717

1818
interface
1919

20-
{$I Image32.inc}
20+
{$I Img32.inc}
2121

2222
uses
2323
SysUtils, Classes, Math, Types,
24-
Image32, Image32_Draw, Image32_Vector;
24+
Img32, Img32.Draw, Img32.Vector;
2525

2626
type
2727
TButtonShape = (bsRound, bsSquare, bsDiamond);
@@ -145,9 +145,9 @@ implementation
145145

146146
uses
147147
{$IFNDEF MSWINDOWS}
148-
Image32_FMX,
148+
Img32.FMX,
149149
{$ENDIF}
150-
Image32_Transform;
150+
Img32.Transform;
151151

152152
const
153153
FloodFillDefaultRGBTolerance: byte = 20;
@@ -269,7 +269,7 @@ procedure DrawShadow(img: TImage32; const polygons: TPathsD;
269269
x := depth * x;
270270
y := depth * y;
271271
blurSize := Max(1,Round(depth / 4));
272-
rec := Image32_Vector.InflateRect(rec, Ceil(depth*2), Ceil(depth*2));
272+
Img32.Vector.InflateRect(rec, Ceil(depth*2), Ceil(depth*2));
273273
polys := OffsetPath(polygons, -rec.Left, -rec.Top);
274274
shadowPolys := OffsetPath(polys, x, y);
275275
shadowImg := TImage32.Create(RectWidth(rec), RectHeight(rec));
@@ -305,7 +305,7 @@ procedure DrawGlow(img: TImage32; const polygons: TPathsD;
305305
rec := GetBounds(polygons);
306306
glowPolys := OffsetPath(polygons,
307307
blurRadius -rec.Left +1, blurRadius -rec.Top +1);
308-
rec := Image32_Vector.InflateRect(rec, blurRadius +1, blurRadius +1);
308+
Img32.Vector.InflateRect(rec, blurRadius +1, blurRadius +1);
309309
glowImg := TImage32.Create(RectWidth(rec), RectHeight(rec));
310310
try
311311
DrawPolygon(glowImg, glowPolys, fillRule, color);
@@ -397,15 +397,15 @@ procedure GridBackground(img: TImage32; majorInterval, minorInterval: integer;
397397
path[0] := PointD(x, 0); path[1] := PointD(x, h);;
398398
for i := 1 to (w div minorInterval) do
399399
begin
400-
Image32_Draw.DrawLine(img, path, 1, minColor, esSquare);
400+
Img32.Draw.DrawLine(img, path, 1, minColor, esSquare);
401401
path[0].X := path[0].X + minorInterval;
402402
path[1].X := path[1].X + minorInterval;
403403
end;
404404
y := minorInterval;
405405
path[0] := PointD(0, y); path[1] := PointD(w, y);
406406
for i := 1 to (h div minorInterval) do
407407
begin
408-
Image32_Draw.DrawLine(img, path, 1, minColor, esSquare);
408+
Img32.Draw.DrawLine(img, path, 1, minColor, esSquare);
409409
path[0].Y := path[0].Y + minorInterval;
410410
path[1].Y := path[1].Y + minorInterval;
411411
end;
@@ -416,15 +416,15 @@ procedure GridBackground(img: TImage32; majorInterval, minorInterval: integer;
416416
path[0] := PointD(x, 0); path[1] := PointD(x, h);;
417417
for i := 1 to (w div majorInterval) do
418418
begin
419-
Image32_Draw.DrawLine(img, path, 1, majColor, esSquare);
419+
Img32.Draw.DrawLine(img, path, 1, majColor, esSquare);
420420
path[0].X := path[0].X + majorInterval;
421421
path[1].X := path[1].X + majorInterval;
422422
end;
423423
y := majorInterval;
424424
path[0] := PointD(0, y); path[1] := PointD(w, y);
425425
for i := 1 to (h div majorInterval) do
426426
begin
427-
Image32_Draw.DrawLine(img, path, 1, majColor, esSquare);
427+
Img32.Draw.DrawLine(img, path, 1, majColor, esSquare);
428428
path[0].Y := path[0].Y + majorInterval;
429429
path[1].Y := path[1].Y + majorInterval;
430430
end;
@@ -504,7 +504,7 @@ procedure RedEyeRemove(img: TImage32; const rect: TRect);
504504
else if k < 230 then k := 3
505505
else k := 4;
506506
cutoutRec := rect;
507-
Image32_Vector.InflateRect(cutoutRec, k, k);
507+
Img32.Vector.InflateRect(cutoutRec, k, k);
508508

509509
cutout := TImage32.Create(img, cutoutRec);
510510
mask := TImage32.Create(cutout.Width, cutout.Height);
@@ -513,7 +513,7 @@ procedure RedEyeRemove(img: TImage32; const rect: TRect);
513513
//fill behind the cutout with black also
514514
//blurring the fill to soften its edges
515515
rect3 := cutout.Bounds;
516-
Image32_Vector.InflateRect(rect3, -k, -k);
516+
Img32.Vector.InflateRect(rect3, -k, -k);
517517
path := Ellipse(rect3);
518518
DrawPolygon(mask, path, frNonZero, clBlack32);
519519
//given the very small area and small radius of the blur, the
@@ -722,7 +722,7 @@ function DrawButton(img: TImage32; const pt: TPointD;
722722
end;
723723
bsSquare:
724724
begin
725-
rec := InflateRect(rec, -1,-1);
725+
Img32.Vector.InflateRect(rec, -1,-1);
726726
Result := Rectangle(rec);
727727
end;
728728
else
@@ -2516,7 +2516,7 @@ procedure GaussianBlur(img: TImage32; rec: TRect; radius: Integer);
25162516
row: PColor32Array;
25172517
wcRow: PWeightedColorArray;
25182518
begin
2519-
rec := Image32_Vector.IntersectRect(rec, img.Bounds);
2519+
Types.IntersectRect(rec, rec, img.Bounds);
25202520
if IsEmptyRect(rec) or (radius < 1) then Exit
25212521
else if radius > MaxBlur then radius := MaxBlur;
25222522

@@ -2682,7 +2682,7 @@ procedure FastGaussianBlur(img: TImage32;
26822682
p: PColor32;
26832683
begin
26842684
if not Assigned(img) then Exit;
2685-
rec2 := Image32_Vector.IntersectRect(rec, img.Bounds);
2685+
Types.IntersectRect(rec2, rec, img.Bounds);
26862686
if IsEmptyRect(rec2) then Exit;
26872687
blurFullImage := RectsEqual(rec2, img.Bounds);
26882688

Ext/SVGIconImageList/Image32/source/Image32_FMX.pas renamed to Ext/SVGIconImageList/Image32/source/Img32.FMX.pas

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
unit Image32_FMX;
1+
unit Img32.FMX;
22

33
(*******************************************************************************
44
* Author : Angus Johnson *
5-
* Version : 2.27 *
6-
* Date : 15 July 2021 *
5+
* Version : 3.0 *
6+
* Date : 20 July 2021 *
77
* Website : http://www.angusj.com *
88
* Copyright : Angus Johnson 2019-2021 *
99
* Purpose : Image file format support for TImage32 and FMX *
@@ -12,9 +12,9 @@
1212

1313
interface
1414

15-
{$I Image32.inc}
15+
{$I Img32.inc}
1616
uses
17-
SysUtils, Classes, Math, Image32, System.Rtti,
17+
SysUtils, Classes, Math, Img32, System.Rtti,
1818
System.Generics.Collections, System.Generics.Defaults,
1919
FMX.Platform, FMX.Types, FMX.Surfaces, FMX.Graphics;
2020

Ext/SVGIconImageList/Image32/source/Image32_BMP.pas renamed to Ext/SVGIconImageList/Image32/source/Img32.Fmt.BMP.pas

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
unit Image32_BMP;
1+
unit Img32.Fmt.BMP;
22

33
(*******************************************************************************
44
* Author : Angus Johnson *
5-
* Version : 2.27 *
6-
* Date : 15 July 2021 *
5+
* Version : 3.0 *
6+
* Date : 20 July 2021 *
77
* Website : http://www.angusj.com *
88
* Copyright : Angus Johnson 2019-2021 *
99
* Purpose : BMP file format extension for TImage32 *
@@ -12,10 +12,10 @@
1212

1313
interface
1414

15-
{$I Image32.inc}
15+
{$I Img32.inc}
1616

1717
uses
18-
{$IFDEF MSWINDOWS} Windows,{$ENDIF} SysUtils, Classes, Math, Image32;
18+
{$IFDEF MSWINDOWS} Windows,{$ENDIF} SysUtils, Classes, Math, Img32;
1919

2020
type
2121

Ext/SVGIconImageList/Image32/source/Image32_GIF.pas renamed to Ext/SVGIconImageList/Image32/source/Img32.Fmt.GIF.pas

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
unit Image32_GIF;
1+
unit Img32.Fmt.GIF;
22

33
(*******************************************************************************
44
* Author : Angus Johnson *
5-
* Version : 2.27 *
6-
* Date : 15 July 2021 *
5+
* Version : 3.0 *
6+
* Date : 20 July 2021 *
77
* Website : http://www.angusj.com *
88
* Copyright : Angus Johnson 2019-2021 *
99
* Purpose : GIF file format extension for TImage32 *
@@ -12,14 +12,14 @@
1212

1313
interface
1414

15-
{$I Image32.inc}
15+
{$I Img32.inc}
1616

1717
{$IF COMPILERVERSION = 15}
1818
implementation
1919
{$ELSE}
2020

2121
uses
22-
SysUtils, Classes, Windows, Math, Image32, Graphics,
22+
SysUtils, Classes, Windows, Math, Img32, Graphics,
2323
{$IFDEF DELPHI_GIF} GifImg {$ELSE} GifImage {$ENDIF};
2424

2525
type

0 commit comments

Comments
 (0)