Beispiel #1
0
        private void Init()
        {
            // Create Options for the encoder and activate validation
            EncoderOptions encOptions = new EncoderOptions
            {
                EncoderPath = Path.Combine(BaseDir, "cjxl.exe"),
                Validate    = false
            };

            // Create new encoder with previously prepared Options
            Enc = new Encoder(encOptions);

            // Create Options for the encoder and activate validation
            DecoderOptions decOptions = new DecoderOptions
            {
                DecoderPath = Path.Combine(BaseDir, "djxl.exe"),
            };


            //Try to get versions
            encOptions.TryGetEncoderVersionInfo();
            enc.Decoder.Options.TryGetDecoderVersionInfo();

            // listen to propertychange events of the encoder to get notified
            // if the images changes to update the FileSystem watcher
            // and it updates the image in the viewer component
            enc.PropertyChanged += enc_PropertyChanged;

            initWatcher(Image2);


            // Set example image as input file
            if (File.Exists(example))
            {
                Enc.InFile = new FileInfo(example);
            }


            // Configure Quality
            jxlNET.Encoder.Parameters.Quality q = new jxlNET.Encoder.Parameters.Quality();
            //q.Value = 101; //Throws ArgumentOutOfRangeException limit is 100
            q.Value = 50; //Throws ArgumentOutOfRangeException limit is 100
            Console.WriteLine("Encode with Quality: " + q.Value);
            Enc.AddOrReplaceParam(q);

            // Configure Speed
            jxlNET.Encoder.Parameters.Speed s = new jxlNET.Encoder.Parameters.Speed(3);
            Enc.AddOrReplaceParam(s);

            // print out all current set parameter
            foreach (var p in enc.Params)
            {
                Console.WriteLine("param: " + p.ToString());
            }

            //Load saved Presets from files
            LoadPresets();

            // Dynamically build controls to add parameter
            ListBoxParameter.FillListBox(LbParam, enc);
        }