コード例 #1
0
ファイル: GifskiInterop.cs プロジェクト: znatz/ScreenToGif
        public GifskiInterop()
        {
            #region Get Gifski version

            var info = new FileInfo(UserSettings.All.GifskiLocation);
            info.Refresh();

            //I really need another way to differentiate gifski versions.
            switch (info.Length)
            {
            case 524_752:
                Version = new Version(1, 2, 0);
                break;

            case 502_720:
                Version = new Version(0, 10, 2);
                break;

            case 502_208:
                Version = new Version(0, 9, 3);
                break;

            default:
                Version = new Version(0, 0);
                break;
            }

            #endregion

            #region Load functions

            _new         = (NewDelegate)FunctionLoader.LoadFunction <NewDelegate>(UserSettings.All.GifskiLocation, "gifski_new");
            _addPngFrame = (AddPngFrameDelegate)FunctionLoader.LoadFunction <AddPngFrameDelegate>(UserSettings.All.GifskiLocation, "gifski_add_frame_png_file");
            //_addRgbaFrame = (AddRgbaFrameDelegate)FunctionLoader.LoadFunction<AddRgbaFrameDelegate>(UserSettings.All.GifskiLocation, "gifski_add_frame_rgba");

            if (Version.Major == 0 && Version.Minor < 10)
            {
                _addRgbFrame = (AddRgbFrameDelegate)FunctionLoader.LoadFunction <AddRgbFrameDelegate>(UserSettings.All.GifskiLocation, "gifski_add_frame_rgb");
            }
            else
            {
                _addRgb2Frame = (AddRgb2FrameDelegate)FunctionLoader.LoadFunction <AddRgb2FrameDelegate>(UserSettings.All.GifskiLocation, "gifski_add_frame_rgb");
            }

            if (Version.Major == 0 && Version.Minor < 9)
            {
                //Older versions of the library.
                _endAddingFrames = (EndAddingFramesDelegate)FunctionLoader.LoadFunction <EndAddingFramesDelegate>(UserSettings.All.GifskiLocation, "gifski_end_adding_frames");
                _write           = (WriteDelegate)FunctionLoader.LoadFunction <WriteDelegate>(UserSettings.All.GifskiLocation, "gifski_write");
                _drop            = (DropDelegate)FunctionLoader.LoadFunction <DropDelegate>(UserSettings.All.GifskiLocation, "gifski_drop");
            }
            else
            {
                //Newer versions.
                _setFileOutput = (SetFileOutputDelegate)FunctionLoader.LoadFunction <SetFileOutputDelegate>(UserSettings.All.GifskiLocation, "gifski_set_file_output");
                _finish        = (FinishDelegate)FunctionLoader.LoadFunction <FinishDelegate>(UserSettings.All.GifskiLocation, "gifski_finish");
            }

            #endregion
        }
コード例 #2
0
        public GifskiInterop()
        {
            #region Get Gifski version

            var info = new FileInfo(UserSettings.All.GifskiLocation);
            info.Refresh();

            Version = info.Length == 502_208 ? new Version(0, 9, 3) : new Version(0, 0);

            #endregion

            #region Load functions

            _new          = (NewDelegate)FunctionLoader.LoadFunction <NewDelegate>(UserSettings.All.GifskiLocation, "gifski_new");
            _addPngFrame  = (AddPngFrameDelegate)FunctionLoader.LoadFunction <AddPngFrameDelegate>(UserSettings.All.GifskiLocation, "gifski_add_frame_png_file");
            _addRgbaFrame = (AddRgbaFrameDelegate)FunctionLoader.LoadFunction <AddRgbaFrameDelegate>(UserSettings.All.GifskiLocation, "gifski_add_frame_rgba");

            if (Version.Major == 0 && Version.Minor < 9)
            {
                //Older versions of the library.
                _endAddingFrames = (EndAddingFramesDelegate)FunctionLoader.LoadFunction <EndAddingFramesDelegate>(UserSettings.All.GifskiLocation, "gifski_end_adding_frames");
                _write           = (WriteDelegate)FunctionLoader.LoadFunction <WriteDelegate>(UserSettings.All.GifskiLocation, "gifski_write");
                _drop            = (DropDelegate)FunctionLoader.LoadFunction <DropDelegate>(UserSettings.All.GifskiLocation, "gifski_drop");
            }
            else
            {
                //Newer versions.
                _setFileOutput = (SetFileOutputDelegate)FunctionLoader.LoadFunction <SetFileOutputDelegate>(UserSettings.All.GifskiLocation, "gifski_set_file_output");
                _finish        = (FinishDelegate)FunctionLoader.LoadFunction <FinishDelegate>(UserSettings.All.GifskiLocation, "gifski_finish");
            }

            #endregion
        }