/// <summary>
        /// Try to figure out if this is a transmasked texture
        /// </summary>
        public static bool isTransMaskedTexture(byte[] lumpdata)
        {
            /*
             * masked & transmasked have the same first 6 bytes (= 3x short) in common:
             *   origsize
             *   width
             *   height
             *
             * This is a format Doom, Strife or Heretic don't know about. Only ROTT does!
             *
             */

            bool trmaskedTexture = false;

            if (lumpdata.Length > Rott2DTransMaskedHeader.TRANSMASKED_HEADER_SIZE)
            {
                Rott2DTransMaskedHeader header = new Rott2DTransMaskedHeader();
                header.Width      = BitConverter.ToUInt16(lumpdata, 2);   //width
                header.Height     = BitConverter.ToUInt16(lumpdata, 4);   //height
                header.TransLevel = BitConverter.ToUInt16(lumpdata, 10);  //read trans level

                if ((header.Width >= TRANSMASKED_MIN_TEXTURE_BOUNDS) && (header.Width < TRANSMASKED_MAX_TEXTURE_BOUNDS))
                {
                    if ((header.Height >= TRANSMASKED_MIN_TEXTURE_BOUNDS) && (header.Height < TRANSMASKED_MAX_TEXTURE_BOUNDS))
                    {
                        if ((header.TransLevel == 21) || (header.TransLevel == 34))  //check to be sure this is a transmasked.
                        {
                            //we have proably a transmasked
                            trmaskedTexture = true;

                            //extra sanity check on the columns data
                            if (lumpdata.Length < (Rott2DTransMaskedHeader.TRANSMASKED_HEADER_SIZE + (header.Width * sizeof(ushort))))
                            {
                                trmaskedTexture = false;
                            }

                            for (int c = 0; c < header.Width; c++)
                            {
                                if ((lumpdata[Rott2DTransMaskedHeader.TRANSMASKED_HEADER_SIZE + c] > lumpdata.Length) ||
                                    (lumpdata[Rott2DTransMaskedHeader.TRANSMASKED_HEADER_SIZE + c] < ((header.Width) + Rott2DTransMaskedHeader.TRANSMASKED_HEADER_SIZE)))
                                {
                                    trmaskedTexture = true;
                                }
                            }
                        }
                    }
                }
            }

            return(trmaskedTexture);
        }
        private int _dataSize = 0;                          //image data size, without the header
        #endregion

        #region Constructor
        /// <summary>
        /// Constructor
        /// </summary>
        public Rott2DTransMasked(ref byte[] transmaskedLumpData, ref Rott2DPalette palette)
        {
            this.isHeaderReady = false;
            this.isReady       = false;
            this._rawData      = transmaskedLumpData;
            this._palette      = palette;
            this._dataSize     = this.GetDataSize() - Rott2DTransMaskedHeader.TRANSMASKED_HEADER_SIZE;

            //process header data first
            this._transMaskedHeader = new Rott2DTransMaskedHeader();
            this.ProcessTransMaskedHeader();

            //create buffer from size
            if ((this._buffer == null) && (this.isHeaderReady))
            {
                this._buffer = new Bitmap(this._transMaskedHeader.Width, this._transMaskedHeader.Height, PixelFormat.Format24bppRgb);
            }

            //generate buffer bitmap
            this.ProcessLumpData();
        }