コード例 #1
0
ファイル: Rott2DMasked.cs プロジェクト: suglasp/ROTTWadReader
        /// <summary>
        /// Try to figure out if this is a masked texture
        /// </summary>
        public static bool isMaskedTexture(byte[] lumpdata)
        {
            /*
             * masked & transmasked have the same first 6 bytes (= 3x short) in common:
             *   origsize
             *   width
             *   height
             *
             * Masked textures are very alike to the Doom masked textures.
             * Only the two extra bits (before and after each post) are not present in ROTT Masked textures.
             * Doom used these two extra bits for, non x86, NExT machines.
             *
             */

            bool maskedTexture = false;

            if (lumpdata.Length > Rott2DMaskedHeader.MASKED_HEADER_SIZE)
            {
                Rott2DMaskedHeader header = new Rott2DMaskedHeader();
                header.Width  = BitConverter.ToUInt16(lumpdata, 2);       //width
                header.Height = BitConverter.ToUInt16(lumpdata, 4);       //height


                if ((header.Width >= MASKED_MIN_TEXTURE_BOUNDS) && (header.Width < MASKED_MAX_TEXTURE_BOUNDS))
                {
                    if ((header.Height >= MASKED_MIN_TEXTURE_BOUNDS) && (header.Height < MASKED_MAX_TEXTURE_BOUNDS))
                    {
                        maskedTexture = true;  //probably a masked textures

                        //do an extra check to be sure this is not a transmasked
                        ushort lastheaderByte = BitConverter.ToUInt16(lumpdata, 10); //standard masked has no translevel, so cannot be 21 or 34

                        if (((lastheaderByte == 21) || (lastheaderByte == 34)) && ((header.Width >= 64) && (header.Height >= 64)))
                        {
                            maskedTexture = false;
                        }                          //probably this is a transmasked texture, mark it as none
                    }
                }
            }

            return(maskedTexture);
        }
コード例 #2
0
ファイル: Rott2DMasked.cs プロジェクト: suglasp/ROTTWadReader
        private int _dataSize = 0;                //image data size, without the header
        #endregion

        #region Constructor
        /// <summary>
        /// Constructor
        /// </summary>
        public Rott2DMasked(ref byte[] maskedLumpData, ref Rott2DPalette palette)
        {
            this.isHeaderReady = false;
            this.isReady       = false;
            this._rawData      = maskedLumpData;
            this._palette      = palette;
            this._dataSize     = this.GetDataSize() - Rott2DMaskedHeader.MASKED_HEADER_SIZE;

            //process header data first
            this._maskedHeader = new Rott2DMaskedHeader();
            this.ProcessMaskedHeader();

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

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