Пример #1
0
        /// <summary>
        /// Read the content of the DDS header.
        /// </summary>
        /// <param name="reader"></param>
        /// <returns>File is valid</returns>
        public override bool Read(EndianReader reader)
        {
            reader.Format = EndianFormat.LittleEndian;

            var tag  = reader.ReadInt32();
            var size = reader.ReadInt32();

            if (tag != 0x20534444 && size != Size)
            {
                return(false);
            }
            else
            {
                Flags             = (DDSFlags)reader.ReadInt32();
                Height            = reader.ReadInt32();
                Width             = reader.ReadInt32();
                PitchOrLinearSize = reader.ReadInt32();
                Depth             = reader.ReadInt32();
                MipMapCount       = reader.ReadInt32();
                reader.ReadBlock(Reserved1, 0, 0x2C);
                if (!PixelFormat.Read(reader))
                {
                    return(false);
                }
                Caps      = (DDSComplexityFlags)reader.ReadInt32();
                Caps2     = (DDSSurfaceInfoFlags)reader.ReadInt32();
                Caps3     = reader.ReadInt32();
                Caps4     = reader.ReadInt32();
                Reserved2 = reader.ReadInt32();

                // Add more verifications here

                return(true);
            }
        }
Пример #2
0
        private void CreateHeaderCubemap(int mipMapCount, BitmapFormat format, BitmapFlags flags)
        {
            Caps  |= DDSComplexityFlags.Complex;
            Caps2 |= DDSSurfaceInfoFlags.CubeMapAllFaces;

            SetTextureFormat(mipMapCount, format, flags);
        }
Пример #3
0
 private void CreateHeaderVolume(int mipMapCount, int depth, BitmapFormat format, BitmapFlags flags)
 {
     Flags |= DDSFlags.Depth;
     Caps  |= DDSComplexityFlags.Complex;
     Caps2 |= DDSSurfaceInfoFlags.Volume;
     Depth  = depth;
     SetTextureFormat(mipMapCount, format, flags);
 }
Пример #4
0
        private void CreateHeaderTexture2D(int mipMapCount, BitmapFormat format, BitmapFlags flags)
        {
            Depth = 0;

            if (mipMapCount > 0)
            {
                MipMapCount = 1 + mipMapCount;
                Flags      |= DDSFlags.MipMapCount;
                Caps       |= DDSComplexityFlags.MipMap | DDSComplexityFlags.Complex;
            }
            else
            {
                MipMapCount = 0;
            }

            SetTextureFormat(mipMapCount, format, flags);
        }