/// <summary>
        /// saves the icon to a stream
        /// </summary>
        /// <param name="str">The string.</param>
        /// <exception cref="System.ArgumentNullException">str</exception>
        /// <exception cref="System.Exception">icon is empty</exception>
        public unsafe void Save(Stream str)
        {
            if (str == null)
            {
                throw new ArgumentNullException("str");
            }
            if (_images.Count < 1)
            {
                throw new Exception("icon is empty");
            }
            //write file header
            ICONDIR fileheader = new ICONDIR((short)(_images.Count));

            fileheader.Write(str);
            //write direntries
            int fileoffset = sizeof(ICONDIR) +
                             _images.Count * sizeof(ICONDIRENTRY);

            foreach (IconImage img in _images)
            {
                ICONDIRENTRY entry = img.GetEntry();
                entry.FileOffset = fileoffset;
                fileoffset      += entry.SizeInBytes;
                entry.Write(str);
            }
            //write images
            foreach (IconImage img in _images)
            {
                img.Write(str);
            }
        }
        /// <summary>
        /// Loads the specified string.
        /// </summary>
        /// <param name="str">The string.</param>
        /// <exception cref="System.Exception">
        /// this is not an icon file
        /// or
        /// no iconimages contained
        /// </exception>
        private void Load(Stream str)
        {
            //read the file header and check
            ICONDIR fileheader = new ICONDIR(str);

            if (fileheader.idType != 1)
            {
                throw new Exception("this is not an icon file");
            }
            if (fileheader.idCount < 1)
            {
                throw new Exception("no iconimages contained");
            }
            //read direntries
            ICONDIRENTRY[] entries = new ICONDIRENTRY[fileheader.idCount];
            for (int i = 0; i < fileheader.idCount; i++)
            {
                entries[i] = new ICONDIRENTRY(str);
            }
            //read images
            for (int i = 0; i < fileheader.idCount; i++)
            {
                _images.Add(IconImage.FromStream(str));
            }
        }