Просмотр исходного кода

Added FilterSmartZoom3 to library and c#.
Changed names of exported functions to be all lowercase.

lainz 10 лет назад
Родитель
Сommit
259a23f344

+ 37 - 30
bgra_pascalscript_library/bgra_pascalscript_library.lpr

@@ -8,7 +8,8 @@ library bgra_pascalscript_library;
 
 uses
   Interfaces,
-  BGRAPascalScript;
+  BGRAPascalScript,
+  BGRABitmapTypes;
 
 { String Utility }
   function PWideCharToUTF8(const str: PWideChar): string;
@@ -18,7 +19,7 @@ uses
 
 { Library }
 
-  function bgra_GetHighestID: integer; {$IFDEF stdcall}stdcall;{$ELSE}cdecl;{$ENDIF}
+  function GetHighestID: integer; {$IFDEF stdcall}stdcall;{$ELSE}cdecl;{$ENDIF}
   begin
     Result := BGRAPascalScript.bgra_GetHighestID;
   end;
@@ -74,74 +75,80 @@ uses
   end;
 
   {Constructors}
-  procedure bgra_Create(id: integer); {$IFDEF stdcall}stdcall;{$ELSE}cdecl;{$ENDIF}
+  procedure Create(id: integer); {$IFDEF stdcall}stdcall;{$ELSE}cdecl;{$ENDIF}
   begin
     BGRAPascalScript.bgra_Create(id);
   end;
 
-  procedure bgra_CreateWithSize(id: integer; AWidth, AHeight: integer); {$IFDEF stdcall}stdcall;{$ELSE}cdecl;{$ENDIF}
+  procedure CreateWithSize(id: integer; AWidth, AHeight: integer); {$IFDEF stdcall}stdcall;{$ELSE}cdecl;{$ENDIF}
   begin
     BGRAPascalScript.bgra_CreateWithSize(id, AWidth, AHeight);
   end;
 
-  procedure bgra_Fill(id: integer; AColor: TBGRAColor); {$IFDEF stdcall}stdcall;{$ELSE}cdecl;{$ENDIF}
+  procedure Fill(id: integer; AColor: TBGRAColor); {$IFDEF stdcall}stdcall;{$ELSE}cdecl;{$ENDIF}
   begin
     BGRAPascalScript.bgra_Fill(id, AColor);
   end;
 
-  procedure bgra_SetPixel(id: integer; x, y: integer; AColor: TBGRAColor); {$IFDEF stdcall}stdcall;{$ELSE}cdecl;{$ENDIF}
+  procedure SetPixel(id: integer; x, y: integer; AColor: TBGRAColor); {$IFDEF stdcall}stdcall;{$ELSE}cdecl;{$ENDIF}
   begin
     BGRAPascalScript.bgra_SetPixel(id, x, y, AColor);
   end;
 
-  function bgra_GetPixel(id: integer; x, y: integer): TBGRAColor; {$IFDEF stdcall}stdcall;{$ELSE}cdecl;{$ENDIF}
+  function GetPixel(id: integer; x, y: integer): TBGRAColor; {$IFDEF stdcall}stdcall;{$ELSE}cdecl;{$ENDIF}
   begin
     Result := BGRAPascalScript.bgra_GetPixel(id, x, y);
   end;
 
-  procedure bgra_CreateFromFile(id: integer; AFilename: PWideChar); {$IFDEF stdcall}stdcall;{$ELSE}cdecl;{$ENDIF}
+  procedure CreateFromFile(id: integer; AFilename: PWideChar); {$IFDEF stdcall}stdcall;{$ELSE}cdecl;{$ENDIF}
   begin
     BGRAPascalScript.bgra_CreateFromFile(id, PWideCharToUTF8(AFilename));
   end;
 
-  procedure bgra_Destroy(id: integer); {$IFDEF stdcall}stdcall;{$ELSE}cdecl;{$ENDIF}
+  procedure Destroy(id: integer); {$IFDEF stdcall}stdcall;{$ELSE}cdecl;{$ENDIF}
   begin
     BGRAPascalScript.bgra_Destroy(id);
   end;
 
-  procedure bgra_SaveToFile(id: integer; filename: PWideChar); {$IFDEF stdcall}stdcall;{$ELSE}cdecl;{$ENDIF}
+  procedure SaveToFile(id: integer; filename: PWideChar); {$IFDEF stdcall}stdcall;{$ELSE}cdecl;{$ENDIF}
   begin
     BGRAPascalScript.bgra_SaveToFile(id, PWideCharToUTF8(filename));
   end;
 
   { Filters }
 
+  procedure FilterSmartZoom3(id: integer; Option: TMedianOption); {$IFDEF stdcall}stdcall;{$ELSE}cdecl;{$ENDIF}
+  begin
+    BGRAPascalScript.bgra_FilterSmartZoom3(id, Option);
+  end;
+
   procedure FilterGrayscale(id: integer); {$IFDEF stdcall}stdcall;{$ELSE}cdecl;{$ENDIF}
   begin
     BGRAPascalScript.bgra_FilterGrayscale(id);
   end;
 
 exports
-  bgra_GetHighestID name 'GetHighestID',
-  rgb,
-  rgba,
-  getBlue,
-  getGreen,
-  getRed,
-  getAlpha,
-  setBlue,
-  setGreen,
-  setRed,
-  setAlpha,
-  bgra_Create name 'Create',
-  bgra_CreateWithSize name 'CreateWithSize',
-  bgra_Fill name 'Fill',
-  bgra_SetPixel name 'SetPixel',
-  bgra_GetPixel name 'GetPixel',
-  bgra_CreateFromFile name 'CreateFromFile',
-  bgra_Destroy name 'Destroy',
-  bgra_SaveToFile name 'SaveToFile',
-  FilterGrayscale;
+  GetHighestID name 'gethighestid',
+  rgb name 'rgb',
+  rgba name 'rgba',
+  getBlue name 'getblue',
+  getGreen name 'getgreen',
+  getRed name 'getred',
+  getAlpha name 'getalpha',
+  setBlue name 'setblue',
+  setGreen name 'setgreen',
+  setRed name 'setred',
+  setAlpha name 'setalpha',
+  Create name 'create',
+  CreateWithSize name 'createwithsize',
+  Fill name 'fill',
+  SetPixel name 'setpixel',
+  GetPixel name 'getpixel',
+  CreateFromFile name 'createfromfile',
+  Destroy name 'destroy',
+  SaveToFile name 'savetofile',
+  FilterSmartZoom3 name 'filtersmartzoom3',
+  FilterGrayscale name 'filtergrayscale';
 
 begin
 end.

+ 27 - 21
bgra_pascalscript_library/c#/BGRABitmap.cs

@@ -5,74 +5,80 @@ namespace BGRABitmapLibrary
 {
     public class BGRABitmap
     {
+        /* Types */
+        public enum TMedianOption : byte { moNone, moLowSmooth, moMediumSmooth, moHighSmooth };
+
         /* Constructors */
 
-        [DllImport("bgrabitmap")]
+        [DllImport("bgrabitmap", EntryPoint = "create")]
         public static extern void Create(int id);
 
-        [DllImport("bgrabitmap")]
+        [DllImport("bgrabitmap", EntryPoint = "createwithsize")]
         public static extern void CreateWithSize(int id, int AWidth, int AHeight);
 
-        [DllImport("bgrabitmap")]
+        [DllImport("bgrabitmap", EntryPoint = "destroy")]
         public static extern void Destroy(int id);
 
-        [DllImport("bgrabitmap")]
+        [DllImport("bgrabitmap", EntryPoint = "gethighestid")]
         public static extern int GetHighestID();
 
         /* Files */
 
-        [DllImport("bgrabitmap")]
+        [DllImport("bgrabitmap", EntryPoint = "createfromfile")]
         public static extern void CreateFromFile(int id, [MarshalAs(UnmanagedType.LPWStr)]string AFileName);
 
-        [DllImport("bgrabitmap")]
+        [DllImport("bgrabitmap", EntryPoint = "savetofile")]
         public static extern void SaveToFile(int id, [MarshalAs(UnmanagedType.LPWStr)]string AFileName);
 
         /* Color */
 
-        [DllImport("bgrabitmap")]
+        [DllImport("bgrabitmap", EntryPoint = "rgb")]
         public static extern uint rgb(byte red, byte green, byte blue);
 
-        [DllImport("bgrabitmap")]
+        [DllImport("bgrabitmap", EntryPoint = "rgba")]
         public static extern uint rgba(byte red, byte green, byte blue, byte alpha);
 
-        [DllImport("bgrabitmap")]
+        [DllImport("bgrabitmap", EntryPoint = "getblue")]
         public static extern byte getBlue(uint AColor);
 
-        [DllImport("bgrabitmap")]
+        [DllImport("bgrabitmap", EntryPoint = "getgreen")]
         public static extern byte getGreen(uint AColor);
 
-        [DllImport("bgrabitmap")]
+        [DllImport("bgrabitmap", EntryPoint = "getred")]
         public static extern byte getRed(uint AColor);
 
-        [DllImport("bgrabitmap")]
+        [DllImport("bgrabitmap", EntryPoint = "getalpha")]
         public static extern byte getAlpha(uint AColor);
 
-        [DllImport("bgrabitmap")]
+        [DllImport("bgrabitmap", EntryPoint = "setblue")]
         public static extern uint setBlue(uint AColor, byte AValue);
 
-        [DllImport("bgrabitmap")]
+        [DllImport("bgrabitmap", EntryPoint = "setgreen")]
         public static extern uint setGreen(uint AColor, byte AValue);
 
-        [DllImport("bgrabitmap")]
+        [DllImport("bgrabitmap", EntryPoint = "setred")]
         public static extern uint setRed(uint AColor, byte AValue);
 
-        [DllImport("bgrabitmap")]
+        [DllImport("bgrabitmap", EntryPoint = "setalpha")]
         public static extern uint setAlpha(uint AColor, byte AValue);
 
         /* Pixels */
 
-        [DllImport("bgrabitmap")]
+        [DllImport("bgrabitmap", EntryPoint = "fill")]
         public static extern void Fill(int id, uint AColor);
 
-        [DllImport("bgrabitmap")]
+        [DllImport("bgrabitmap", EntryPoint = "setpixel")]
         public static extern void SetPixel(int id, int x, int y, uint AColor);
 
-        [DllImport("bgrabitmap")]
+        [DllImport("bgrabitmap", EntryPoint = "getpixel")]
         public static extern uint GetPixel(int id, int x, int y);
 
         /* Filters */
 
-        [DllImport("bgrabitmap")]
-        public static extern uint FilterGrayscale(int id);
+        [DllImport("bgrabitmap", EntryPoint = "filtersmartzoom3")]
+        public static extern void FilterSmartZoom3(int id, TMedianOption Option);
+
+        [DllImport("bgrabitmap", EntryPoint = "filtergrayscale")]
+        public static extern void FilterGrayscale(int id);
     }
 }