فهرست منبع

Added more filters in bcfilters.pas

lainz 11 سال پیش
والد
کامیت
ad8b7ffd7a
3فایلهای تغییر یافته به همراه721 افزوده شده و 61 حذف شده
  1. 659 49
      bcfilters.pas
  2. 49 5
      test/test_bccontrols/test_bcfilters/unit1.lfm
  3. 13 7
      test/test_bccontrols/test_bcfilters/unit1.pas

+ 659 - 49
bcfilters.pas

@@ -1,3 +1,5 @@
+unit bcfilters;
+
 {
 {
 // all pixels //
 // all pixels //
 var
 var
@@ -35,14 +37,12 @@ begin
   Bitmap.InvalidateBitmap;
   Bitmap.InvalidateBitmap;
 }
 }
 
 
-unit bcfilters;
-
 {$mode objfpc}{$H+}
 {$mode objfpc}{$H+}
 
 
 interface
 interface
 
 
 uses
 uses
-  Classes, SysUtils, StrUtils, LCLProc, Math, BGRABitmap, BGRABitmapTypes;
+  Classes, SysUtils, LCLProc, Math, BGRABitmap, BGRABitmapTypes;
 
 
 type
 type
   TBCSimpleFilter = (bcsNone, bcsInvert, bcsGrayScale, bcsGrayScaleA,
   TBCSimpleFilter = (bcsNone, bcsInvert, bcsGrayScale, bcsGrayScaleA,
@@ -50,7 +50,10 @@ type
     bcsNoiseA, bcsNoiseBW, bcsNoiseBWA, bcsTVScanLinesH, bcsTVScanLinesV,
     bcsNoiseA, bcsNoiseBW, bcsNoiseBWA, bcsTVScanLinesH, bcsTVScanLinesV,
     bcsCheckeredL, bcsCheckeredR, bcsBlackAndWhite, bcsInstagram1,
     bcsCheckeredL, bcsCheckeredR, bcsBlackAndWhite, bcsInstagram1,
     bcsInstagram2, bcsInstagram3, bcsInstagram4, bcsInstagram5, bcsInstagram6,
     bcsInstagram2, bcsInstagram3, bcsInstagram4, bcsInstagram5, bcsInstagram6,
-    bcsPhotoNoise, bcsPolaroid, bcsMovement);
+    bcsPhotoNoise, bcsPolaroid, bcsMovement, bcsRBG, bcsGRB, bcsGBR,
+    bcsBRG, bcsBGR, bcsRRG, bcsRGR, bcsGRR, bcsRRB, bcsRBR, bcsBRR,
+    bcsGGR, bcsGRG, bcsRGG, bcsGGB, bcsGBG, bcsBGG, bcsBBR, bcsBRB,
+    bcsRBB, bcsBBG, bcsBGB, bcsGBB, bcsRRR, bcsGGG, bcsBBB);
 
 
 const
 const
   BCSimpleFilterStr: array [TBCSimpleFilter] of string =
   BCSimpleFilterStr: array [TBCSimpleFilter] of string =
@@ -58,11 +61,42 @@ const
     'Noise', 'NoiseA', 'NoiseBW', 'NoiseBWA', 'TVScanLinesH', 'TVScanLinesV',
     'Noise', 'NoiseA', 'NoiseBW', 'NoiseBWA', 'TVScanLinesH', 'TVScanLinesV',
     'CheckeredL', 'CheckeredR', 'BlackAndWhite', 'Instagram1', 'Instagram2',
     'CheckeredL', 'CheckeredR', 'BlackAndWhite', 'Instagram1', 'Instagram2',
     'Instagram3', 'Instagram4', 'Instagram5', 'Instagram6', 'PhotoNoise',
     'Instagram3', 'Instagram4', 'Instagram5', 'Instagram6', 'PhotoNoise',
-    'Polaroid', 'Movement');
+    'Polaroid', 'Movement', 'RBG', 'GRB', 'GBR', 'BRG', 'BGR', 'RRG',
+    'RGR', 'GRR', 'RRB', 'RBR', 'BRR', 'GGR', 'GRG', 'RGG', 'GGB', 'GBG',
+    'BGG', 'BBR', 'BRB', 'RBB', 'BBG', 'BGB', 'GBB', 'RRR', 'GGG', 'BBB');
 
 
 function StrToTBCSimpleFilter(const s: ansistring): TBCSimpleFilter;
 function StrToTBCSimpleFilter(const s: ansistring): TBCSimpleFilter;
 procedure BCSimpleFilterStrList(s: TStrings);
 procedure BCSimpleFilterStrList(s: TStrings);
 
 
+procedure FilterRGB(Bitmap: TBGRABitmap; R, G, B: byte);
+
+procedure RBG(Bitmap: TBGRABitmap);
+procedure GRB(Bitmap: TBGRABitmap);
+procedure GBR(Bitmap: TBGRABitmap);
+procedure BRG(Bitmap: TBGRABitmap);
+procedure BGR(Bitmap: TBGRABitmap);
+procedure RRG(Bitmap: TBGRABitmap);
+procedure RGR(Bitmap: TBGRABitmap);
+procedure GRR(Bitmap: TBGRABitmap);
+procedure RRB(Bitmap: TBGRABitmap);
+procedure RBR(Bitmap: TBGRABitmap);
+procedure BRR(Bitmap: TBGRABitmap);
+procedure GGR(Bitmap: TBGRABitmap);
+procedure GRG(Bitmap: TBGRABitmap);
+procedure RGG(Bitmap: TBGRABitmap);
+procedure GGB(Bitmap: TBGRABitmap);
+procedure GBG(Bitmap: TBGRABitmap);
+procedure BGG(Bitmap: TBGRABitmap);
+procedure BBR(Bitmap: TBGRABitmap);
+procedure BRB(Bitmap: TBGRABitmap);
+procedure RBB(Bitmap: TBGRABitmap);
+procedure BBG(Bitmap: TBGRABitmap);
+procedure BGB(Bitmap: TBGRABitmap);
+procedure GBB(Bitmap: TBGRABitmap);
+procedure RRR(Bitmap: TBGRABitmap);
+procedure GGG(Bitmap: TBGRABitmap);
+procedure BBB(Bitmap: TBGRABitmap);
+
 { Invert colors, keep alpha }
 { Invert colors, keep alpha }
 procedure Invert(Bitmap: TBGRABitmap);
 procedure Invert(Bitmap: TBGRABitmap);
 { Invert colors, advanced options }
 { Invert colors, advanced options }
@@ -131,7 +165,7 @@ procedure PhotoNoise(Bitmap: TBGRABitmap);
 procedure Movement(Bitmap: TBGRABitmap; randXmin: NativeInt = -5;
 procedure Movement(Bitmap: TBGRABitmap; randXmin: NativeInt = -5;
   randXmax: NativeInt = 5; randYmin: NativeInt = -5; randYmax: NativeInt = 5);
   randXmax: NativeInt = 5; randYmin: NativeInt = -5; randYmax: NativeInt = 5);
 
 
-procedure Zoomy(Bitmap: TBGRABitmap; xMy,yMy: extended);
+procedure Zoomy(Bitmap: TBGRABitmap; xMy, yMy: extended);
 
 
 { Filters that only need Bitmap as parameter }
 { Filters that only need Bitmap as parameter }
 procedure SimpleFilter(Bitmap: TBGRABitmap; Filter: TBCSimpleFilter);
 procedure SimpleFilter(Bitmap: TBGRABitmap; Filter: TBCSimpleFilter);
@@ -542,15 +576,15 @@ begin
     p := Bitmap.Scanline[y];
     p := Bitmap.Scanline[y];
     for x := 0 to Bitmap.Width - 1 do
     for x := 0 to Bitmap.Width - 1 do
     begin
     begin
-      p^ := Bitmap.GetPixel(x + RandomRange(randXmin, randXmax), y + RandomRange(
-        randYmin, randYmax));
+      p^ := Bitmap.GetPixel(x + RandomRange(randXmin, randXmax), y +
+        RandomRange(randYmin, randYmax));
       Inc(p);
       Inc(p);
     end;
     end;
   end;
   end;
   Bitmap.InvalidateBitmap;
   Bitmap.InvalidateBitmap;
 end;
 end;
 
 
-procedure Zoomy(Bitmap: TBGRABitmap; xMy,yMy: extended);
+procedure Zoomy(Bitmap: TBGRABitmap; xMy, yMy: extended);
 var
 var
   x, y: integer;
   x, y: integer;
   p: PBGRAPixel;
   p: PBGRAPixel;
@@ -560,7 +594,7 @@ begin
     p := Bitmap.Scanline[y];
     p := Bitmap.Scanline[y];
     for x := 0 to Bitmap.Width - 1 do
     for x := 0 to Bitmap.Width - 1 do
     begin
     begin
-      p^{.red} := Bitmap.GetPixel(x*xMy,y*yMy);
+      p^{.red} := Bitmap.GetPixel(x * xMy, y * yMy);
       {p^.green := 0;
       {p^.green := 0;
       p^.blue := 0;
       p^.blue := 0;
       p^.alpha := 255;}
       p^.alpha := 255;}
@@ -595,6 +629,32 @@ begin
     bcsPhotoNoise: PhotoNoise(Bitmap);
     bcsPhotoNoise: PhotoNoise(Bitmap);
     bcsPolaroid: Polaroid(Bitmap);
     bcsPolaroid: Polaroid(Bitmap);
     bcsMovement: Movement(Bitmap);
     bcsMovement: Movement(Bitmap);
+    bcsRBG: RBG(Bitmap);
+    bcsGRB: GRB(Bitmap);
+    bcsGBR: GBR(Bitmap);
+    bcsBRG: BRG(Bitmap);
+    bcsBGR: BGR(Bitmap);
+    bcsRRG: RRG(Bitmap);
+    bcsRGR: RGR(Bitmap);
+    bcsGRR: GRR(Bitmap);
+    bcsRRB: RRB(Bitmap);
+    bcsRBR: RBR(Bitmap);
+    bcsBRR: BRR(Bitmap);
+    bcsGGR: GGR(Bitmap);
+    bcsGRG: GRG(Bitmap);
+    bcsRGG: RGG(Bitmap);
+    bcsGGB: GGB(Bitmap);
+    bcsGBG: GBG(Bitmap);
+    bcsBGG: BGG(Bitmap);
+    bcsBBR: BBR(Bitmap);
+    bcsBRB: BRB(Bitmap);
+    bcsRBB: RBB(Bitmap);
+    bcsBBG: BBG(Bitmap);
+    bcsBGB: BGB(Bitmap);
+    bcsGBB: GBB(Bitmap);
+    bcsRRR: RRR(Bitmap);
+    bcsGGG: GGG(Bitmap);
+    bcsBBB: BBB(Bitmap);
   end;
   end;
 end;
 end;
 
 
@@ -693,56 +753,20 @@ end;
 
 
 // 4
 // 4
 procedure Instagram4(Bitmap: TBGRABitmap);
 procedure Instagram4(Bitmap: TBGRABitmap);
-var
-  i: integer;
-  p: PBGRAPixel;
 begin
 begin
-  p := Bitmap.Data;
-
-  for i := Bitmap.NBPixels - 1 downto 0 do
-  begin
-    p^.red := p^.blue;
-    p^.green := p^.blue;
-    p^.blue := p^.blue;
-    //p^.alpha := ;
-    Inc(p);
-  end;
+  BBB(Bitmap);
 end;
 end;
 
 
 // 5
 // 5
 procedure Instagram5(Bitmap: TBGRABitmap);
 procedure Instagram5(Bitmap: TBGRABitmap);
-var
-  i: integer;
-  p: PBGRAPixel;
 begin
 begin
-  p := Bitmap.Data;
-
-  for i := Bitmap.NBPixels - 1 downto 0 do
-  begin
-    p^.red := p^.green;
-    p^.green := p^.green;
-    p^.blue := p^.green;
-    //p^.alpha := ;
-    Inc(p);
-  end;
+  GGG(Bitmap);
 end;
 end;
 
 
 // 6
 // 6
 procedure Instagram6(Bitmap: TBGRABitmap);
 procedure Instagram6(Bitmap: TBGRABitmap);
-var
-  i: integer;
-  p: PBGRAPixel;
 begin
 begin
-  p := Bitmap.Data;
-
-  for i := Bitmap.NBPixels - 1 downto 0 do
-  begin
-    p^.red := p^.red;
-    p^.green := p^.red;
-    p^.blue := p^.red;
-    //p^.alpha := ;
-    Inc(p);
-  end;
+  RRR(Bitmap);
 end;
 end;
 
 
 procedure Polaroid(Bitmap: TBGRABitmap);
 procedure Polaroid(Bitmap: TBGRABitmap);
@@ -773,4 +797,590 @@ begin
   tmp.Free;
   tmp.Free;
 end;
 end;
 
 
+{Change colors}
+
+procedure FilterRGB(Bitmap: TBGRABitmap; R, G, B: byte);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      p^.red := round(p^.red * (R / 100));
+      p^.green := round(p^.green * (G / 100));
+      p^.blue := round(p^.blue * (B / 100));
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
+procedure RBG(Bitmap: TBGRABitmap);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+  r, g, b: byte;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      r := p^.red;
+      g := p^.green;
+      b := p^.blue;
+      p^.red := r;
+      p^.green := g;
+      p^.blue := b;
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
+procedure GRB(Bitmap: TBGRABitmap);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+  r, g, b: byte;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      r := p^.red;
+      g := p^.green;
+      b := p^.blue;
+      p^.red := g;
+      p^.green := r;
+      p^.blue := b;
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
+procedure GBR(Bitmap: TBGRABitmap);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+  r, g, b: byte;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      r := p^.red;
+      g := p^.green;
+      b := p^.blue;
+      p^.red := g;
+      p^.green := b;
+      p^.blue := r;
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
+procedure BRG(Bitmap: TBGRABitmap);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+  r, g, b: byte;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      r := p^.red;
+      g := p^.green;
+      b := p^.blue;
+      p^.red := b;
+      p^.green := r;
+      p^.blue := g;
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
+procedure BGR(Bitmap: TBGRABitmap);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+  r, g, b: byte;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      r := p^.red;
+      g := p^.green;
+      b := p^.blue;
+      p^.red := b;
+      p^.green := g;
+      p^.blue := r;
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
+procedure RRG(Bitmap: TBGRABitmap);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+  r, g: byte;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      r := p^.red;
+      g := p^.green;
+      p^.red := r;
+      p^.green := r;
+      p^.blue := g;
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
+procedure RGR(Bitmap: TBGRABitmap);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+  r, g: byte;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      r := p^.red;
+      g := p^.green;
+      p^.red := r;
+      p^.green := g;
+      p^.blue := r;
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
+procedure GRR(Bitmap: TBGRABitmap);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+  r, g: byte;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      r := p^.red;
+      g := p^.green;
+      p^.red := g;
+      p^.green := r;
+      p^.blue := r;
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
+procedure RRB(Bitmap: TBGRABitmap);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+  r, b: byte;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      r := p^.red;
+      b := p^.blue;
+      p^.red := r;
+      p^.green := r;
+      p^.blue := b;
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
+procedure RBR(Bitmap: TBGRABitmap);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+  r, b: byte;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      r := p^.red;
+      b := p^.blue;
+      p^.red := r;
+      p^.green := b;
+      p^.blue := r;
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
+procedure BRR(Bitmap: TBGRABitmap);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+  r, b: byte;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      r := p^.red;
+      b := p^.blue;
+      p^.red := b;
+      p^.green := r;
+      p^.blue := r;
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
+procedure GGR(Bitmap: TBGRABitmap);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+  r, g: byte;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      r := p^.red;
+      g := p^.green;
+      p^.red := g;
+      p^.green := g;
+      p^.blue := r;
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
+procedure GRG(Bitmap: TBGRABitmap);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+  r, g: byte;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      r := p^.red;
+      g := p^.green;
+      p^.red := g;
+      p^.green := r;
+      p^.blue := g;
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
+procedure RGG(Bitmap: TBGRABitmap);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+  r, g: byte;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      r := p^.red;
+      g := p^.green;
+      p^.red := r;
+      p^.green := g;
+      p^.blue := g;
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
+procedure GGB(Bitmap: TBGRABitmap);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+  g, b: byte;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      g := p^.green;
+      b := p^.blue;
+      p^.red := g;
+      p^.green := g;
+      p^.blue := b;
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
+procedure GBG(Bitmap: TBGRABitmap);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+  g, b: byte;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      g := p^.green;
+      b := p^.blue;
+      p^.red := g;
+      p^.green := b;
+      p^.blue := g;
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
+procedure BGG(Bitmap: TBGRABitmap);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+  g, b: byte;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      g := p^.green;
+      b := p^.blue;
+      p^.red := b;
+      p^.green := g;
+      p^.blue := g;
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
+procedure BBR(Bitmap: TBGRABitmap);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+  r, b: byte;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      r := p^.red;
+      b := p^.blue;
+      p^.red := b;
+      p^.green := b;
+      p^.blue := r;
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
+procedure BRB(Bitmap: TBGRABitmap);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+  r, b: byte;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      r := p^.red;
+      b := p^.blue;
+      p^.red := b;
+      p^.green := r;
+      p^.blue := b;
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
+procedure RBB(Bitmap: TBGRABitmap);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+  r, b: byte;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      r := p^.red;
+      b := p^.blue;
+      p^.red := r;
+      p^.green := b;
+      p^.blue := b;
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
+procedure BBG(Bitmap: TBGRABitmap);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+  g, b: byte;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      g := p^.green;
+      b := p^.blue;
+      p^.red := b;
+      p^.green := b;
+      p^.blue := g;
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
+procedure BGB(Bitmap: TBGRABitmap);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+  g, b: byte;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      g := p^.green;
+      b := p^.blue;
+      p^.red := b;
+      p^.green := g;
+      p^.blue := b;
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
+procedure GBB(Bitmap: TBGRABitmap);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+  g, b: byte;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      g := p^.green;
+      b := p^.blue;
+      p^.red := g;
+      p^.green := b;
+      p^.blue := b;
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
+procedure RRR(Bitmap: TBGRABitmap);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      p^.green := p^.red;
+      p^.blue := p^.red;
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
+procedure GGG(Bitmap: TBGRABitmap);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      p^.red := p^.green;
+      p^.blue := p^.green;
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
+procedure BBB(Bitmap: TBGRABitmap);
+var
+  x, y: integer;
+  p: PBGRAPixel;
+begin
+  for y := 0 to Bitmap.Height - 1 do
+  begin
+    p := Bitmap.Scanline[y];
+    for x := 0 to Bitmap.Width - 1 do
+    begin
+      p^.red := p^.blue;
+      p^.green := p^.blue;
+      Inc(p);
+    end;
+  end;
+  Bitmap.InvalidateBitmap;
+end;
+
 end.
 end.

+ 49 - 5
test/test_bccontrols/test_bcfilters/unit1.lfm

@@ -1,15 +1,15 @@
 object Form1: TForm1
 object Form1: TForm1
   Left = 203
   Left = 203
-  Height = 408
+  Height = 575
   Top = 139
   Top = 139
   Width = 1045
   Width = 1045
   Caption = 'BCFilters'
   Caption = 'BCFilters'
-  ClientHeight = 408
+  ClientHeight = 575
   ClientWidth = 1045
   ClientWidth = 1045
   OnCloseQuery = FormCloseQuery
   OnCloseQuery = FormCloseQuery
   OnCreate = FormCreate
   OnCreate = FormCreate
   OnDestroy = FormDestroy
   OnDestroy = FormDestroy
-  LCLVersion = '1.1'
+  LCLVersion = '1.2.4.0'
   object vs1: TBGRAVirtualScreen
   object vs1: TBGRAVirtualScreen
     Left = 8
     Left = 8
     Height = 320
     Height = 320
@@ -63,7 +63,7 @@ object Form1: TForm1
   end
   end
   object fs1: TFloatSpinEdit
   object fs1: TFloatSpinEdit
     Left = 8
     Left = 8
-    Height = 28
+    Height = 33
     Top = 336
     Top = 336
     Width = 322
     Width = 322
     DecimalPlaces = 5
     DecimalPlaces = 5
@@ -76,7 +76,7 @@ object Form1: TForm1
   end
   end
   object fs2: TFloatSpinEdit
   object fs2: TFloatSpinEdit
     Left = 8
     Left = 8
-    Height = 28
+    Height = 33
     Top = 368
     Top = 368
     Width = 322
     Width = 322
     DecimalPlaces = 5
     DecimalPlaces = 5
@@ -87,6 +87,50 @@ object Form1: TForm1
     TabOrder = 6
     TabOrder = 6
     Value = 0.98
     Value = 0.98
   end
   end
+  object TrackBar1: TTrackBar
+    Left = 344
+    Height = 48
+    Top = 344
+    Width = 392
+    Max = 100
+    Min = 1
+    OnChange = fs1Change
+    Position = 100
+    ParentShowHint = False
+    TabOrder = 7
+  end
+  object TrackBar2: TTrackBar
+    Left = 344
+    Height = 48
+    Top = 408
+    Width = 392
+    Max = 100
+    Min = 1
+    OnChange = fs1Change
+    Position = 100
+    TabOrder = 8
+  end
+  object TrackBar3: TTrackBar
+    Left = 344
+    Height = 48
+    Top = 464
+    Width = 392
+    Max = 100
+    Min = 1
+    OnChange = fs1Change
+    Position = 100
+    TabOrder = 9
+  end
+  object TrackBar4: TTrackBar
+    Left = 344
+    Height = 48
+    Top = 512
+    Width = 392
+    Max = 255
+    OnChange = fs1Change
+    Position = 255
+    TabOrder = 10
+  end
   object Timer1: TTimer
   object Timer1: TTimer
     Interval = 100
     Interval = 100
     OnTimer = Timer1Timer
     OnTimer = Timer1Timer

+ 13 - 7
test/test_bccontrols/test_bcfilters/unit1.pas

@@ -21,6 +21,10 @@ type
     ListBox3: TListBox;
     ListBox3: TListBox;
     ListBox4: TListBox;
     ListBox4: TListBox;
     Timer1: TTimer;
     Timer1: TTimer;
+    TrackBar1: TTrackBar;
+    TrackBar2: TTrackBar;
+    TrackBar3: TTrackBar;
+    TrackBar4: TTrackBar;
     vs1: TBGRAVirtualScreen;
     vs1: TBGRAVirtualScreen;
     procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
     procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
     procedure FormCreate(Sender: TObject);
     procedure FormCreate(Sender: TObject);
@@ -54,10 +58,10 @@ begin
   BCSimpleFilterStrList(ListBox2.Items);
   BCSimpleFilterStrList(ListBox2.Items);
   BCSimpleFilterStrList(ListBox3.Items);
   BCSimpleFilterStrList(ListBox3.Items);
   BCSimpleFilterStrList(ListBox4.Items);
   BCSimpleFilterStrList(ListBox4.Items);
-  ListBox1.Selected[9] := True;
+  ListBox1.Selected[20] := True;
   ListBox2.Selected[21] := True;
   ListBox2.Selected[21] := True;
-  ListBox3.Selected[15] := True;
-  ListBox4.Selected[20] := True;
+  ListBox3.Selected[0] := True;
+  ListBox4.Selected[0] := True;
 
 
   Fade.Mode := fmFadeOut;
   Fade.Mode := fmFadeOut;
   Fade.Step := 15;
   Fade.Step := 15;
@@ -96,10 +100,7 @@ procedure TForm1.vs1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
 var
 var
   tmp: TBGRABitmap;
   tmp: TBGRABitmap;
 begin
 begin
-  Bitmap.BlendImage(0, 0, Image, boLinearBlend);
-
-  { Weird thing }
-  Zoomy(Bitmap,fs1.Value,fs2.Value);
+  Bitmap.BlendImageOver(0, 0, Image, boTransparent, TrackBar4.Position);
 
 
   tmp := TextShadow(vs1.Width, vs1.Height, 'Penguin TELEPORT project', 20, BGRA(255,255,255,200), BGRABlack, 1, 1, 2) as TBGRABitmap;
   tmp := TextShadow(vs1.Width, vs1.Height, 'Penguin TELEPORT project', 20, BGRA(255,255,255,200), BGRABlack, 1, 1, 2) as TBGRABitmap;
   Bitmap.BlendImage(RandomRange(0,1), RandomRange(vs1.Height div 2 - 40,vs1.Height div 2 - 38), tmp, boLinearBlend);
   Bitmap.BlendImage(RandomRange(0,1), RandomRange(vs1.Height div 2 - 40,vs1.Height div 2 - 38), tmp, boLinearBlend);
@@ -116,6 +117,11 @@ begin
 
 
   // Fade Out the black rectangle
   // Fade Out the black rectangle
   Bitmap.FillRect(0, 0, vs1.Width, vs1.Height, BGRA(0, 0, 0, Fade.Execute), dmFastBlend);
   Bitmap.FillRect(0, 0, vs1.Width, vs1.Height, BGRA(0, 0, 0, Fade.Execute), dmFastBlend);
+
+  FilterRGB(Bitmap, TrackBar1.Position, TrackBar2.Position, TrackBar3.Position);
+
+  { Weird thing }
+  Zoomy(Bitmap,fs1.Value,fs2.Value);
 end;
 end;
 
 
 end.
 end.