Procházet zdrojové kódy

Added filters in bgrascript.pas

lainz před 11 roky
rodič
revize
0f0ff9ade2
2 změnil soubory, kde provedl 124 přidání a 7 odebrání
  1. 115 0
      bgrascript.pas
  2. 9 7
      test/test_bgrascript/umain.lfm

+ 115 - 0
bgrascript.pas

@@ -65,6 +65,16 @@ begin
     Add('BlendBitmap 0,0,"file.png","boTransparent"');
     Add('BlendBitmapOver 0,0,"file.png","boTransparent",255,"False"');
     Add('ApplyBitmapMask "file.png",0,0,100,100,0,0');
+    {Filters}
+    Add('FilterFastBlur 5,"False"');
+    Add('FilterSmooth "False"');
+    Add('FilterSharpen 5,"False"');
+    Add('FilterContour');
+    Add('FilterEmboss "1,5"');
+    Add('FilterNormalize "True"');
+    Add('FilterSphere "True"');
+    Add('FilterCylinder "True"');
+    Add('FilterPlane "True"');
   end;
 end;
 
@@ -352,6 +362,8 @@ begin
           StrToInt(list[3]), StrToInt(list[4])), StrToBGRA(list[5]), StrToBGRA(list[6]));
     end;
 
+    {Filters}
+
     {Custom Functions}
     'blendbitmap':
     begin
@@ -390,6 +402,109 @@ begin
         finally
         end;
     end;
+    'filterfastblur':
+    begin
+      Result := ParamCheck(passed, 3);
+      if Result then
+      begin
+        tmpbmp1 := bitmap.FilterBlurRadial(StrToInt(list[1]), rbFast) as TBGRABitmap;
+        if StrToBool(list[2]) then
+          bitmap.FillTransparent;
+        bitmap.BlendImage(0, 0, tmpbmp1, boLinearBlend);
+        tmpbmp1.Free;
+      end;
+    end;
+    'filtersmooth':
+    begin
+      Result := ParamCheck(passed, 2);
+      if Result then
+      begin
+        tmpbmp1 := bitmap.FilterSmooth as TBGRABitmap;
+        if StrToBool(list[1]) then
+          bitmap.FillTransparent;
+        bitmap.BlendImage(0, 0, tmpbmp1, boLinearBlend);
+        tmpbmp1.Free;
+      end;
+    end;
+    'filtersharpen':
+    begin
+      Result := ParamCheck(passed, 3);
+      if Result then
+      begin
+        tmpbmp1 := bitmap.FilterSharpen(StrToInt(list[1])) as TBGRABitmap;
+        if StrToBool(list[2]) then
+          bitmap.FillTransparent;
+        bitmap.BlendImage(0, 0, tmpbmp1, boLinearBlend);
+        tmpbmp1.Free;
+      end;
+    end;
+    'filtercontour':
+    begin
+      Result := ParamCheck(passed, 1);
+      if Result then
+      begin
+        tmpbmp1 := bitmap.FilterContour as TBGRABitmap;
+        bitmap.BlendImage(0, 0, tmpbmp1, boLinearBlend);
+        tmpbmp1.Free;
+      end;
+    end;
+    'filteremboss':
+    begin
+      Result := ParamCheck(passed, 2);
+      if Result then
+      begin
+        tmpbmp1 := bitmap.FilterEmboss(StrToFloat(list[1])) as TBGRABitmap;
+        bitmap.BlendImage(0, 0, tmpbmp1, boLinearBlend);
+        tmpbmp1.Free;
+      end;
+    end;
+    'filternormalize':
+    begin
+      Result := ParamCheck(passed, 2);
+      if Result then
+      begin
+        tmpbmp1 := bitmap.FilterNormalize(StrToBool(list[1])) as TBGRABitmap;
+        bitmap.FillTransparent;
+        bitmap.BlendImage(0, 0, tmpbmp1, boLinearBlend);
+        tmpbmp1.Free;
+      end;
+    end;
+    'filtersphere':
+    begin
+      Result := ParamCheck(passed, 2);
+      if Result then
+      begin
+        tmpbmp1 := bitmap.FilterSphere as TBGRABitmap;
+        if StrToBool(list[1]) then
+          bitmap.FillTransparent;
+        bitmap.BlendImage(0, 0, tmpbmp1, boLinearBlend);
+        tmpbmp1.Free;
+      end;
+    end;
+    'filtercylinder':
+    begin
+      Result := ParamCheck(passed, 2);
+      if Result then
+      begin
+        tmpbmp1 := bitmap.FilterCylinder as TBGRABitmap;
+        if StrToBool(list[1]) then
+          bitmap.FillTransparent;
+        bitmap.BlendImage(0, 0, tmpbmp1, boLinearBlend);
+        tmpbmp1.Free;
+      end;
+    end;
+    'filterplane':
+    begin
+      Result := ParamCheck(passed, 2);
+      if Result then
+      begin
+        tmpbmp1 := bitmap.FilterPlane as TBGRABitmap;
+        if StrToBool(list[1]) then
+          bitmap.FillTransparent;
+        bitmap.BlendImage(0, 0, tmpbmp1, boLinearBlend);
+        tmpbmp1.Free;
+      end;
+    end;
 
     '//':
     begin

+ 9 - 7
test/test_bgrascript/umain.lfm

@@ -456,37 +456,39 @@ object Form1: TForm1
       '{ BGRAScript }'
       'FillTransparent'
       ''
-      '// Draw rectangles, lines and bitmap'
+      '// "Draw rectangles, lines and bitmap"'
       'Rectangle 0,0,100,100,"rgba(0,0,0,0.6)","rgba(250,250,250,1)","dmDrawWithTransparency"'
       'Rectangle 20,20,80,80,"rgba(0,0,0,0.4)","rgba(255,255,255,1)","dmDrawWithTransparency"'
       'SetHorizLine 0,10,98,"rgba(0,0,0,.3)"'
       'SetVertLine 90,1,98,"rgba(0,0,0,.3)"'
       'BlendBitmap 26,26,"test.png","boTransparent"'
       ''
-      '// Save and weird things step 1'
+      '// "Save and weird things step 1"'
       'SaveToFile "file.png"'
       'Negative'
       'BlendBitmap 0,100,"file.png","boTransparent"'
       ''
-      '// Save and weird things step 2'
+      '// "Save and weird things step 2"'
       'SaveToFile "file.png"'
       'Negative'
+      'FilterFastBlur 3,"False"'
       'BlendBitmap 100,0,"file.png","boTransparent"'
       ''
-      '// Flip the world and save it'
+      '// "Flip the world and save it"'
       'VerticalFlip 0,0,100,100'
       'HorizontalFlip 100,100,200,200'
       'VerticalFlip 100,0,200,100'
       'HorizontalFlip 100,0,200,100'
       'SaveToFile "file.png"'
       ''
-      '// Weird things level 3'
+      '// "Weird things level 3"'
       'DrawCheckers 200,0,300,300,"rgba(100,100,100,255)","rgba(0,0,0,0)"'
       'InplaceGrayscaleRect 0,0,100,100'
+      'FilterSmooth "False"'
       'ApplyBitmapMask "file.png",100,100,200,200,0,100'
       ''
-      '// Save this in your hard disk (again)'
-      'SaveToFile "file.png"     '
+      '// "Save this in your hard disk (again)"'
+      'SaveToFile "file.png"    '
     )
     VisibleSpecialChars = [vscSpace, vscTabAtLast]
     SelectedColor.FrameEdges = sfeAround