فهرست منبع

o patch by Ondrej Pokorny: adds a simple box/pixelate interpolation to fcl-image, resolves #32665

git-svn-id: trunk@37622 -
florian 7 سال پیش
والد
کامیت
32f305d2a8
2فایلهای تغییر یافته به همراه21 افزوده شده و 0 حذف شده
  1. 7 0
      packages/fcl-image/src/fpcanvas.pp
  2. 14 0
      packages/fcl-image/src/fpinterpolation.inc

+ 7 - 0
packages/fcl-image/src/fpcanvas.pp

@@ -191,6 +191,13 @@ type
     property Image : TFPCustomImage read fimage;
   end;
 
+  { TFPBoxInterpolation }
+
+  TFPBoxInterpolation = class(TFPCustomInterpolation)
+  public
+    procedure Execute (x,y,w,h:integer); override;
+  end;
+
   { TFPBaseInterpolation }
 
   TFPBaseInterpolation = class (TFPCustomInterpolation)

+ 14 - 0
packages/fcl-image/src/fpinterpolation.inc

@@ -6,6 +6,20 @@ begin
   fcanvas := acanvas;
 end;
 
+{ TFPBoxInterpolation }
+
+procedure TFPBoxInterpolation.Execute(x,y,w,h:integer);
+var
+  dx, dy, iw, ih: Integer;
+begin
+  iw := Image.Width;
+  ih := Image.Height;
+
+  for dx := 0 to w-1 do
+    for dy := 0 to h-1 do
+      Canvas.Colors[x+dx,y+dy] := Image.Colors[dx*iw div w, dy*ih div h];
+end;
+
 { TFPBaseInterpolation }
 
 procedure TFPBaseInterpolation.CreatePixelWeights(OldSize, NewSize: integer;