mixster

mixster

Oct 13th, 2008
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.39 KB | None | 0 0
  1. library GifToBitmap;
  2.  
  3. uses
  4.   FastShareMem,
  5.   SysUtils,
  6.   Classes,
  7.   Windows,
  8.   Graphics,
  9.   GIFimage;
  10.  
  11. {$R *.res}
  12.  
  13. type
  14.   TSCARPlugFunc = record
  15.     Name: string;
  16.     Ptr: Pointer;
  17.   end;
  18.  
  19.   TOneStrProc = procedure(s: string);
  20.  
  21. var
  22.   Writeln: TOneStrProc;
  23.  
  24.  
  25. procedure GifToBmp(gifPath: string; var bmp: TBitmap); stdcall;
  26. var
  27.   gif: TGIFImage;
  28.  
  29. begin
  30.   try
  31.     gif := TGIFImage.Create;
  32.     try
  33.       gif.OnProgress := OnProgress;
  34.       gif.LoadFromFile(gifPath);
  35.       try
  36.     bmp.Free;
  37.       finally
  38.     bmp := TBitmap.Create;
  39.       end;
  40.       try
  41.         bmp.Assign(gif);
  42.       except
  43.         bmp.Free;
  44.       end;
  45.     finally
  46.     end;
  47.   finally
  48.     gif.Free;
  49.   end;
  50. end;
  51.  
  52.  
  53. function GetFunctionCount(): Integer; stdcall; export;
  54. begin
  55.   Result := 1;
  56. end;
  57.  
  58. function GetFunctionInfo(x: Integer; var ProcAddr: Pointer; var ProcDef: PChar): Integer; stdcall;
  59. begin
  60.   case x of
  61.     0:
  62.       begin
  63.         ProcAddr := @GifToBmp;
  64.         StrPCopy(ProcDef, 'procedure GifToBmp(gifPath: string; var bmp: TBitmap);');
  65.       end;
  66.  
  67.   else
  68.     x := -1;
  69.   end;
  70.   Result := x;
  71. end;
  72.  
  73.  
  74. procedure SetFunctions(Funcs: array of TSCARPlugFunc); stdcall;
  75. var
  76.   i: Integer;
  77. begin
  78.   for i := 0 to Length(Funcs) - 1 do
  79.     if Funcs[i].Name = 'Writeln' then
  80.       Writeln := Funcs[i].Ptr;
  81. end;
  82.  
  83. exports GetFunctionCount;
  84. exports GetFunctionInfo;
  85. exports SetFunctions;
  86. end.
Add Comment
Please, Sign In to add comment