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(); }
/// <summary> /// Figure if we have a small picture (pic_t; GUI overlay textures) /// </summary> public static bool isPicTexture(byte[] lumpdata) { /* * small picture header is 2 bytes * the actual header structure only contains width and height in byte (= 2 bytes) * * on a key image (8x16 in size) are the first foud bytes always: * x * 4 ==> width. You have to multiply by four. (value * 4) * y ==> Height * * A second paramter to check for are the two trailing bytes. * These two trailing bytes are a left over from Doom alpha versions. * */ bool isPic = false; if (lumpdata.Length > Rott2DPicHeader.PIC_HEADER_SIZE) { //PIC_UPPER_PLANE_BOUNDS is 80, reason: //80 * 4 = 320. This is the largest pic format found in ROTT wad files. //so this explains why upper plane bounds size is set to be 80. Rott2DPicHeader header = new Rott2DPicHeader(); header.PicPlaneSize = lumpdata[0]; //plane size header.PicHeight = lumpdata[1]; //read height as byte byte trailing1 = lumpdata[lumpdata.Length - 2]; //trailing bytes byte trailing2 = lumpdata[lumpdata.Length - 1]; if (((((header.PicWidth * header.PicHeight) + (Rott2DPicHeader.PIC_HEADER_SIZE + Rott2DPicHeader.PIC_TRAIL_SIZE)) == lumpdata.Length)) && (header.PicPlaneSize <= Rott2DPicHeader.PIC_UPPER_PLANE_BOUNDS)) { if ((trailing1 == 0) && (trailing2 == 0)) { isPic = true; } } } return(isPic); }