@@ -1452,67 +1452,64 @@ function TSimbaImage.Blend(Points: TPointArray; Radius: Integer): TSimbaImage;
14521452 Result := Blend(Points, Radius, []);
14531453end ;
14541454
1455+
14551456function TSimbaImage.Blend (Points: TPointArray; Radius: Integer; IgnorePoints: TPointArray): TSimbaImage;
14561457var
14571458 P: TPoint;
14581459 X, Y, Count: Integer;
14591460 Area: TBox;
1460- SumR, SumG, SumB: UInt64;
1461- Skip, Ignored: TBooleanArray;
1461+ R, G, B: Int32;
1462+ BGRA: TColorBGRA;
1463+ Skip: TBooleanArray;
14621464begin
14631465 Result := Copy();
14641466
1465- SetLength(Skip, FWidth*FHeight);
1466- SetLength(Ignored, FWidth*FHeight);
1467-
1467+ SetLength(Skip, FWidth * FHeight);
14681468 for P in IgnorePoints do
1469- Ignored[P.Y * FWidth + P.X] := True;
1470- for P in Points do
14711469 Skip[P.Y * FWidth + P.X] := True;
14721470
14731471 for P in Points do
14741472 begin
1473+ if Skip[
14751474 Area.X1 := Max(P.X - Radius, 0 );
14761475 Area.Y1 := Max(P.Y - Radius, 0 );
1477- Area.X2 := Min(P.X + Radius, FWidth - 1 );
1478- Area.Y2 := Min(P.Y + Radius, FHeight - 1 );
1476+ Area.X2 := Min(P.X + Radius, FWidth- 1 );
1477+ Area.Y2 := Min(P.Y + Radius, FHeight- 1 );
14791478
14801479 Count := 0 ;
1481- SumR := 0 ; SumG := 0 ; SumB := 0 ;
1480+
1481+ R := 0 ;
1482+ G := 0 ;
1483+ B := 0 ;
14821484
14831485 for X := Area.X1 to Area.X2 do
14841486 for Y := Area.Y1 to Area.Y2 do
14851487 begin
1486- if Ignored[Y * FWidth + X] then
1487- Continue;
14881488 if Skip[Y * FWidth + X] then
14891489 Continue;
1490+ BGRA := FData[Y * FWidth + X];
1491+ if (BGRA = ALPHA_OPAQUE) then
1492+ Continue;
1493+
1494+ Inc(R, BGRA.R);
1495+ Inc(G, BGRA.G);
1496+ Inc(B, BGRA.B);
14901497
1491- with FData[Y * FWidth + X] do
1492- begin
1493- Inc(SumR, R);
1494- Inc(SumG, G);
1495- Inc(SumB, B);
1496- end ;
14971498 Inc(Count);
14981499 end ;
14991500
1500- if ( Count > 1 ) then
1501+ if Count > 0 then
15011502 begin
1502- with Result.Data[P.Y * FWidth + P.X] do
1503- begin
1504- R := SumR div Count;
1505- G := SumG div Count;
1506- B := SumB div Count;
1507- A := ALPHA_OPAQUE;
1508- end ;
1503+ BGRA.R := R div Count;
1504+ BGRA.G := G div Count;
1505+ BGRA.B := B div Count;
15091506
1510- Skip[P.Y * FWidth + P.X] := False;
1511- end else
1512- Result.Data[P.Y * FWidth + P.X] := FData[P.Y * FWidth + P.X];
1507+ Result.FData[P.Y * FWidth + P.X] := BGRA;
1508+ end ;
15131509 end ;
15141510end ;
15151511
1512+
15161513function TSimbaImage.Downsample (Scale: Integer): TSimbaImage;
15171514begin
15181515 Result := SimbaImage_Downsample(Self, Scale);
0 commit comments