//the header contains all the basic information for the psd, such as its size
        private void parseHeader()
        {
            Console.Out.WriteLine("parsing header");

            signiture = bytes.getString(4);
            if (signiture != "8BPS")
            {
                throw new Exception("Incorrect PSD signiture: " + signiture);
            }
            traceProperty("signiture", signiture);

            //read the version
            version = bytes.getUI16();
            if (version != 1)
            {
                if (version == 2)
                {
                    throw new Exception("PSB is not supported.");
                }
                else
                {
                    throw new Exception("Unknown version: " + version);
                }
            }
            traceProperty("version", version);

            //there are 6 reserved bytes that dont do anything
            bytes.skipBytes(6);

            //the number of color channels
            numberOfChannels = bytes.getUI16();
            traceProperty("number of channels", numberOfChannels);

            //the width and height of the canvas in pixels
            height = bytes.getUI32();
            width  = bytes.getUI32();
            traceProperty("width", width);
            traceProperty("height", height);

            //the number of bits per channel
            bitDepth = bytes.getUI16();
            traceProperty("bit depth", bitDepth);

            //the color mode, there is an enum for this called colorModeEnum
            colorMode = bytes.getUI16();
            if (ColorModeEnum.getName(colorMode) == null)
            {
                throw new Exception("Unknown color mode: " + colorMode);
            }
            traceProperty("color mode", ColorModeEnum.getName(colorMode));
        }
        //parses the color mode data, e.g. whether it is rgb or cymk,
        //i can not parse indexed or duotone colors
        private void parseColorModeData()
        {
            Console.Out.WriteLine("parsing color mode data");

            uint length = bytes.getUI32();

            switch (colorMode)
            {
            case ColorModeEnum.INDEXED:
                throw new Exception("Indexed color mode not supported");

            case ColorModeEnum.DUOTONE:
                throw new Exception("Duotone color mode not supported");

            default:
                if (length != 0)
                {
                    throw new Exception("Color mode data found for: " + ColorModeEnum.getName(colorMode));
                }
                break;
            }
        }