Exemplo n.º 1
0
        /// <summary>
        /// Resizes an image using specified interpolation mode.
        /// </summary>
        /// <param name="img">Input image.</param>
        /// <param name="newSize">New image size.</param>
        /// <param name="mode">Interpolation mode.</param>
        /// <returns>Resized image.</returns>
        internal static TColor[,] Resize <TColor>(this TColor[,] img, Size newSize, InterpolationMode mode)
        where TColor : struct, IColor
        {
            switch (mode)
            {
            case InterpolationMode.NearestNeighbor :
                //return img.ApplyFilter(new ResizeNearestNeighbor(newSize.Width, newSize.Height));
                return(ResizeNearsetNeighbur.Resize(img, newSize));    //faster

            case InterpolationMode.Bilinear:
                return(img.ApplyBaseTransformationFilter(new ResizeBilinear(newSize.Width, newSize.Height)));

            case InterpolationMode.Bicubic:
                return(img.ApplyBaseTransformationFilter(new ResizeBicubic(newSize.Width, newSize.Height)));

            default:
                throw new NotSupportedException();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Resizes an image using specified interpolation mode.
        /// </summary>
        /// <param name="img">Input image.</param>
        /// <param name="newSize">New image size.</param>
        /// <param name="mode">Interpolation mode.</param>
        /// <returns>Resized image.</returns>
        internal static Image <TColor, TDepth> Resize <TColor, TDepth>(this Image <TColor, TDepth> img, Size newSize, InterpolationMode mode)
            where TColor : IColor
            where TDepth : struct
        {
            switch (mode)
            {
            case InterpolationMode.NearestNeighbor:
                //return img.ApplyFilter(new ResizeNearestNeighbor(newSize.Width, newSize.Height));
                return(ResizeNearsetNeighbur.ResizeNN(img, newSize));    //faster

            case InterpolationMode.Bilinear:
                return(img.ApplyFilter(new ResizeBilinear(newSize.Width, newSize.Height)));

            case InterpolationMode.Bicubic:
                return(img.ApplyFilter(new ResizeBicubic(newSize.Width, newSize.Height)));

            default:
                throw new NotSupportedException();
            }
        }