Пример #1
0
        /// <summary>
        /// Performs nearest-neighbor resizing on a LAB bitmap.
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        private BitmapLAB ResizeNearestNeighborLAB(BitmapLAB input)
        {
            // Calculate horizontal ratio of input:output
            double rX = input.Width / (float)Math.Max(this.TargetSize.Width, 1);
            // Calculate vertical ratio of input:output
            double rY = input.Height / (float)Math.Max(this.TargetSize.Height, 1);

            if (rX == 0.0 && rY == 0.0)
            {
                return(input); // No scaling necessary.
            }
            BitmapLAB output = new BitmapLAB(this.TargetSize);

            for (int y = 0; y < this.TargetSize.Height; y++)
            {
                for (int x = 0; x < this.TargetSize.Width; x++)
                {
                    output[x, y] = input[(int)Math.Floor(x * rX), (int)Math.Floor(y * rY)];
                }
            }

            return(output);
        }
Пример #2
0
        protected override Frame RenderFrame(long frameIndex)
        {
            var frame = this.Input.GetFrame(frameIndex);

            for (int i = 0; i < frame.Video.Count; i++)
            {
                var bitmap = frame.Video[i];

                if (bitmap is BitmapCMYK)
                {
                    BitmapCMYK input  = (BitmapCMYK)bitmap;
                    BitmapCMYK output = new BitmapCMYK((int)(input.Width * this.ScaleFactor), (int)(input.Height * this.ScaleFactor));

                    for (int y = 0; y < input.Height; y++)    // Columns
                    {
                        for (int x = 0; x < input.Width; x++) // Rows
                        {
                            for (int b = (int)(y * this.ScaleFactor), j = 0; j < this.ScaleFactor; b++, j++)
                            {
                                for (int a = (int)(x * this.ScaleFactor), k = 0; i < this.ScaleFactor; a++, k++)
                                {
                                    output[a, b] = input[x, y];
                                }
                            }
                        }
                    }

                    frame.Video[i] = output;
                }
                else if (bitmap is BitmapLAB)
                {
                    BitmapLAB input  = (BitmapLAB)bitmap;
                    BitmapLAB output = new BitmapLAB((int)(input.Width * this.ScaleFactor), (int)(input.Height * this.ScaleFactor));

                    for (int y = 0; y < input.Height; y++)    // Columns
                    {
                        for (int x = 0; x < input.Width; x++) // Rows
                        {
                            for (int b = (int)(y * this.ScaleFactor), j = 0; j < this.ScaleFactor; b++, j++)
                            {
                                for (int a = (int)(x * this.ScaleFactor), k = 0; i < this.ScaleFactor; a++, k++)
                                {
                                    output[a, b] = input[x, y];
                                }
                            }
                        }
                    }

                    frame.Video[i] = output;
                }
                else if (bitmap is BitmapRGB)
                {
                    BitmapRGB input  = (BitmapRGB)bitmap;
                    BitmapRGB output = new BitmapRGB((int)(input.Width * this.ScaleFactor), (int)(input.Height * this.ScaleFactor));

                    for (int y = 0; y < input.Height; y++)    // Columns
                    {
                        for (int x = 0; x < input.Width; x++) // Rows
                        {
                            for (int b = (int)(y * this.ScaleFactor), j = 0; j < this.ScaleFactor; b++, j++)
                            {
                                for (int a = (int)(x * this.ScaleFactor), k = 0; i < this.ScaleFactor; a++, k++)
                                {
                                    output[a, b] = input[x, y];
                                }
                            }
                        }
                    }

                    frame.Video[i] = output;
                }
                else if (bitmap is BitmapYCC)
                {
                    BitmapYCC input  = (BitmapYCC)bitmap;
                    BitmapYCC output = new BitmapYCC((int)(input.Width * this.ScaleFactor), (int)(input.Height * this.ScaleFactor));

                    for (int y = 0; y < input.Height; y++)    // Columns
                    {
                        for (int x = 0; x < input.Width; x++) // Rows
                        {
                            for (int b = (int)(y * this.ScaleFactor), j = 0; j < this.ScaleFactor; b++, j++)
                            {
                                for (int a = (int)(x * this.ScaleFactor), k = 0; i < this.ScaleFactor; a++, k++)
                                {
                                    output[a, b] = input[x, y];
                                }
                            }
                        }
                    }

                    frame.Video[i] = output;
                }
            }
            return(frame);
        }
Пример #3
0
        protected override Frame RenderFrame(long frameIndex)
        {
            var frame = this.Input.GetFrame(frameIndex);

            for (int i = 0; i < frame.Video.Count; i++)
            {
                var bitmap = frame.Video[i];

                if (bitmap is BitmapCMYK)
                {
                    BitmapCMYK input = (BitmapCMYK)bitmap;
                    BitmapCMYK output = new BitmapCMYK((int)(input.Width * this.ScaleFactor), (int)(input.Height * this.ScaleFactor));

                    for (int y = 0; y < input.Height; y++) // Columns
                        for (int x = 0; x < input.Width; x++) // Rows
                            for (int b = (int)(y * this.ScaleFactor), j = 0; j < this.ScaleFactor; b++,j++)
                                for (int a = (int)(x * this.ScaleFactor), k = 0; i < this.ScaleFactor; a++, k++)
                                    output[a, b] = input[x, y];

                    frame.Video[i] = output;
                }
                else if (bitmap is BitmapLAB)
                {
                    BitmapLAB input = (BitmapLAB)bitmap;
                    BitmapLAB output = new BitmapLAB((int)(input.Width * this.ScaleFactor), (int)(input.Height * this.ScaleFactor));

                    for (int y = 0; y < input.Height; y++) // Columns
                        for (int x = 0; x < input.Width; x++) // Rows
                            for (int b = (int)(y * this.ScaleFactor), j = 0; j < this.ScaleFactor; b++, j++)
                                for (int a = (int)(x * this.ScaleFactor), k = 0; i < this.ScaleFactor; a++, k++)
                                    output[a, b] = input[x, y];

                    frame.Video[i] = output;
                }
                else if (bitmap is BitmapRGB)
                {
                    BitmapRGB input = (BitmapRGB)bitmap;
                    BitmapRGB output = new BitmapRGB((int)(input.Width * this.ScaleFactor), (int)(input.Height * this.ScaleFactor));

                    for (int y = 0; y < input.Height; y++) // Columns
                        for (int x = 0; x < input.Width; x++) // Rows
                            for (int b = (int)(y * this.ScaleFactor), j = 0; j < this.ScaleFactor; b++, j++)
                                for (int a = (int)(x * this.ScaleFactor), k = 0; i < this.ScaleFactor; a++, k++)
                                    output[a, b] = input[x, y];

                    frame.Video[i] = output;
                }
                else if (bitmap is BitmapYCC)
                {
                    BitmapYCC input = (BitmapYCC)bitmap;
                    BitmapYCC output = new BitmapYCC((int)(input.Width * this.ScaleFactor), (int)(input.Height * this.ScaleFactor));

                    for (int y = 0; y < input.Height; y++) // Columns
                        for (int x = 0; x < input.Width; x++) // Rows
                            for (int b = (int)(y * this.ScaleFactor), j = 0; j < this.ScaleFactor; b++, j++)
                                for (int a = (int)(x * this.ScaleFactor), k = 0; i < this.ScaleFactor; a++, k++)
                                    output[a, b] = input[x, y];

                    frame.Video[i] = output;
                }
            }
            return frame;
        }
Пример #4
0
        /// <summary>
        /// Performs nearest-neighbor resizing on a LAB bitmap.
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        private BitmapLAB ResizeNearestNeighborLAB(BitmapLAB input)
        {
            // Calculate horizontal ratio of input:output
            double rX = input.Width / (float)Math.Max(this.TargetSize.Width, 1);
            // Calculate vertical ratio of input:output
            double rY = input.Height / (float)Math.Max(this.TargetSize.Height, 1);

            if (rX == 0.0 && rY == 0.0)
                return input; // No scaling necessary.

            BitmapLAB output = new BitmapLAB(this.TargetSize);

            for (int y = 0; y < this.TargetSize.Height; y++)
                for (int x = 0; x < this.TargetSize.Width; x++)
                    output[x, y] = input[(int)Math.Floor(x * rX), (int)Math.Floor(y * rY)];

            return output;
        }