ZForge.Controls.TreeViewAdv.GifDecoder.ReadColorTable C# (CSharp) Method

ReadColorTable() private method

private ReadColorTable ( int ncolors ) : int[]
ncolors int
return int[]
        private int[] ReadColorTable(int ncolors)
        {
            int nbytes = 3 * ncolors;
            int[] tab = null;
            byte[] c = new byte[nbytes];
            int n = 0;
            try
            {
                n = inStream.Read(c, 0, c.Length );
            }
            catch (IOException)
            {
            }
            if (n < nbytes)
            {
                status = StatusFormatError;
            }
            else
            {
                tab = new int[256]; // max size to avoid bounds checks
                int i = 0;
                int j = 0;
                while (i < ncolors)
                {
                    uint r = ((uint)c[j++]) & 0xff;
                    uint g = ((uint)c[j++]) & 0xff;
                    uint b = ((uint)c[j++]) & 0xff;
                    tab[i++] = ( int ) ( 0xff000000 | (r << 16) | (g << 8) | b );
                }
            }
            return tab;
        }