コード例 #1
0
ファイル: ImageResizer.cs プロジェクト: hazychill/oog
 //     public static Resizer GetSizeFixedResizer(Size size) {
 //       Size sizeTemp = size;
 //       Resizer resizer = delegate(Size original, Size target) {
 //         return sizeTemp;
 //       };
 //     }
 public static Image Resize(Image original, Size target, Resizer resizer, InterpolationMode interpolationMode)
 {
     Size changedSize = resizer(original.Size, target);
       if (changedSize == original.Size) {
     return original;
       }
       else {
     Bitmap bmp = new Bitmap(changedSize.Width, changedSize.Height);
     using (Graphics g = Graphics.FromImage(bmp)) {
       g.InterpolationMode = interpolationMode;
       Rectangle rect = new Rectangle(new Point(0, 0), changedSize);
       g.DrawImage(original, rect);
     }
     return bmp;
       }
 }
コード例 #2
0
        public static FullScreenViewerSettings Load(XmlDocument document)
        {
            Resizer resizer;
              InterpolationMode interpolationMode;
              Color backColor;

              ResizerConverter rsConv = new ResizerConverter();

              XmlElement resizerElem = document.SelectSingleNode("settings/fullScreenViewer/resizer") as XmlElement;
              if (resizerElem != null) {
            try {
              resizer = (Resizer)rsConv.ConvertFrom(null, null, resizerElem.GetAttribute("value"));
            }
            catch {
              resizer = DefaultResizer;
            }
              }
              else {
            resizer = DefaultResizer;
              }

              EnumConverter ipConv = new EnumConverter(typeof(InterpolationMode));

              XmlElement ipmodeElem = document.SelectSingleNode("settings/fullScreenViewer/interpolationMode") as XmlElement;
              if (ipmodeElem != null) {
            try {
              interpolationMode = (InterpolationMode)ipConv.ConvertFromString(ipmodeElem.GetAttribute("value"));
            }
            catch {
              interpolationMode = DefaultInterpolationMode;
            }
              }
              else {
            interpolationMode = DefaultInterpolationMode;
              }

              ColorConverter colorConv = new ColorConverter();

              XmlElement bcolorElem = document.SelectSingleNode("settings/fullScreenViewer/backColor") as XmlElement;
              if (bcolorElem != null) {
            try {
              backColor = (Color)colorConv.ConvertFromString(bcolorElem.GetAttribute("value"));
            }
            catch {
              backColor = DefaultBackColor;
            }
              }
              else {
            backColor = DefaultBackColor;
              }

              return new FullScreenViewerSettings(resizer, interpolationMode, backColor);
        }
コード例 #3
0
 private FullScreenViewerSettings(Resizer resizer, InterpolationMode interpolationMode)
     : this(resizer, interpolationMode, DefaultBackColor)
 {
 }
コード例 #4
0
        /// <summary>
        /// Processes the image.
        /// </summary>
        /// <param name="factory">
        /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class containing
        /// the image to process.
        /// </param>
        /// <returns>
        /// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public Image ProcessImage(ImageFactory factory)
        {
            Image image = factory.Image;

            try
            {
                ImageLayer imageLayer = this.DynamicParameter;
                Bitmap     overlay    = new Bitmap(imageLayer.Image);

                // Set the resolution of the overlay and the image to match.
                overlay.SetResolution(image.HorizontalResolution, image.VerticalResolution);

                Size size          = imageLayer.Size;
                int  width         = image.Width;
                int  height        = image.Height;
                int  overlayWidth  = size != Size.Empty ? Math.Min(width, size.Width) : Math.Min(width, overlay.Width);
                int  overlayHeight = size != Size.Empty ? Math.Min(height, size.Height) : Math.Min(height, overlay.Height);

                Point?position = imageLayer.Position;
                int   opacity  = imageLayer.Opacity;

                if (image.Size != overlay.Size || image.Size != new Size(overlayWidth, overlayHeight))
                {
                    // Find the maximum possible dimensions and resize the image.
                    ResizeLayer layer   = new ResizeLayer(new Size(overlayWidth, overlayHeight), ResizeMode.Max);
                    Resizer     resizer = new Resizer(layer)
                    {
                        AnimationProcessMode = factory.AnimationProcessMode
                    };
                    overlay       = resizer.ResizeImage(overlay, factory.FixGamma);
                    overlayWidth  = overlay.Width;
                    overlayHeight = overlay.Height;
                }

                // Figure out bounds.
                Rectangle parent = new Rectangle(0, 0, width, height);
                Rectangle child  = new Rectangle(0, 0, overlayWidth, overlayHeight);

                // Apply opacity.
                if (opacity < 100)
                {
                    overlay = Adjustments.Alpha(overlay, opacity);
                }

                using (Graphics graphics = Graphics.FromImage(image))
                {
                    GraphicsHelper.SetGraphicsOptions(graphics, true);

                    if (position != null)
                    {
                        // Draw the image in position catering for overflow.
                        graphics.DrawImage(overlay, new Point(Math.Min(position.Value.X, width - overlayWidth), Math.Min(position.Value.Y, height - overlayHeight)));
                    }
                    else
                    {
                        RectangleF centered = ImageMaths.CenteredRectangle(parent, child);
                        graphics.DrawImage(overlay, new PointF(centered.X, centered.Y));
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ImageProcessingException("Error processing image with " + this.GetType().Name, ex);
            }

            return(image);
        }
コード例 #5
0
        /// <summary>
        /// Processes the image.
        /// </summary>
        /// <param name="factory">
        /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class containing
        /// the image to process.
        /// </param>
        /// <returns>
        /// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public Image ProcessImage(ImageFactory factory)
        {
            Bitmap newImage = null;
            Image  image    = factory.Image;

            try
            {
                newImage = new Bitmap(image);
                ImageLayer imageLayer = this.DynamicParameter;
                Bitmap     overlay    = new Bitmap(imageLayer.Image);

                // Set the resolution of the overlay and the image to match.
                overlay.SetResolution(newImage.HorizontalResolution, newImage.VerticalResolution);

                Size size          = imageLayer.Size;
                int  width         = image.Width;
                int  height        = image.Height;
                int  overlayWidth  = size != Size.Empty ? Math.Min(image.Size.Width, size.Width) : Math.Min(image.Size.Width, overlay.Size.Width);
                int  overlayHeight = size != Size.Empty ? Math.Min(image.Size.Height, size.Height) : Math.Min(image.Size.Height, overlay.Size.Height);

                Point?position = imageLayer.Position;
                int   opacity  = imageLayer.Opacity;

                if (image.Size != overlay.Size || image.Size != new Size(overlayWidth, overlayHeight))
                {
                    // Find the maximum possible dimensions and resize the image.
                    ResizeLayer layer = new ResizeLayer(new Size(overlayWidth, overlayHeight), ResizeMode.Max);
                    overlay       = new Resizer(layer).ResizeImage(overlay);
                    overlayWidth  = overlay.Width;
                    overlayHeight = overlay.Height;
                }

                // Figure out bounds.
                Rectangle parent = new Rectangle(0, 0, width, height);
                Rectangle child  = new Rectangle(0, 0, overlayWidth, overlayHeight);

                // Apply opacity.
                if (opacity < 100)
                {
                    overlay = Adjustments.Alpha(overlay, opacity);
                }

                using (Graphics graphics = Graphics.FromImage(newImage))
                {
                    graphics.SmoothingMode      = SmoothingMode.AntiAlias;
                    graphics.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                    graphics.PixelOffsetMode    = PixelOffsetMode.HighQuality;
                    graphics.CompositingQuality = CompositingQuality.HighQuality;

                    if (position != null)
                    {
                        // Draw the image in position catering for overflow.
                        graphics.DrawImage(overlay, new Point(Math.Min(position.Value.X, width - overlayWidth), Math.Min(position.Value.Y, height - overlayHeight)));
                    }
                    else
                    {
                        RectangleF centered = ImageMaths.CenteredRectangle(parent, child);
                        graphics.DrawImage(overlay, new PointF(centered.X, centered.Y));
                    }
                }

                image.Dispose();
                image = newImage;
            }
            catch (Exception ex)
            {
                if (newImage != null)
                {
                    newImage.Dispose();
                }

                throw new ImageProcessingException("Error processing image with " + this.GetType().Name, ex);
            }

            return(image);
        }
コード例 #6
0
 internal static float HeightResizer(Rect position, float height, float minHeight, float maxHeight, out bool hasControl)
 {
     return(Resizer.Resize(position, height, minHeight, maxHeight, false, out hasControl));
 }
コード例 #7
0
 public void Resizer_fromConfig_must_return_None_if_neither_resizer_is_enabled_which_is_default()
 {
     Resizer.FromConfig(Config.Empty).Should().BeNull();
 }
コード例 #8
0
ファイル: GrabScript.cs プロジェクト: Malmaars/VrNewTech1.2
 // Start is called before the first frame update
 void Start()
 {
     resizer = FindObjectOfType <Resizer>();
 }
コード例 #9
0
        public VFXBlackboard(VFXView view)
        {
            m_View            = view;
            editTextRequested = OnEditName;
            addItemRequested  = OnAddItem;

            this.scrollable = true;

            SetPosition(BoardPreferenceHelper.LoadPosition(BoardPreferenceHelper.Board.blackboard, defaultRect));

            m_DefaultCategory = new VFXBlackboardCategory()
            {
                title = "parameters"
            };
            Add(m_DefaultCategory);
            m_DefaultCategory.headerVisible = false;

            styleSheets.Add(VFXView.LoadStyleSheet("VFXBlackboard"));

            RegisterCallback <MouseDownEvent>(OnMouseClick, TrickleDown.TrickleDown);
            RegisterCallback <DragUpdatedEvent>(OnDragUpdatedEvent);
            RegisterCallback <DragPerformEvent>(OnDragPerformEvent);
            RegisterCallback <DragLeaveEvent>(OnDragLeaveEvent);
            RegisterCallback <KeyDownEvent>(OnKeyDown);

            focusable = true;

            m_AddButton = this.Q <Button>(name: "addButton");

            m_DragIndicator = new VisualElement();


            m_DragIndicator.name           = "dragIndicator";
            m_DragIndicator.style.position = PositionType.Absolute;
            hierarchy.Add(m_DragIndicator);

            SetDragIndicatorVisible(false);

            Resizer resizer = this.Query <Resizer>();

            hierarchy.Add(new UnityEditor.Experimental.GraphView.ResizableElement());

            style.position = PositionType.Absolute;

            m_PathLabel = hierarchy.ElementAt(0).Q <Label>("subTitleLabel");
            m_PathLabel.RegisterCallback <MouseDownEvent>(OnMouseDownSubTitle);

            m_PathTextField = new TextField {
                visible = false
            };
            m_PathTextField.Q(TextField.textInputUssName).RegisterCallback <FocusOutEvent>(e => { OnEditPathTextFinished(); });
            m_PathTextField.Q(TextField.textInputUssName).RegisterCallback <KeyDownEvent>(OnPathTextFieldKeyPressed);
            hierarchy.Add(m_PathTextField);

            resizer.RemoveFromHierarchy();

            if (s_LayoutManual != null)
            {
                s_LayoutManual.SetValue(this, false);
            }

            m_LockedElement                      = new Label("Asset is locked");
            m_LockedElement.style.color          = Color.white * 0.75f;
            m_LockedElement.style.position       = PositionType.Absolute;
            m_LockedElement.style.left           = 0f;
            m_LockedElement.style.right          = new StyleLength(0f);
            m_LockedElement.style.top            = new StyleLength(0f);
            m_LockedElement.style.bottom         = new StyleLength(0f);
            m_LockedElement.style.unityTextAlign = TextAnchor.MiddleCenter;
            var fontSize = 54f;

            m_LockedElement.style.fontSize      = new StyleLength(fontSize);
            m_LockedElement.style.paddingBottom = fontSize / 2f;
            m_LockedElement.style.paddingTop    = fontSize / 2f;
            m_LockedElement.style.display       = DisplayStyle.None;
            m_LockedElement.focusable           = true;
            m_LockedElement.RegisterCallback <KeyDownEvent>(e => e.StopPropagation());
            Add(m_LockedElement);

            m_AddButton.SetEnabled(false);

            this.AddManipulator(new ContextualMenuManipulator(BuildContextualMenu));
        }
コード例 #10
0
 public override Pool WithResizer(Resizer resizer)
 {
     return(new RemoteRouterConfig(Local.WithResizer(resizer), Nodes));
 }
コード例 #11
0
            protected override ITextureFilter CreateFilter(ITextureFilter input)
            {
                // Scale chroma first (this bypasses MPDN's chroma scaler)
                input += new BicubicChroma {
                    Preset = Presets.MitchellNetravali
                };
// Uncomment if you want to deinterlace with MPC-HC's deinterlace (blend) shader

/***
 *              if (Renderer.InterlaceFlags.HasFlag(InterlaceFlags.IsInterlaced))
 *              {
 *                  // Deinterlace using blend
 *                  input += new ImageProcessor { ShaderFileNames = Deinterlace };
 *              }
 ***/
                // Pre resize shaders, followed by NEDI image doubler
                input += new ImageProcessor {
                    ShaderFileNames = PreProcess
                };

                // Use NEDI once only.
                // Note: To use NEDI as many times as required to get the image past target size,
                //       Change the following *if* to *while*
                if ((Renderer.TargetSize > input.Size()).All) // See TextureSize for other comparer methods
                {
                    input += new Nedi {
                        AlwaysDoubleImage = true
                    };
                }

                if ((Renderer.TargetSize < input.Size()).All)
                {
                    // Use linear light for downscaling
                    input += new ImageProcessor {
                        ShaderFileNames = ToLinear
                    }
                    +new Resizer {
                        ResizerOption = ResizerOption.TargetSize100Percent
                    }
                    +new ImageProcessor {
                        ShaderFileNames = ToGamma
                    };
                }
                else
                {
                    // Otherwise, scale with gamma light
                    input += new Resizer {
                        ResizerOption = ResizerOption.TargetSize100Percent
                    };
                }

                if (Renderer.VideoSize.Width < 1920)
                {
                    // Sharpen only if video isn't full HD
                    input += new ImageProcessor {
                        ShaderFileNames = PostProcess
                    };
                }

                return(input);
            }
コード例 #12
0
 public void Setup()
 {
     form    = new Form();
     resizer = new Resizer(form, thickness);
 }
コード例 #13
0
        //Panel hit or stay
        private void btnHit_Click(object sender, EventArgs e)
        {
            //Not bust or blackjack, your turn
            if (TotalCalculator.CalculateTotal(players[betCounter].GetHand()) < 21)
            {
                players[betCounter].SetHand(players[betCounter].TakeHit(cards, players[betCounter].GetHand()));
                cards = Resizer.ResizeDeck(cards, 1);

                if (players.Length == 1)
                {
                    display1Player();
                }
                else if (players.Length == 2)
                {
                    display2Player();
                }
                else if (players.Length == 3)
                {
                    display3Player();
                }
                else if (players.Length == 4)
                {
                    display4Player();
                }
                else if (players.Length == 5)
                {
                    display5Player();
                }
                else if (players.Length == 6)
                {
                    display6Player();
                }
                else
                {
                    display7Player();
                }

                //blackjack or bust, next players turn
                if (TotalCalculator.CalculateTotal(players[betCounter].GetHand()) >= 21)
                {
                    //Any players left? No, house turn
                    if (betCounter < players.Length - 1)
                    {
                        betCounter++;
                        labelPlayerTurnName.Text = players[betCounter].Name;
                    }
                    else
                    {
                        houseTurn();
                    }
                }
            }
            //blackjack or bust, next players turn
            else
            {
                //Any players left? No, house turn
                if (betCounter < players.Length - 1)
                {
                    betCounter++;
                    labelPlayerTurnName.Text = players[betCounter].Name;
                }
                else
                {
                    houseTurn();
                }
            }
        }
コード例 #14
0
 public override Pool WithResizer(Resizer resizer)
 {
     return(new ClusterRouterPool(Local.WithResizer(resizer), Settings));
 }
コード例 #15
0
        /// <summary>
        /// Processes the image.
        /// </summary>
        /// <param name="factory">
        /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class containing
        /// the image to process.
        /// </param>
        /// <returns>
        /// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public Image ProcessImage(ImageFactory factory)
        {
            var    image      = factory.Image;
            Bitmap background = null;
            Bitmap newImage   = null;

            try
            {
                ImageLayer imageLayer = DynamicParameter;
                background = new Bitmap(imageLayer.Image);

                // Set the resolution of the background and the image to match.
                background.SetResolution(image.HorizontalResolution, image.VerticalResolution);

                var size             = imageLayer.Size;
                var width            = image.Width;
                var height           = image.Height;
                var backgroundWidth  = size != Size.Empty ? Math.Min(width, size.Width) : Math.Min(width, background.Width);
                var backgroundHeight = size != Size.Empty ? Math.Min(height, size.Height) : Math.Min(height, background.Height);

                var position = imageLayer.Position;
                var opacity  = imageLayer.Opacity;

                if (image.Size != background.Size || image.Size != new Size(backgroundWidth, backgroundHeight))
                {
                    // Find the maximum possible dimensions and resize the image.
                    var layer   = new ResizeLayer(new Size(backgroundWidth, backgroundHeight), ResizeMode.Max);
                    var resizer = new Resizer(layer)
                    {
                        AnimationProcessMode = factory.AnimationProcessMode
                    };
                    background       = resizer.ResizeImage(background, factory.FixGamma);
                    backgroundWidth  = background.Width;
                    backgroundHeight = background.Height;
                }

                // Figure out bounds.
                var parent = new Rectangle(0, 0, width, height);
                var child  = new Rectangle(0, 0, backgroundWidth, backgroundHeight);

                // Apply opacity.
                if (opacity < 100)
                {
                    background = Adjustments.Alpha(background, opacity);
                }

                newImage = new Bitmap(width, height, PixelFormat.Format32bppPArgb);
                newImage.SetResolution(image.HorizontalResolution, image.VerticalResolution);

                using (var graphics = Graphics.FromImage(newImage))
                {
                    GraphicsHelper.SetGraphicsOptions(graphics, true);

                    if (position != null)
                    {
                        // Draw the image in position catering for overflow.
                        graphics.DrawImage(background, new Point(Math.Min(position.Value.X, width - backgroundWidth), Math.Min(position.Value.Y, height - backgroundHeight)));
                    }
                    else
                    {
                        var centered = ImageMaths.CenteredRectangle(parent, child);
                        graphics.DrawImage(background, new PointF(centered.X, centered.Y));
                    }

                    // Draw passed in image onto graphics object.
                    graphics.DrawImage(image, 0, 0, width, height);
                }

                image.Dispose();
                image = newImage;
            }
            catch (Exception ex)
            {
                newImage?.Dispose();

                throw new ImageProcessingException("Error processing image with " + GetType().Name, ex);
            }
            finally
            {
                background?.Dispose();
            }

            return(image);
        }
コード例 #16
0
ファイル: Program.cs プロジェクト: PawelMStasik/plinProject
        public static void Main(string[] args)
        {
            //pomoc przy wywołaniu bez argumentów
            if (args.Length == 0)
            {
                Func <bool> exit = () =>
                {
                    Console.WriteLine();
                    Console.WriteLine("[Any key - continue, Esc - exit]");
                    ConsoleKeyInfo key = Console.ReadKey(true);
                    if (key.Key == ConsoleKey.Escape)
                    {
                        return(true);
                    }
                    return(false);
                };

                Console.WriteLine("\tP-Lin Interpolation --- Program Help");
                Console.WriteLine();
                Console.WriteLine("Normal callouts:");
                Console.WriteLine("\tplin.exe {input_file} width height {output_file}");
                Console.WriteLine("\tplin.exe {input_file} scale {output_file}");
                Console.WriteLine();
                Console.WriteLine("\tplin.exe      - name of this program (if not changed)");
                Console.WriteLine("\t{input_file}  - path to original image, can be quoted to allow spaces");
                Console.WriteLine("\t{output_file} - path to save the file, can be quoted, if target file exists, it will be overwritten, format is obtained from file extension");
                Console.WriteLine("\twidth height  - size of the image after rescaling (integers)");
                Console.WriteLine("\tscale         - scaling factor for rescaling (floating point)");
                Console.WriteLine();
                Console.WriteLine("Supported file formats (extensions): *.bmp, *.emf, *.gif, *.jpeg, *.jpg, *.png, *.tif, *.tiff, *.wmf.");
                if (exit())
                {
                    return;
                }

                Console.WriteLine();
                Console.WriteLine("Special arguments:");
                Console.WriteLine("Remark: Special arguments might be placed anywhere after the program's name and each has to be prefixed with dash (-), e.g. -linear. Options (if avaible) are separated with ':' or '=' (no spaces)");
                Console.WriteLine();
                Console.WriteLine(" For selecting an interpolation algorithm:");
                Console.WriteLine("\tnearest near nn - nearest nieghbour");
                Console.WriteLine("\tlinear lin l bilinear - bilinear");
                Console.WriteLine("\tplin p-lin - P-Lin");
                Console.WriteLine();
                Console.WriteLine(" For a proximity-based coefficient correction:");
                Console.WriteLine("\tproximity_correction pbcc - general use; full when no parameters");
                Console.WriteLine("\t options: full, fast, no");
                Console.WriteLine("\tfull_proximity_correction = pbcc:full pbcc:yes pbcc:1 pbcc:true");
                Console.WriteLine("\tno_proximity_correction = pbcc:no pbcc:0 pbcc:false no_pbcc");
                if (exit())
                {
                    return;
                }

                Console.WriteLine(" For transition reduction:");
                Console.WriteLine("\ttransition tran tar t - for reducing a transition of interpolation between original points");
                Console.WriteLine("\tparameter means number of pixels in the output image used for the effect (floating point)");
                Console.WriteLine("\te.g. -transition:2 -tran:1.5 -tar:1");
                Console.WriteLine();
                Console.WriteLine(" Additional:");
                Console.WriteLine("\trotation rot r rotate_degrees rotate_dgr rot_dgr rdgr - rotate image counterclockwise (by degrees)");
                Console.WriteLine("\trotate_radians rotate_rad rot_rad rrad - rotate image counterclockwise (by radians)");
                Console.WriteLine("\tparallel multithreading multithread mt - allow use of Parallel.For (multithreading)");
                Console.WriteLine("\twait w pause - after processing wait for user to press any key to continue");
                Console.WriteLine("\ttime t measure measure_time diagnostics diag - measure time taken by each step and show at the end");
                Console.WriteLine(" Calling with no parameters means to turn those options on (or with zero degrees). They can also be called with parameter (boolean):");
                Console.WriteLine("\ttrue t 1 yes - for true (turn the option on)");
                Console.WriteLine("\tfalse f 0 no - for false (tunr the option off)");
                Console.WriteLine("\te.g. -mt:no -wait:true -time:yes");
                Console.WriteLine("\te.g. -rot_dgr:60.35");

                Console.WriteLine();
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey(true);
                return;
            }

            //podział poleceń na podstawowe (bez myślnika) i specjalne (z myślnikiem)
            //the commands are separated into basic- (without a dash) and special (with a dash)
            int[]    iiSpecial = args.Select((arg, i) => arg.StartsWith("-") ? i : -1).Where(i => i != -1).ToArray();
            string[] basic     = args.Where((arg, i) => !iiSpecial.Contains(i)).ToArray();
            string[] special   = args.Where((arg, i) => iiSpecial.Contains(i)).ToArray();
            special = special.Select((arg) => arg.Substring(1).ToLowerInvariant()).ToArray();

            //odczytywane dane | acquired data
            string inputFile            = null;
            string outputFile           = null;
            string algorithm            = null;
            string proximity_correction = null;
            float  reduce        = -1.0f;
            string reduction     = null;
            int    targetWidth   = -1;
            int    targetHeight  = -1;
            double factor        = -1.0d;
            string allowParallel = null;
            string wait          = null;
            string measureTime   = null;
            string rotation      = null;
            double angle         = 0;


            //interpretacja komend wiersza poleceń | interpretation of the command-line arguments
            if (basic.Length < 3)
            {
                Console.WriteLine("!\tNot enought arguments (missing input, output and/or size/scaling factor).");
                return;
            }
            else if (basic.Length == 3)
            {
                inputFile  = basic[0];
                outputFile = basic[2];

                if (TryParseDouble(basic[1], out factor))
                {
                    if (factor < 0)
                    {
                        factor = -factor;
                    }
                    else if (factor == 0)
                    {
                        factor = 1;
                    }
                }
                else
                {
                    Console.WriteLine("!\tImproper scaling factor.");
                    return;
                }
            }
            else
            {
                inputFile  = basic[0];
                outputFile = basic[3];
                Int32.TryParse(basic[1], out targetWidth);
                Int32.TryParse(basic[2], out targetHeight);
                factor = -1;
                if (targetHeight <= 0 || targetWidth <= 0)
                {
                    Console.WriteLine("!\tImproper output dimensions.");
                    return;
                }
            }

            foreach (string cmd in special)
            {
                string a, e;
                int    sep = cmd.IndexOfAny(argsSeparators);
                if (sep < 0)
                {
                    a = cmd;
                    e = String.Empty;
                }
                else
                {
                    a = cmd.Substring(0, sep);
                    e = cmd.Substring(sep + 1);
                }

                int iArg = Array.IndexOf <string>(argsAlgorithms, a);
                if (iArg >= 0)
                {
                    if (algorithm == null)
                    {
                        algorithm = argsAlgorithmsCast[iArg];
                    }
                    continue;
                }
                iArg = Array.IndexOf <string>(argsProximityCorrection, a);
                if (iArg >= 0)
                {
                    if (proximity_correction == null)
                    {
                        if (iArg <= 1 && e != String.Empty)
                        {
                            int dwOpt = Array.IndexOf <string>(argsPBCCOptions, e);
                            if (dwOpt >= 0)
                            {
                                proximity_correction = argsPBCCOptionsCast[dwOpt];
                            }
                        }
                        else
                        {
                            proximity_correction = argsProximityCorrectionCast[iArg];
                        }
                    }
                    continue;
                }
                iArg = Array.IndexOf <string>(argsTransitionReduction, a);
                if (iArg >= 0)
                {
                    if (reduction == null)
                    {
                        if (TryParseSingle(e, out reduce))
                        {
                            if (reduce < 0)
                            {
                                reduce = -reduce;
                            }
                            if (reduce != 0)
                            {
                                reduction = argsTRansitionReductionCast[iArg];
                            }
                        }
                    }
                }

                iArg = Array.IndexOf <string>(argsParallel, a);
                if (iArg >= 0)
                {
                    if (allowParallel == null)
                    {
                        if (e != String.Empty)
                        {
                            int prlOpt = Array.IndexOf <String>(argsOptionsBoolean, e);
                            if (prlOpt >= 0)
                            {
                                allowParallel = argsOptionsBooleanCast[prlOpt];
                            }
                        }
                        else
                        {
                            allowParallel = "true";
                        }
                    }
                }
                iArg = Array.IndexOf <string>(argsWait, a);
                if (iArg >= 0)
                {
                    if (wait == null)
                    {
                        if (e != String.Empty)
                        {
                            int wtOpt = Array.IndexOf <String>(argsOptionsBoolean, e);
                            if (wtOpt >= 0)
                            {
                                wait = argsOptionsBooleanCast[wtOpt];
                            }
                        }
                        else
                        {
                            wait = "true";
                        }
                    }
                }
                iArg = Array.IndexOf <string>(argsTime, a);
                if (iArg >= 0)
                {
                    if (measureTime == null)
                    {
                        if (e != String.Empty)
                        {
                            int mtOpt = Array.IndexOf <String>(argsOptionsBoolean, e);
                            if (mtOpt >= 0)
                            {
                                measureTime = argsOptionsBooleanCast[mtOpt];
                            }
                        }
                        else
                        {
                            measureTime = "true";
                        }
                    }
                }
                iArg = Array.IndexOf <string>(argsRotation, a);
                if (iArg >= 0)
                {
                    if (rotation == null)
                    {
                        if (e != String.Empty)
                        {
                            if (TryParseDouble(e, out angle))
                            {
                                rotation = argsRotationCast[iArg];
                            }
                        }
                    }
                }
            }

            //ustawianie wartości domyślnych jeśli nie określono parametró
            //settinf up default values for variables if those parametrów weren't defined
            if (reduction == null)
            {
                reduction = "no";
            }
            if (algorithm == null)
            {
                algorithm = "plin";
            }
            if (proximity_correction == null)
            {
                proximity_correction = "no";
            }
            if (allowParallel == null)
            {
                allowParallel = "true";
            }
            if (wait == null)
            {
                wait = "false";
            }
            if (measureTime == null)
            {
                measureTime = "false";
            }
            if (rotation == null)
            {
                rotation = "no";
            }

            bool diagnostics = measureTime == "true";
            bool parallel    = allowParallel == "true";
            bool stable      = rotation == "no";

            //inputFile = inputFile.Trim();
            //outputFile = outputFile.Trim();

            System.DateTime T00 = new DateTime(); //rozpoczęcie pracy | start of work
            System.DateTime T10 = new DateTime(); //rozpoczęcie ustawiania interpolacji | start of setting-up the interpolation
            System.DateTime T20 = new DateTime(); //rozpoczęcie interpolacji | start of the interpolation
            System.DateTime T30 = new DateTime(); //rozpoczęcie zapisywania wyniku | start of saving the result
            System.DateTime T40 = new DateTime(); //po zapisaniu wyniku | after saving the result

            if (diagnostics)
            {
                T00 = System.DateTime.Now;
            }

            if (!System.IO.File.Exists(inputFile))
            {
                Console.WriteLine("!\tFile \"{0}\" doesn't exists.", inputFile);
                return;
            }


            Image original;

            using (System.Drawing.Bitmap img = new System.Drawing.Bitmap(inputFile))
            {
                original = new Image(img.Width, img.Height, 3);
                for (int y = original.Height - 1; y >= 0; --y)
                {
                    for (int x = original.Width - 1; x >= 0; --x)
                    {
                        var c = img.GetPixel(x, y);
                        original[x, y, Image.R] = c.R;
                        original[x, y, Image.G] = c.G;
                        original[x, y, Image.B] = c.B;
                    }
                }
            }

            if (diagnostics)
            {
                T10 = System.DateTime.Now;
            }

            if (factor > 0)
            {
                targetHeight = (int)(Math.Round(factor * (double)original.Height));
                targetWidth  = (int)(Math.Round(factor * (double)original.Width));
            }

            Image target = new Image(targetWidth, targetHeight, 3);



            Interpolations.Interpolations.Implemented theAlgorithm = Interpolations.Interpolations.Implemented.PLin;
            Interpolations.Interpolations.ProximityBasedCoefficientReduction theDW = Interpolations.Interpolations.ProximityBasedCoefficientReduction.None;

            switch (algorithm)
            {
            case "lin":
                theAlgorithm = Interpolations.Interpolations.Implemented.Linear;
                break;

            case "nn":
                theAlgorithm = Interpolations.Interpolations.Implemented.NearestNeighbour;
                break;

            case "plin":
            default:
                theAlgorithm = Interpolations.Interpolations.Implemented.PLin;
                break;
            }
            switch (proximity_correction)
            {
            case "full":
                theDW = Interpolations.Interpolations.ProximityBasedCoefficientReduction.Full;
                break;

            case "no":
            default:
                theDW = Interpolations.Interpolations.ProximityBasedCoefficientReduction.None;
                break;
            }

            //ustawianie paramaterów i funkcji przeskalowania
            //setting up the parameters and functions of the resize
            Casting.Blending2D blending = null;
            Resizer            resizer  = new Resizer();

            resizer.Original = original;

            if (stable)
            {
                resizer.Result = target;

                resizer.Interpolation = new Interp();
                resizer.Interpolation.InitializeResize(original.Width, original.Height, target.Width, target.Height,
                                                       Casting.Function.GenProperCasting(original.Width, target.Width), Casting.Function.GenProperCasting(original.Height, target.Height));
                //resizer.Interpolation.InitializeFunctions(Interpolations.Interpolations.Implemented.DLin, Interpolations.Interpolations.DistanceWaging.Full, 2);
                resizer.Interpolation.InitializeFunctions(theAlgorithm, theDW);
            }
            else
            {
                Transformations.TransformationSetup t = new Transformations.TransformationSetup(true);
                t.OriginalWidth   = original.Width;
                t.OriginalHeight  = original.Height;
                t.RelativeScaling = false;
                t.ScalingX        = targetWidth;
                t.ScalingY        = targetHeight;

                t.RotationInDegrees = rotation == "dgr";
                t.RotationRescaling = true;
                t.RotationAngle     = angle;

                Transformations.TransformationPrototype prototype = t.CalculateTransformation();

                targetHeight = (int)(Math.Round((double)prototype.TargetHeight));
                targetWidth  = (int)(Math.Round((double)prototype.TargetWidth));
                target       = new Image(targetWidth, targetHeight, 3);

                resizer.Result = target;

                Cast2D casting = Casting.Function.FromTransformationMatrix(prototype.T_Target2Original, 0.5f);

                resizer.Interpolation = new Interp();
                resizer.Interpolation.InitializeTransformation(original.Width, original.Height, target.Width, target.Height, casting);
                resizer.Interpolation.InitializeFunctions(theAlgorithm, theDW);

                //blending = Casting.Function.FastBlendingFromCasting(casting, 0.5f, 0.5f, original.Width, original.Height);
                blending = Casting.Function.BlendingFromCasting(casting, Casting.Function.PlinBlending, 0.5f, 0.5f, original.Width, original.Height);
            }

            if (reduction == "tran")
            {
                resizer.Interpolation.InitializePassageReduction(reduce);
            }
            else
            {
                resizer.Interpolation.TransitionReduction = null;
            }



            if (!resizer.Buffer())
            {
                resizer.RemoveBuffer();
            }

            resizer.Optimalize(parallel);

            if (diagnostics)
            {
                T20 = System.DateTime.Now;
            }

            bool r = resizer.Resize();

            if (diagnostics)
            {
                T30 = System.DateTime.Now;
            }

            //zapisywanie obrazu wynikowego
            //saving up the resulting image
            using (System.Drawing.Bitmap img2 = new System.Drawing.Bitmap(target.Width, target.Height))
            {
                if (blending == null)
                {
                    for (int y = target.Height - 1; y >= 0; --y)
                    {
                        for (int x = target.Width - 1; x >= 0; --x)
                        {
                            img2.SetPixel(x, y, System.Drawing.Color.FromArgb(target[x, y, Image.R], target[x, y, Image.G], target[x, y, Image.B]));
                        }
                    }
                }
                else
                {
                    for (int y = target.Height - 1; y >= 0; --y)
                    {
                        for (int x = target.Width - 1; x >= 0; --x)
                        {
                            float alpha = blending(x, y);

                            int rc = (int)((float)target[x, y, Image.R] * alpha);
                            int gc = (int)((float)target[x, y, Image.G] * alpha);
                            int bc = (int)((float)target[x, y, Image.B] * alpha);
                            int a  = (int)((float)255 * alpha);

                            img2.SetPixel(x, y, System.Drawing.Color.FromArgb(a, rc, gc, bc));
                        }
                    }
                }

                try
                {
                    using (System.IO.Stream stream = new System.IO.FileStream(outputFile, System.IO.FileMode.Create))
                    {
                        string ext = System.IO.Path.GetExtension(outputFile).ToLowerInvariant();
                        System.Drawing.Imaging.ImageFormat format;

                        switch (ext)
                        {
                        case ".bmp":
                            format = System.Drawing.Imaging.ImageFormat.Bmp;
                            break;

                        case ".emf":
                            format = System.Drawing.Imaging.ImageFormat.Emf;
                            break;

                        case ".gif":
                            format = System.Drawing.Imaging.ImageFormat.Gif;
                            break;

                        case ".jpg":
                        case ".jpeg":
                            format = System.Drawing.Imaging.ImageFormat.Jpeg;
                            break;

                        case ".tiff":
                        case ".tif":
                            format = System.Drawing.Imaging.ImageFormat.Tiff;
                            break;

                        case ".wmf":
                            format = System.Drawing.Imaging.ImageFormat.Wmf;
                            break;

                        case ".png":
                        default:
                            format = System.Drawing.Imaging.ImageFormat.Png;
                            break;
                        }

                        img2.Save(stream, format);
                        //img2.Save(outputFile);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            if (diagnostics)
            {
                T40 = System.DateTime.Now;
            }

            //jeśli ma wyświetlić pomierzony czas
            //if have to show the measured time
            if (diagnostics)
            {
                System.TimeSpan t_loading       = T10 - T00;
                System.TimeSpan t_saving        = T40 - T30;
                System.TimeSpan t_interpolation = T30 - T10;
                System.TimeSpan t_setup         = T20 - T10;
                System.TimeSpan t_resizing      = T30 - T20;
                System.TimeSpan t_total         = T40 - T10;

                Console.WriteLine("DIAGNOSTICS:");
                Console.WriteLine("\tfor: {0}", String.Join("; ", special));
                Console.WriteLine();
                Console.WriteLine("\t    Started work | Loading input: [T0] {0:yyyy:MM:dd hh:mm:ss.fff}", T00);
                Console.WriteLine("\t    Input loaded | Setting up:    [T1] {0:yyyy:MM:dd hh:mm:ss.fff}", T10);
                Console.WriteLine("\tAlgorithm set up | Resizing:      [T2] {0:yyyy:MM:dd hh:mm:ss.fff}", T20);
                Console.WriteLine("\t         Resized | Saving output: [T3] {0:yyyy:MM:dd hh:mm:ss.fff}", T30);
                Console.WriteLine("\t    Output saved | Finished work: [T4] {0:yyyy:MM:dd hh:mm:ss.fff}", T40);
                Console.WriteLine();
                Console.WriteLine(" * Total time: {0} ms (ap. {1} s).", t_total.TotalMilliseconds.ToString(_CI), t_total.TotalSeconds.ToString("0.###", _CI));
                Console.WriteLine(" * Loading the input file took {0} ms (ap. {1} s).", t_loading.TotalMilliseconds.ToString(_CI), t_loading.TotalSeconds.ToString("0.###", _CI));
                Console.WriteLine(" * Saving the output file took {0} ms (ap. {1} s).", t_saving.TotalMilliseconds.ToString(_CI), t_saving.TotalSeconds.ToString("0.###", _CI));
                Console.WriteLine(" * Whole interpolation algorithm took {0} ms (ap. {1} s).", t_interpolation.TotalMilliseconds.ToString(_CI), t_interpolation.TotalSeconds.ToString("0.###", _CI));
                Console.WriteLine(" * Setting out the interpolation algorihtm took {0} ms (ap. {1} s).", t_setup.TotalMilliseconds.ToString(_CI), t_setup.TotalSeconds.ToString("0.###", _CI));
                Console.WriteLine(" * Resizing the image took {0} ms (ap. {1} s).", t_resizing.TotalMilliseconds.ToString(_CI), t_resizing.TotalSeconds.ToString("0.###", _CI));
                Console.WriteLine();
            }

            //jeśli ma spauzować na końcu
            //if there is pasue on the end
            if (wait == "true")
            {
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey(true);
            }
        }
コード例 #17
0
ファイル: EasyLayout.cs プロジェクト: RockfFestival/Rock
 /// <summary>
 /// Raises the disable event.
 /// </summary>
 protected override void OnDisable()
 {
     Resizer.Clear();
     base.OnDisable();
 }
コード例 #18
0
 public int GetPot()
 {
     Resizer.ResizeAndSwitch(_pokerHandle);
     return(GetNumber(_relativePotPos, _potSize, CutPotBitmap));
 }
コード例 #19
0
 internal static float WidthResizer(Rect position, float width, float minWidth, float maxWidth, out bool hasControl)
 {
     return(Resizer.Resize(position, width, minWidth, maxWidth, true, out hasControl));
 }
コード例 #20
0
 public TConfig WithResizer(Resizer resizer)
 {
     Resizer = resizer;
     return((this as TConfig) !);
 }
コード例 #21
0
 private void OnBeginResize(Resizer resizer, Region region)
 {
 }
コード例 #22
0
ファイル: TurnDetector.cs プロジェクト: ozeidan/pokerBot
 public bool MyTurn()
 {
     Resizer.ResizeAndSwitch(_pokerHandle);
     return(CheckPixel(_relativeTurnPos));
 }
コード例 #23
0
 public ResizerAutomationPeer(Resizer owner)
     : base(owner)
 {
 }
コード例 #24
0
ファイル: TurnDetector.cs プロジェクト: ozeidan/pokerBot
 public bool OnlyCall()
 {
     Resizer.ResizeAndSwitch(_pokerHandle);
     return(!CheckPixel(_relativeTurn2Pos));
 }
コード例 #25
0
        public VFXBlackboard(VFXView view)
        {
            m_View            = view;
            editTextRequested = OnEditName;
            addItemRequested  = OnAddItem;

            this.scrollable = true;

            SetPosition(BoardPreferenceHelper.LoadPosition(BoardPreferenceHelper.Board.blackboard, defaultRect));

            m_DefaultCategory = new VFXBlackboardCategory()
            {
                title = "parameters"
            };
            Add(m_DefaultCategory);
            m_DefaultCategory.headerVisible = false;

            styleSheets.Add(Resources.Load <StyleSheet>("VFXBlackboard"));

            RegisterCallback <MouseDownEvent>(OnMouseClick, TrickleDown.TrickleDown);
            RegisterCallback <DragUpdatedEvent>(OnDragUpdatedEvent);
            RegisterCallback <DragPerformEvent>(OnDragPerformEvent);
            RegisterCallback <DragLeaveEvent>(OnDragLeaveEvent);
            RegisterCallback <KeyDownEvent>(OnKeyDown);

            focusable = true;

            m_AddButton = this.Q <Button>(name: "addButton");

            m_DragIndicator = new VisualElement();

            m_DragIndicator.name           = "dragIndicator";
            m_DragIndicator.style.position = PositionType.Absolute;
            hierarchy.Add(m_DragIndicator);

            cacheAsBitmap = true;
            SetDragIndicatorVisible(false);

            Resizer resizer = this.Query <Resizer>();

            hierarchy.Add(new ResizableElement());

            style.position = PositionType.Absolute;

            m_PathLabel = hierarchy.ElementAt(0).Q <Label>("subTitleLabel");
            m_PathLabel.RegisterCallback <MouseDownEvent>(OnMouseDownSubTitle);

            m_PathTextField = new TextField {
                visible = false
            };
            m_PathTextField.Q(TextField.textInputUssName).RegisterCallback <FocusOutEvent>(e => { OnEditPathTextFinished(); });
            m_PathTextField.Q(TextField.textInputUssName).RegisterCallback <KeyDownEvent>(OnPathTextFieldKeyPressed);
            hierarchy.Add(m_PathTextField);

            resizer.RemoveFromHierarchy();

            if (s_LayoutManual != null)
            {
                s_LayoutManual.SetValue(this, false);
            }

            m_AddButton.SetEnabled(false);
        }
        private void resizer_Progress(object sender, ResizerEventArgs e)
        {
            Resizer       resizer = (Resizer)sender;
            StringBuilder sb      = new StringBuilder();

            sb.AppendLine(Environment.NewLine + Path.GetFileName(e.Result.DestFileName) + " - " + e.Result.ConversionMsg);

            if (e.Result.HasError)
            {
                WriteToPaneLog(e.Result.ErrorMessage);
            }
            else
            {
                switch (resizer.Command.ActionToPerform)
                {
                case ManipulateAction.AdvancedConvert:
                    if (resizer.Command.CreateNewFile)
                    {
                        sb.AppendLine("Created new image: " + e.Result.DestFileName);
                    }
                    sb.AppendLine("Resized image: " + FileUtil.ConvertSize(e.Result.SizeAfter));
                    sb.AppendLine("Difference: " + e.Result.PercentSaved + "%");

                    resizer.Command.AddToSolution = true;
                    break;

                case ManipulateAction.Rotate:
                    sb.AppendLine("Rotate: " + e.Result.DestFileName);
                    break;

                case ManipulateAction.CopyAsThumbnail:
                    sb.AppendLine("Thumbnail: " + FileUtil.ConvertSize(e.Result.SizeAfter));
                    resizer.Command.AddToSolution = true;
                    break;

                case ManipulateAction.ConvertToJpeg:
                    sb.AppendLine("Original: " + FileUtil.ConvertSize(e.Result.SizeBefore));
                    sb.AppendLine("New JPG: " + FileUtil.ConvertSize(e.Result.SizeAfter));
                    sb.AppendLine("Difference: " + e.Result.PercentSaved + "%");
                    resizer.Command.AddToSolution = true;
                    break;

                case ManipulateAction.ConvertToPng:
                    sb.AppendLine("Original: " + FileUtil.ConvertSize(e.Result.SizeBefore));
                    sb.AppendLine("New PNG: " + FileUtil.ConvertSize(e.Result.SizeAfter));
                    sb.AppendLine("Difference: " + e.Result.PercentSaved + "%");
                    resizer.Command.AddToSolution = true;
                    break;

                case ManipulateAction.ConvertToGif:
                    sb.AppendLine("Original: " + FileUtil.ConvertSize(e.Result.SizeBefore));
                    sb.AppendLine("New GIF: " + FileUtil.ConvertSize(e.Result.SizeAfter));
                    sb.AppendLine("Difference: " + e.Result.PercentSaved + "%");
                    resizer.Command.AddToSolution = true;
                    break;

                case ManipulateAction.ReCompressWithQuality:
                    sb.AppendLine("Original: " + FileUtil.ConvertSize(e.Result.SizeBefore));
                    sb.AppendLine("Recompressed: " + FileUtil.ConvertSize(e.Result.SizeAfter));
                    sb.AppendLine("Savings: " + e.Result.PercentSaved + "%");
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                if (resizer.Command.AddToSolution)
                {
                    AddToSolution(e.Result.SourceFileName, e.Result.DestFileName);
                }


                processed++;
                allBefore += e.Result.SizeBefore;
                allAfter  += e.Result.SizeAfter;
            }

            WriteToPaneLog(sb.ToString());
            dte.StatusBar.Progress(true, e.Result.DestFileName, resizer.Optimized, resizer.Count);
        }
コード例 #27
0
 //const string SETTING_FILE_NAME = "OogSettings.xml";
 private FullScreenViewerSettings(Resizer resizer, InterpolationMode interpolationMode, Color backColor)
 {
     this.resizer = resizer;
       this.interpolationMode = interpolationMode;
       this.backColor = backColor;
 }
コード例 #28
0
 private void compoundsResults_Enter(object sender, EventArgs e)
 {
     Resizer.ExpandReadingBox(this);
 }
コード例 #29
0
		public ResizerAutomationPeer(Resizer owner)
			: base(owner)
		{
		}
コード例 #30
0
 private void resultList_Enter(object sender, EventArgs e)
 {
     Resizer.OriginalFieldSize(this);
 }
コード例 #31
0
ファイル: ImageResizer.cs プロジェクト: hazychill/oog
        public static Image Resize(Image original, Size target, Resizer resizer, InterpolationMode interpolationMode, bool rotate)
        {
            if (rotate) {
            Size changedSize = resizer(new Size(original.Height, original.Width), target);

            Bitmap bmp = new Bitmap(changedSize.Width, changedSize.Height);
            using (Graphics g = Graphics.FromImage(bmp)) {
              g.InterpolationMode = interpolationMode;
              Point[] destPoints = new Point[]{
            new Point(changedSize.Width-1, 0),
            new Point(changedSize.Width-1, changedSize.Height-1),
            new Point(0, 0)
            };
              g.DrawImage(original, destPoints);
            }
            return bmp;
              }
              else {
            Size changedSize = resizer(original.Size, target);

            if (changedSize == original.Size) {
              return original;
            }
            else {
              Bitmap bmp = new Bitmap(changedSize.Width, changedSize.Height);
              using (Graphics g = Graphics.FromImage(bmp)) {
            g.InterpolationMode = interpolationMode;
            Rectangle rect = new Rectangle(new Point(0, 0), changedSize);
            g.DrawImage(original, rect);
              }
              return bmp;
            }

              }
        }
コード例 #32
0
ファイル: VideoSource.cs プロジェクト: nixxquality/FFMSSharp
        /// <summary>
        /// Sets the output format for video frames
        /// </summary>
        /// <remarks>
        /// <para>In FFMS2, the equivalent is <c>FFMS_SetOutputFormatV2</c>.</para>
        /// </remarks>
        /// <param name="targetFormats">The desired output colorspace(s)
        /// <para>The destination that gives the least lossy conversion from the source colorspace will automatically be selected, ON A FRAME BASIS.</para>
        /// <para>To get the integer constant representing a given colorspace, see <see cref="FFMS2.GetPixelFormat">GetPixFmt</see>.</para>
        /// </param>
        /// <param name="width">The desired image width, in pixels
        /// <para>If you do not want to resize just pass the input dimensions.</para>
        /// </param>
        /// <param name="height">The desired image height, in pixels
        /// <para>If you do not want to resize just pass the input dimensions.</para>
        /// </param>
        /// <param name="resizer">The desired image resizing algorithm.
        /// <para>You must choose one even if you're not actually rescaling the image, because the video may change resolution mid-stream and then you will be using a resizer whether you want it or not (you will only know that the resolution changed after you actually decoded a frame with a new resolution), and it may also get used for rescaling subsampled chroma planes.</para>
        /// </param>
        /// <seealso cref="ResetOutputFormat"/>
        /// <exception cref="ArgumentOutOfRangeException">Trying to set the desired image resolution to an invalid size like 0, 0.</exception>
        /// <exception cref="ArgumentNullException">Trying to supply a null list of <paramref name="targetFormats"/>.</exception>
        /// <exception cref="ArgumentException">Trying to set an invalid output format.</exception>
        public void SetOutputFormat(ICollection<int> targetFormats, int width, int height, Resizer resizer)
        {
            if (targetFormats == null)
                throw new ArgumentNullException(@"targetFormats");
            if (width <= 0)
                throw new ArgumentOutOfRangeException(@"width", "Invalid image width.");
            if (height <= 0)
                throw new ArgumentOutOfRangeException(@"height", "Invalid image height.");

            var err = new FFMS_ErrorInfo
            {
                BufferSize = 1024,
                Buffer = new String((char) 0, 1024)
            };

            var targetFormatsArray = new int[targetFormats.Count + 1];
            targetFormats.CopyTo(targetFormatsArray, 0);
            targetFormatsArray[targetFormats.Count] = -1;

            MarkLastFrameAsInvalid();

            if (NativeMethods.FFMS_SetOutputFormatV2(_nativePtr, targetFormatsArray, width, height, (int) resizer, ref err) == 0)
                return;

            if (err.ErrorType == FFMS_Errors.FFMS_ERROR_SCALING && err.SubType == FFMS_Errors.FFMS_ERROR_INVALID_ARGUMENT)
                throw new ArgumentException(err.Buffer);
            if (err.ErrorType == FFMS_Errors.FFMS_ERROR_DECODING && err.SubType == FFMS_Errors.FFMS_ERROR_CODEC)
                throw new ArgumentException(err.Buffer);

            throw new NotImplementedException(string.Format(System.Globalization.CultureInfo.CurrentCulture, "Unknown FFMS2 error encountered: ({0}, {1}, '{2}'). Please report this issue on FFMSSharp's GitHub.", err.ErrorType, err.SubType, err.Buffer));
        }