Exemplo n.º 1
0
        /// <summary>
        /// Constructor
        /// </summary>
        protected Rott2DRaw(ushort width, ushort height, ref byte[] rawLumpData, ref Rott2DPalette palette)
        {
            this.isReady  = false;
            this._rawData = rawLumpData;
            this._palette = palette;

            if (this._buffer == null)
            {
                this._buffer = new Bitmap(width, height, PixelFormat.Format24bppRgb);
            }

            this.ProcessLumpData(); //generate !
        }
Exemplo n.º 2
0
        /// <summary>
        /// Unload the buffer
        /// </summary>
        protected virtual void Unload()
        {
            //release backbuffer
            if (this._buffer != null)
            {
                this._buffer.Dispose();
                this._buffer = null;
            }

            //release color palette
            if (this._palette != null)
            {
                this._palette.Dispose();
                this._palette = null;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Constructor
        /// </summary>
        public Rott2DColormap(string name, ref byte[] colormapLumpData, ref Rott2DPalette palette)
        {
            this.isReady    = false;
            this._rawData   = colormapLumpData;
            this._palette   = palette;
            this._colorMaps = new byte[COLORMAP_COUNT, COLORMAP_SIZE];
            //this._colorMaps = new byte[COLORMAP_SIZE, COLORMAP_COUNT];

            //create buffer from size
            if ((this._buffer == null) && (!this.isReady))
            {
                //this._buffer = new Bitmap(COLORMAP_COUNT, COLORMAP_SIZE, PixelFormat.Format24bppRgb);
                this._buffer = new Bitmap(COLORMAP_SIZE, COLORMAP_COUNT, PixelFormat.Format24bppRgb);
            }

            this.ProcessLumpData(); //generate !
        }
Exemplo n.º 4
0
        private Rott2DPicHeader _picHeader; //small picture texture header
        #endregion

        #region Constructor
        /// <summary>
        /// Constructor
        /// </summary>
        public Rott2DPic(ref byte[] picLumpData, ref Rott2DPalette palette)
        {
            this.isHeaderReady = false;
            this.isReady       = false;
            this._rawData      = picLumpData;
            this._palette      = palette;

            //process header data first
            this._picHeader = new Rott2DPicHeader();
            this.ProcessPicHeader();

            //create buffer from size
            if ((this._buffer == null) && (this.isHeaderReady))
            {
                this._buffer = new Bitmap(this._picHeader.PicWidth, this._picHeader.PicHeight, PixelFormat.Format24bppRgb);
            }

            //generate buffer bitmap
            this.ProcessLumpData();
        }
Exemplo n.º 5
0
        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();
        }
Exemplo n.º 6
0
 /// <summary>
 /// Constructor
 /// </summary>
 public Rott2DSky(string name, ref byte[] skyLumpData, ref Rott2DPalette palette) : base(name, SKY_TEXTURE_WIDTH, SKY_TEXTURE_HEIGHT, ref skyLumpData, ref palette)
 {
     this.ProcessLumpData(); //generate !
 }
Exemplo n.º 7
0
 /// <summary>
 /// Constructor
 /// </summary>
 public Rott2DFlat(string name, ref byte[] flatLumpData, ref Rott2DPalette palette) : base(name, FLAT_TEXTURE_WIDTH, FLAT_TEXTURE_HEIGHT, ref flatLumpData, ref palette)
 {
     this.ProcessLumpData(); //generate !
 }
        /// <summary>
        /// Get lump type (by data)
        /// </summary>
        public Rott2DMarkerType getLumpType(byte[] data)
        {
            Rott2DMarkerType mkrType = Rott2DMarkerType.mtUnknown;

            /*
             * If data is larger then zero, start processing.
             *
             * First we process all simple data structure = fast
             * Then, we also keep in mind what data types are most common (in WAD and for loading).
             *
             * Remarks:
             * Since c# doesn't support ranges in a switch-case statement,
             * we'll have to do it with slower processing if-then statements.
             *
             */

            if (data.Length > 0)
            {
                //okay, larger the zero -> start processing

                //sky
                if (Rott2DSky.isSkyTexture(data))
                {
                    mkrType = Rott2DMarkerType.mtSky;
                }
                else
                {
                    //pic_t
                    if (Rott2DPic.isPicTexture(data))
                    {
                        mkrType = Rott2DMarkerType.mtPic;
                    }
                    else
                    {
                        //patch (lpic_t)
                        if (Rott2DPatch.isPatchTexture(data))
                        {
                            mkrType = Rott2DMarkerType.mtPatch;
                        }
                        else
                        {
                            //colormap
                            if (Rott2DColormap.isColormap(data))
                            {
                                mkrType = Rott2DMarkerType.mtColormap;
                            }
                            else
                            {
                                //masked
                                if (Rott2DMasked.isMaskedTexture(data))
                                {
                                    mkrType = Rott2DMarkerType.mtMasked;
                                }
                                else
                                {
                                    //transmasked
                                    if (Rott2DTransMasked.isTransMaskedTexture(data))
                                    {
                                        mkrType = Rott2DMarkerType.mtTransMasked;
                                    }
                                    else
                                    {
                                        //flat (moved checking of flat and palette after
                                        //      all header type lumps, to prevent incorrect checking.)
                                        if (Rott2DFlat.isFlatTexture(data))
                                        {
                                            mkrType = Rott2DMarkerType.mtFlat;
                                        }
                                        else
                                        {
                                            //palette
                                            if (Rott2DPalette.isPalette(data))
                                            {
                                                mkrType = Rott2DMarkerType.mtPalette;
                                            }
                                            else
                                            {
                                                //sound (voc data)
                                                if (Rott2DVoc.isSoundLump(data))
                                                {
                                                    mkrType = Rott2DMarkerType.mtSound;
                                                }
                                                else
                                                {
                                                    //music (midi data)
                                                    if (Rott2DMidi.isMidiLump(data))
                                                    {
                                                        mkrType = Rott2DMarkerType.mtMusic;
                                                    } //midi
                                                }     //sound
                                            }         //palette
                                        }             //flat
                                    }                 //trans masked
                                }                     //masked
                            }                         //colormap
                        }                             //patch
                    }                                 //pic
                }                                     //sky
            }                                         //else unknown (unknown = ascii, pcspeaker, fonts, ...)

#if DEBUG
            MessageBox.Show(mkrType.ToString()); //fast dirty DEBUG
#endif

            return(mkrType);
        }