示例#1
0
        public void writeDataScaled(byte[][,] raster, int componentIndex, BlockUpsamplingMode mode)
        {
            int x = 0, y = 0, lastblockheight = 0, incrementblock = 0;

            int blockIdx = 0;

            int w = raster[0].GetLength(0);

            //h = raster[0].GetLength(1);

            // Keep looping through all of the blocks until there are no more.
            while (blockIdx < scanDecoded.Count)
            {
                int blockwidth  = 0;
                int blockheight = 0;

                if (x >= w)
                {
                    x = 0; y += incrementblock;
                }

                // Loop through the horizontal component blocks of the MCU first
                // then for each horizontal line write out all of the vertical
                // components
                for (int factorVIndex = 0; factorVIndex < factorV; factorVIndex++)
                {
                    blockwidth = 0;

                    for (int factorHIndex = 0; factorHIndex < factorH; factorHIndex++)
                    {
                        // Captures the width of this block so we can increment the X coordinate
                        byte[,] blockdata = scanDecoded[blockIdx++];

                        // Writes the data at the specific X and Y coordinate of this component
                        writeBlockScaled(raster, blockdata, componentIndex, x, y, mode);

                        blockwidth += blockdata.GetLength(1) * factorUpH;
                        x          += blockdata.GetLength(1) * factorUpH;
                        blockheight = blockdata.GetLength(0) * factorUpV;
                    }

                    y += blockheight;
                    x -= blockwidth;
                    lastblockheight += blockheight;
                }
                y -= lastblockheight;
                incrementblock  = lastblockheight;
                lastblockheight = 0;
                x += blockwidth;
            }
        }
示例#2
0
        public void writeDataScaled(byte[][,] raster, int componentIndex, BlockUpsamplingMode mode)
        {
            int x      = 0;
            int y      = 0;
            int num3   = 0;
            int num4   = 0;
            int num5   = 0;
            int length = raster[0].GetLength(0);
            int num7   = raster[0].GetLength(1);

            while (num5 < this.scanDecoded.Count)
            {
                int num8 = 0;
                int num9 = 0;
                if (x >= length)
                {
                    x  = 0;
                    y += num4;
                }
                for (int i = 0; i < this.factorV; i++)
                {
                    num8 = 0;
                    for (int j = 0; j < this.factorH; j++)
                    {
                        byte[,] blockdata = this.scanDecoded[num5++];
                        this.writeBlockScaled(raster, blockdata, componentIndex, x, y, mode);
                        num8 += blockdata.GetLength(1) * this.factorUpH;
                        x    += blockdata.GetLength(1) * this.factorUpH;
                        num9  = blockdata.GetLength(0) * this.factorUpV;
                    }
                    y    += num9;
                    x    -= num8;
                    num3 += num9;
                }
                y   -= num3;
                num4 = num3;
                num3 = 0;
                x   += num8;
            }
        }
示例#3
0
        public void writeDataScaled(byte[][,] raster, int componentIndex, BlockUpsamplingMode mode)
        {
            int num    = 0;
            int num2   = 0;
            int num3   = 0;
            int num4   = 0;
            int num5   = 0;
            int length = raster[0].GetLength(0);

            while (num5 < scanDecoded.Count)
            {
                int num6 = 0;
                int num7 = 0;
                if (num >= length)
                {
                    num   = 0;
                    num2 += num4;
                }
                for (int i = 0; i < factorV; i++)
                {
                    num6 = 0;
                    for (int j = 0; j < factorH; j++)
                    {
                        byte[,] array = scanDecoded[num5++];
                        writeBlockScaled(raster, array, componentIndex, num, num2, mode);
                        num6 += array.GetLength(1) * factorUpH;
                        num  += array.GetLength(1) * factorUpH;
                        num7  = array.GetLength(0) * factorUpV;
                    }
                    num2 += num7;
                    num  -= num6;
                    num3 += num7;
                }
                num2 -= num3;
                num4  = num3;
                num3  = 0;
                num  += num6;
            }
        }
示例#4
0
        private void writeBlockScaled(byte[][,] raster, byte[,] blockdata, int compIndex, int x, int y, BlockUpsamplingMode mode)
        {
            int w = raster[0].GetLength(0),
                h = raster[0].GetLength(1);

            int factorUpVertical = factorUpV,
                factorUpHorizontal = factorUpH;

            int oldV = blockdata.GetLength(0),
                oldH = blockdata.GetLength(1),
                newV = oldV * factorUpVertical,
                newH = oldH * factorUpHorizontal;

            byte[,] comp = raster[compIndex];

            // Blocks may spill over the frame so we bound by the frame size
            int yMax = newV; if ((y + yMax) > h) yMax = h - y;
            int xMax = newH; if ((x + xMax) > w) xMax = w - x;

            switch (mode)
            {
                case BlockUpsamplingMode.BoxFilter:

                    #region Upsampling by repeating values

                    // Special case 1: No scale-up
                    if (factorUpVertical == 1 && factorUpHorizontal == 1)
                    {
                        for (int u = 0; u < xMax; u++)
                            for (int v = 0; v < yMax; v++)
                                comp[u + x, y + v] = blockdata[v, u];
                    }
                    // Special case 2: Perform scale-up 4 pixels at a time
                    else if (factorUpHorizontal == 2 && 
                             factorUpVertical == 2 && 
                             xMax == newH && yMax == newV)
                    {
                        for (int src_u = 0; src_u < oldH; src_u++)
                        {
                            int bx = src_u * 2 + x;

                            for ( int src_v = 0; src_v < oldV; src_v++)
                            {
                                byte val = blockdata[src_v, src_u];
                                int by = src_v * 2 + y;

                                comp[bx, by] = val;
                                comp[bx, by + 1] = val;
                                comp[bx + 1, by] = val;
                                comp[bx + 1, by + 1] = val;
                            }
                        }
                    }
                    else
                    {
                        /* Perform scaling (Box filter) */
                        for (int u = 0; u < xMax; u++)
                        {
                            int src_u = u / factorUpHorizontal;
                            for (int v = 0; v < yMax; v++)
                            {
                                int src_v = v / factorUpVertical;
                                comp[u + x, y + v] = blockdata[src_v, src_u];
                            }
                        }
                    }


                    #endregion
                    break;

                // JRP 4/7/08 -- This mode is disabled temporarily as it needs to be fixed after
                //               recent performance tweaks.
                //               It can produce slightly better (less blocky) decodings.

                //case BlockUpsamplingMode.Interpolate:
                //    #region Upsampling by interpolation
                //    for (int u = 0; u < newH; u++)
                //    {
                //        for (int v = 0; v < newV; v++)
                //        {
                //            int val = 0;
                //            for (int x = 0; x < factorUpHorizontal; x++)
                //            {
                //                int src_u = (u + x) / factorUpHorizontal;
                //                if (src_u >= oldH) src_u = oldH - 1;
                //                for (int y = 0; y < factorUpVertical; y++)
                //                {
                //                    int src_v = (v + y) / factorUpVertical;
                //                    if (src_v >= oldV) src_v = oldV - 1;
                //                    val += src[src_v, src_u];
                //                }
                //            }
                //            dest[v, u] = (byte)(val / (factorUpHorizontal * factorUpVertical));
                //        }
                //    }
                //    #endregion
                //    break;

                default:
                    throw new ArgumentException("Upsampling mode not supported.");
            }

        }
示例#5
0
        public void writeDataScaled(byte[][,] raster, int componentIndex, BlockUpsamplingMode mode)
        {
            int x = 0, y = 0, lastblockheight = 0, incrementblock = 0;

            int blockIdx = 0;

            int w = raster[0].GetLength(0),
                h = raster[0].GetLength(1);

            // Keep looping through all of the blocks until there are no more.
            while (blockIdx < scanDecoded.Count)
            {
                int blockwidth = 0;
                int blockheight = 0;

                if (x >= w) { x = 0; y += incrementblock; }

                // Loop through the horizontal component blocks of the MCU first
                // then for each horizontal line write out all of the vertical
                // components
                for (int factorVIndex = 0; factorVIndex < factorV; factorVIndex++)
                {
                    blockwidth = 0;

                    for (int factorHIndex = 0; factorHIndex < factorH; factorHIndex++)
                    {
                        // Captures the width of this block so we can increment the X coordinate
                        byte[,] blockdata = scanDecoded[blockIdx++];

                        // Writes the data at the specific X and Y coordinate of this component
                        writeBlockScaled(raster, blockdata, componentIndex, x, y, mode);

                        blockwidth += blockdata.GetLength(1) * factorUpH;
                        x += blockdata.GetLength(1) * factorUpH;
                        blockheight = blockdata.GetLength(0) * factorUpV;
                    }

                    y += blockheight;
                    x -= blockwidth;
                    lastblockheight += blockheight;
                }
                y -= lastblockheight;
                incrementblock = lastblockheight;
                lastblockheight = 0;
                x += blockwidth;
            }
        }
示例#6
0
        /// <summary>
        /// Stretches components as needed to normalize the size of all components.
        /// For example, in a 2x1 (4:2:2) sequence, the Cr and Cb channels will be 
        /// scaled vertically by a factor of 2.
        /// </summary>
        public void scaleByFactors( BlockUpsamplingMode mode )
        {
            int factorUpVertical = factorUpV,
                factorUpHorizontal = factorUpH;

            if (factorUpVertical == 1 && factorUpHorizontal == 1) return;

            for (int i = 0; i < scanDecoded.Count; i++)
            {
                byte[,] src = scanDecoded[i];

                int oldV = src.GetLength(0),
                    oldH = src.GetLength(1),
                    newV = oldV * factorUpVertical,
                    newH = oldH * factorUpHorizontal;
                
                byte[,] dest = new byte[newV, newH];

                switch (mode)
                {
                    case BlockUpsamplingMode.BoxFilter:
                        #region Upsampling by repeating values
                        /* Perform scaling (Box filter) */
                        for (int u = 0; u < newH; u++)
                        {
                            int src_u = u / factorUpHorizontal;
                            for (int v = 0; v < newV; v++)
                            {
                                int src_v = v / factorUpVertical;
                                dest[v, u] = src[src_v, src_u];
                            }
                        }
                        #endregion
                        break;

                    case BlockUpsamplingMode.Interpolate:
                        #region Upsampling by interpolation

                        for (int u = 0; u < newH; u++)
                        {
                            for (int v = 0; v < newV; v++)
                            {
                                int val = 0;

                                for (int x = 0; x < factorUpHorizontal; x++)
                                {
                                    int src_u = (u + x) / factorUpHorizontal;
                                    if (src_u >= oldH) src_u = oldH - 1;

                                    for (int y = 0; y < factorUpVertical; y++)
                                    {
                                        int src_v = (v + y) / factorUpVertical;

                                        if (src_v >= oldV) src_v = oldV - 1;

                                        val += src[src_v, src_u];
                                    }
                                }

                                dest[v, u] = (byte)(val / (factorUpHorizontal * factorUpVertical));
                            }
                        }

                        #endregion
                        break;

                    default:
                        throw new ArgumentException("Upsampling mode not supported.");
                }

                scanDecoded[i] = dest;
            }

        }
示例#7
0
        private void writeBlockScaled(byte[][,] raster, byte[,] blockdata, int compIndex, int x, int y, BlockUpsamplingMode mode)
        {
            int w = raster[0].GetLength(0),
                h = raster[0].GetLength(1);

            int factorUpVertical   = factorUpV,
                factorUpHorizontal = factorUpH;

            int oldV = blockdata.GetLength(0),
                oldH = blockdata.GetLength(1),
                newV = oldV * factorUpVertical,
                newH = oldH * factorUpHorizontal;

            byte[,] comp = raster[compIndex];

            // Blocks may spill over the frame so we bound by the frame size
            int yMax = newV; if ((y + yMax) > h)
            {
                yMax = h - y;
            }
            int xMax = newH; if ((x + xMax) > w)

            {
                xMax = w - x;
            }

            switch (mode)
            {
            case BlockUpsamplingMode.BoxFilter:

                #region Upsampling by repeating values

                // Special case 1: No scale-up
                if (factorUpVertical == 1 && factorUpHorizontal == 1)
                {
                    for (int u = 0; u < xMax; u++)
                    {
                        for (int v = 0; v < yMax; v++)
                        {
                            comp[u + x, y + v] = blockdata[v, u];
                        }
                    }
                }
                // Special case 2: Perform scale-up 4 pixels at a time
                else if (factorUpHorizontal == 2 &&
                         factorUpVertical == 2 &&
                         xMax == newH && yMax == newV)
                {
                    for (int src_u = 0; src_u < oldH; src_u++)
                    {
                        int bx = src_u * 2 + x;

                        for (int src_v = 0; src_v < oldV; src_v++)
                        {
                            byte val = blockdata[src_v, src_u];
                            int  by  = src_v * 2 + y;

                            comp[bx, by]         = val;
                            comp[bx, by + 1]     = val;
                            comp[bx + 1, by]     = val;
                            comp[bx + 1, by + 1] = val;
                        }
                    }
                }
                else
                {
                    /* Perform scaling (Box filter) */
                    for (int u = 0; u < xMax; u++)
                    {
                        int src_u = u / factorUpHorizontal;
                        for (int v = 0; v < yMax; v++)
                        {
                            int src_v = v / factorUpVertical;
                            comp[u + x, y + v] = blockdata[src_v, src_u];
                        }
                    }
                }


                #endregion
                break;

            // JRP 4/7/08 -- This mode is disabled temporarily as it needs to be fixed after
            //               recent performance tweaks.
            //               It can produce slightly better (less blocky) decodings.

            //case BlockUpsamplingMode.Interpolate:
            //    #region Upsampling by interpolation
            //    for (int u = 0; u < newH; u++)
            //    {
            //        for (int v = 0; v < newV; v++)
            //        {
            //            int val = 0;
            //            for (int x = 0; x < factorUpHorizontal; x++)
            //            {
            //                int src_u = (u + x) / factorUpHorizontal;
            //                if (src_u >= oldH) src_u = oldH - 1;
            //                for (int y = 0; y < factorUpVertical; y++)
            //                {
            //                    int src_v = (v + y) / factorUpVertical;
            //                    if (src_v >= oldV) src_v = oldV - 1;
            //                    val += src[src_v, src_u];
            //                }
            //            }
            //            dest[v, u] = (byte)(val / (factorUpHorizontal * factorUpVertical));
            //        }
            //    }
            //    #endregion
            //    break;

            default:
                throw new ArgumentException("Upsampling mode not supported.");
            }
        }
示例#8
0
        /// <summary>
        /// Stretches components as needed to normalize the size of all components.
        /// For example, in a 2x1 (4:2:2) sequence, the Cr and Cb channels will be
        /// scaled vertically by a factor of 2.
        /// </summary>
        public void scaleByFactors(BlockUpsamplingMode mode)
        {
            int factorUpVertical   = factorUpV,
                factorUpHorizontal = factorUpH;

            if (factorUpVertical == 1 && factorUpHorizontal == 1)
            {
                return;
            }

            for (int i = 0; i < scanDecoded.Count; i++)
            {
                byte[,] src = scanDecoded[i];

                int oldV = src.GetLength(0),
                    oldH = src.GetLength(1),
                    newV = oldV * factorUpVertical,
                    newH = oldH * factorUpHorizontal;

                byte[,] dest = new byte[newV, newH];

                switch (mode)
                {
                case BlockUpsamplingMode.BoxFilter:
                    #region Upsampling by repeating values
                    /* Perform scaling (Box filter) */
                    for (int u = 0; u < newH; u++)
                    {
                        int src_u = u / factorUpHorizontal;
                        for (int v = 0; v < newV; v++)
                        {
                            int src_v = v / factorUpVertical;
                            dest[v, u] = src[src_v, src_u];
                        }
                    }
                    #endregion
                    break;

                case BlockUpsamplingMode.Interpolate:
                    #region Upsampling by interpolation

                    for (int u = 0; u < newH; u++)
                    {
                        for (int v = 0; v < newV; v++)
                        {
                            int val = 0;

                            for (int x = 0; x < factorUpHorizontal; x++)
                            {
                                int src_u = (u + x) / factorUpHorizontal;
                                if (src_u >= oldH)
                                {
                                    src_u = oldH - 1;
                                }

                                for (int y = 0; y < factorUpVertical; y++)
                                {
                                    int src_v = (v + y) / factorUpVertical;

                                    if (src_v >= oldV)
                                    {
                                        src_v = oldV - 1;
                                    }

                                    val += src[src_v, src_u];
                                }
                            }

                            dest[v, u] = (byte)(val / (factorUpHorizontal * factorUpVertical));
                        }
                    }

                    #endregion
                    break;

                default:
                    throw new ArgumentException("Upsampling mode not supported.");
                }

                scanDecoded[i] = dest;
            }
        }
示例#9
0
        public void writeBlockScaled(byte[][,] raster, byte[,] blockdata, int compIndex, int x, int y, BlockUpsamplingMode mode)
        {
            int length    = raster[0].GetLength(0);
            int length2   = raster[0].GetLength(1);
            int factorUpV = this.factorUpV;
            int factorUpH = this.factorUpH;
            int length3   = blockdata.GetLength(0);
            int length4   = blockdata.GetLength(1);
            int num       = length3 * factorUpV;
            int num2      = length4 * factorUpH;

            byte[,] array = raster[compIndex];
            int num3 = num;

            if (y + num3 > length2)
            {
                num3 = length2 - y;
            }
            int num4 = num2;

            if (x + num4 > length)
            {
                num4 = length - x;
            }
            if (mode == BlockUpsamplingMode.BoxFilter)
            {
                if (factorUpV == 1 && factorUpH == 1)
                {
                    for (int i = 0; i < num4; i++)
                    {
                        for (int j = 0; j < num3; j++)
                        {
                            array[i + x, y + j] = blockdata[j, i];
                        }
                    }
                    return;
                }
                if (factorUpH == 2 && factorUpV == 2 && num4 == num2 && num3 == num)
                {
                    for (int k = 0; k < length4; k++)
                    {
                        int num5 = k * 2 + x;
                        for (int l = 0; l < length3; l++)
                        {
                            byte b    = blockdata[l, k];
                            int  num6 = l * 2 + y;
                            array[num5, num6]         = b;
                            array[num5, num6 + 1]     = b;
                            array[num5 + 1, num6]     = b;
                            array[num5 + 1, num6 + 1] = b;
                        }
                    }
                    return;
                }
                for (int m = 0; m < num4; m++)
                {
                    int num7 = m / factorUpH;
                    for (int n = 0; n < num3; n++)
                    {
                        int num8 = n / factorUpV;
                        array[m + x, y + n] = blockdata[num8, num7];
                    }
                }
                return;
            }
            throw new ArgumentException("Upsampling mode not supported.");
        }
示例#10
0
        public void scaleByFactors(BlockUpsamplingMode mode)
        {
            int factorUpV = this.factorUpV;
            int factorUpH = this.factorUpH;

            if (factorUpV == 1 && factorUpH == 1)
            {
                return;
            }
            for (int i = 0; i < scanDecoded.Count; i++)
            {
                byte[,] array = scanDecoded[i];
                int length  = array.GetLength(0);
                int length2 = array.GetLength(1);
                int num     = length * factorUpV;
                int num2    = length2 * factorUpH;
                byte[,] array2 = new byte[num, num2];
                switch (mode)
                {
                case BlockUpsamplingMode.BoxFilter:
                {
                    for (int n = 0; n < num2; n++)
                    {
                        int num6 = n / factorUpH;
                        for (int num7 = 0; num7 < num; num7++)
                        {
                            int num8 = num7 / factorUpV;
                            array2[num7, n] = array[num8, num6];
                        }
                    }
                    break;
                }

                case BlockUpsamplingMode.Interpolate:
                {
                    for (int j = 0; j < num2; j++)
                    {
                        for (int k = 0; k < num; k++)
                        {
                            int num3 = 0;
                            for (int l = 0; l < factorUpH; l++)
                            {
                                int num4 = (j + l) / factorUpH;
                                if (num4 >= length2)
                                {
                                    num4 = length2 - 1;
                                }
                                for (int m = 0; m < factorUpV; m++)
                                {
                                    int num5 = (k + m) / factorUpV;
                                    if (num5 >= length)
                                    {
                                        num5 = length - 1;
                                    }
                                    num3 += array[num5, num4];
                                }
                            }
                            array2[k, j] = (byte)(num3 / (factorUpH * factorUpV));
                        }
                    }
                    break;
                }

                default:
                    throw new ArgumentException("Upsampling mode not supported.");
                }
                scanDecoded[i] = array2;
            }
        }
示例#11
0
        private void writeBlockScaled(byte[][,] raster, byte[,] blockdata, int compIndex, int x, int y, BlockUpsamplingMode mode)
        {
            int num11;
            int num12;
            int length    = raster[0].GetLength(0);
            int num2      = raster[0].GetLength(1);
            int factorUpV = this.factorUpV;
            int factorUpH = this.factorUpH;
            int num5      = blockdata.GetLength(0);
            int num6      = blockdata.GetLength(1);
            int num7      = num5 * factorUpV;
            int num8      = num6 * factorUpH;

            byte[,] buffer = raster[compIndex];
            int num9 = num7;

            if ((y + num9) > num2)
            {
                num9 = num2 - y;
            }
            int num10 = num8;

            if ((x + num10) > length)
            {
                num10 = length - x;
            }
            if (mode != BlockUpsamplingMode.BoxFilter)
            {
                throw new ArgumentException("Upsampling mode not supported.");
            }
            if ((factorUpV == 1) && (factorUpH == 1))
            {
                for (num11 = 0; num11 < num10; num11++)
                {
                    num12 = 0;
                    while (num12 < num9)
                    {
                        buffer[num11 + x, y + num12] = blockdata[num12, num11];
                        num12++;
                    }
                }
            }
            else
            {
                int num13;
                int num15;
                if ((((factorUpH == 2) && (factorUpV == 2)) && (num10 == num8)) && (num9 == num7))
                {
                    num13 = 0;
                    while (num13 < num6)
                    {
                        int num14 = (num13 * 2) + x;
                        num15 = 0;
                        while (num15 < num5)
                        {
                            byte num16 = blockdata[num15, num13];
                            int  num17 = (num15 * 2) + y;
                            buffer[num14, num17]         = num16;
                            buffer[num14, num17 + 1]     = num16;
                            buffer[num14 + 1, num17]     = num16;
                            buffer[num14 + 1, num17 + 1] = num16;
                            num15++;
                        }
                        num13++;
                    }
                }
                else
                {
                    for (num11 = 0; num11 < num10; num11++)
                    {
                        num13 = num11 / factorUpH;
                        for (num12 = 0; num12 < num9; num12++)
                        {
                            num15 = num12 / factorUpV;
                            buffer[num11 + x, y + num12] = blockdata[num15, num13];
                        }
                    }
                }
            }
        }
示例#12
0
        public void scaleByFactors(BlockUpsamplingMode mode)
        {
            int factorUpV = this.factorUpV;
            int factorUpH = this.factorUpH;

            if ((factorUpV != 1) || (factorUpH != 1))
            {
                for (int i = 0; i < this.scanDecoded.Count; i++)
                {
                    int num8;
                    int num9;
                    int num11;
                    byte[,] buffer = this.scanDecoded[i];
                    int length = buffer.GetLength(0);
                    int num5   = buffer.GetLength(1);
                    int num6   = length * factorUpV;
                    int num7   = num5 * factorUpH;
                    byte[,] buffer2 = new byte[num6, num7];
                    switch (mode)
                    {
                    case BlockUpsamplingMode.BoxFilter:
                        num8 = 0;
                        goto Label_00C4;

                    case BlockUpsamplingMode.Interpolate:
                        num8 = 0;
                        goto Label_018E;

                    default:
                        throw new ArgumentException("Upsampling mode not supported.");
                    }
Label_0082:
                    num9 = num8 / factorUpH;
                    int num10 = 0;
                    while (num10 < num6)
                    {
                        num11 = num10 / factorUpV;
                        buffer2[num10, num8] = buffer[num11, num9];
                        num10++;
                    }
                    num8++;
Label_00C4:
                    if (num8 < num7)
                    {
                        goto Label_0082;
                    }
                    goto Label_01AA;
Label_00DD:
                    num10 = 0;
                    while (num10 < num6)
                    {
                        int num12 = 0;
                        for (int j = 0; j < factorUpH; j++)
                        {
                            num9 = (num8 + j) / factorUpH;
                            if (num9 >= num5)
                            {
                                num9 = num5 - 1;
                            }
                            for (int k = 0; k < factorUpV; k++)
                            {
                                num11 = (num10 + k) / factorUpV;
                                if (num11 >= length)
                                {
                                    num11 = length - 1;
                                }
                                num12 += buffer[num11, num9];
                            }
                        }
                        buffer2[num10, num8] = (byte)(num12 / (factorUpH * factorUpV));
                        num10++;
                    }
                    num8++;
Label_018E:
                    if (num8 < num7)
                    {
                        goto Label_00DD;
                    }
Label_01AA:
                    this.scanDecoded[i] = buffer2;
                }
            }
        }
示例#13
0
 public void writeDataScaled(byte[][,] raster, int componentIndex, BlockUpsamplingMode mode)
 {
     int x = 0;
     int y = 0;
     int num3 = 0;
     int num4 = 0;
     int num5 = 0;
     int length = raster[0].GetLength(0);
     int num7 = raster[0].GetLength(1);
     while (num5 < this.scanDecoded.Count)
     {
         int num8 = 0;
         int num9 = 0;
         if (x >= length)
         {
             x = 0;
             y += num4;
         }
         for (int i = 0; i < this.factorV; i++)
         {
             num8 = 0;
             for (int j = 0; j < this.factorH; j++)
             {
                 byte[,] blockdata = this.scanDecoded[num5++];
                 this.writeBlockScaled(raster, blockdata, componentIndex, x, y, mode);
                 num8 += blockdata.GetLength(1) * this.factorUpH;
                 x += blockdata.GetLength(1) * this.factorUpH;
                 num9 = blockdata.GetLength(0) * this.factorUpV;
             }
             y += num9;
             x -= num8;
             num3 += num9;
         }
         y -= num3;
         num4 = num3;
         num3 = 0;
         x += num8;
     }
 }
示例#14
0
 private void writeBlockScaled(byte[][,] raster, byte[,] blockdata, int compIndex, int x, int y, BlockUpsamplingMode mode)
 {
     int num11;
     int num12;
     int length = raster[0].GetLength(0);
     int num2 = raster[0].GetLength(1);
     int factorUpV = this.factorUpV;
     int factorUpH = this.factorUpH;
     int num5 = blockdata.GetLength(0);
     int num6 = blockdata.GetLength(1);
     int num7 = num5 * factorUpV;
     int num8 = num6 * factorUpH;
     byte[,] buffer = raster[compIndex];
     int num9 = num7;
     if ((y + num9) > num2)
     {
         num9 = num2 - y;
     }
     int num10 = num8;
     if ((x + num10) > length)
     {
         num10 = length - x;
     }
     if (mode != BlockUpsamplingMode.BoxFilter)
     {
         throw new ArgumentException("Upsampling mode not supported.");
     }
     if ((factorUpV == 1) && (factorUpH == 1))
     {
         for (num11 = 0; num11 < num10; num11++)
         {
             num12 = 0;
             while (num12 < num9)
             {
                 buffer[num11 + x, y + num12] = blockdata[num12, num11];
                 num12++;
             }
         }
     }
     else
     {
         int num13;
         int num15;
         if ((((factorUpH == 2) && (factorUpV == 2)) && (num10 == num8)) && (num9 == num7))
         {
             num13 = 0;
             while (num13 < num6)
             {
                 int num14 = (num13 * 2) + x;
                 num15 = 0;
                 while (num15 < num5)
                 {
                     byte num16 = blockdata[num15, num13];
                     int num17 = (num15 * 2) + y;
                     buffer[num14, num17] = num16;
                     buffer[num14, num17 + 1] = num16;
                     buffer[num14 + 1, num17] = num16;
                     buffer[num14 + 1, num17 + 1] = num16;
                     num15++;
                 }
                 num13++;
             }
         }
         else
         {
             for (num11 = 0; num11 < num10; num11++)
             {
                 num13 = num11 / factorUpH;
                 for (num12 = 0; num12 < num9; num12++)
                 {
                     num15 = num12 / factorUpV;
                     buffer[num11 + x, y + num12] = blockdata[num15, num13];
                 }
             }
         }
     }
 }
示例#15
0
        public void scaleByFactors(BlockUpsamplingMode mode)
        {
            int factorUpV = this.factorUpV;
            int factorUpH = this.factorUpH;
            if ((factorUpV != 1) || (factorUpH != 1))
            {
                for (int i = 0; i < this.scanDecoded.Count; i++)
                {
                    int num8;
                    int num9;
                    int num11;
                    byte[,] buffer = this.scanDecoded[i];
                    int length = buffer.GetLength(0);
                    int num5 = buffer.GetLength(1);
                    int num6 = length * factorUpV;
                    int num7 = num5 * factorUpH;
                    byte[,] buffer2 = new byte[num6, num7];
                    switch (mode)
                    {
                        case BlockUpsamplingMode.BoxFilter:
                            num8 = 0;
                            goto Label_00C4;

                        case BlockUpsamplingMode.Interpolate:
                            num8 = 0;
                            goto Label_018E;

                        default:
                            throw new ArgumentException("Upsampling mode not supported.");
                    }
                Label_0082:
                    num9 = num8 / factorUpH;
                    int num10 = 0;
                    while (num10 < num6)
                    {
                        num11 = num10 / factorUpV;
                        buffer2[num10, num8] = buffer[num11, num9];
                        num10++;
                    }
                    num8++;
                Label_00C4:
                    if (num8 < num7)
                    {
                        goto Label_0082;
                    }
                    goto Label_01AA;
                Label_00DD:
                    num10 = 0;
                    while (num10 < num6)
                    {
                        int num12 = 0;
                        for (int j = 0; j < factorUpH; j++)
                        {
                            num9 = (num8 + j) / factorUpH;
                            if (num9 >= num5)
                            {
                                num9 = num5 - 1;
                            }
                            for (int k = 0; k < factorUpV; k++)
                            {
                                num11 = (num10 + k) / factorUpV;
                                if (num11 >= length)
                                {
                                    num11 = length - 1;
                                }
                                num12 += buffer[num11, num9];
                            }
                        }
                        buffer2[num10, num8] = (byte) (num12 / (factorUpH * factorUpV));
                        num10++;
                    }
                    num8++;
                Label_018E:
                    if (num8 < num7)
                    {
                        goto Label_00DD;
                    }
                Label_01AA:
                    this.scanDecoded[i] = buffer2;
                }
            }
        }