1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| Procedure TBZBitmapBlurFilters.FastBlur;
Var
x1, y1, x2, y2, XSteps, YSteps, w, h: Integer;
DstColor: TBZColor;
xx, yy, totalsize, nextLineInc: Integer;
Line0, Line2, PixelPtr, MaskPtr : PBZColor;
AColor, AColor1, AColor0, AColor2: TBZColor;
Delta : Single;
Begin
nextlineInc := 0;
TotalSize := 0;
x1 := 0;
y1 := 0;
x2 := 0;
y2 := 0;
w := 0;
h := 0;
getClippingBoundInfos(x1, y1, x2, y2, w, h, totalsize, nextLineInc); // Permet de calculer les incréments
Line0 := OwnerBitmap.GetPixelPtr(X1, Y1);
PixelPtr := OwnerBitmap.GetPixelPtr(X1, Y1 + 1);
Line2 := OwnerBitmap.GetPixelPtr(X1, Y1 + 2);
XSteps := (x2 - x1) - 2;
YSteps := (y2 - y1) - 2;
totalsize := (XSteps * YSteps);
Inc(XSteps);
xx := 0;
yy := 0;
While yy < TotalSize Do // TotalSize nombre de pixel total = Largeur*hauteur
Begin
AColor1 := PBZColor(PixelPtr + 1)^;
AColor := PBZColor(PixelPtr - 1)^;
AColor0 := PBZColor(Line0)^;
AColor2 := PBZColor(Line2)^;
DstColor.Red := (AColor0.Red + AColor2.Red + AColor.Red + AColor1.Red) Shr 2;
DstColor.Green := (AColor0.Green + AColor2.Green + AColor.Green + AColor1.Green) Shr 2;
DstColor.Blue := (AColor0.Blue + AColor2.Blue + AColor.Blue + AColor1.Blue) Shr 2;
// Alpha
DstColor.Alpha := AColor0.Alpha;
PixelPtr^ := DstColor;
Inc(PixelPtr);
Inc(Line0);
Inc(Line2);
Inc(xx);
If xx > XSteps Then
Begin
xx := 0;
Inc(PixelPtr, NextLineInc);
Inc(Line0, NextLineInc);
Inc(Line2, NextLineInc);
End;
Inc(yy);
End;
End;
End;
{ Note TBZColor = Record Red, Green, Blue, Alpha : Byte End; } |
Partager