Esempio n. 1
0
        public byte[] Get()
        {
            byte[] returned = null;

            using (MemoryStream MS = new MemoryStream())
                using (BinaryWriter writer = new BinaryWriter(MS))
                {
                    writer.Write(Size);
                    writer.Write(Utilities.Utilities.WriteFlags(Flags));
                    writer.Write(Height);
                    writer.Write(Width);
                    writer.Write(PitchOrLinearSize);
                    writer.Write(Depth);
                    writer.Write(MipMapCount);
                    writer.WriteInt32Array(Reserved);
                    writer.Write(DDSPixelFormat.Get());
                    writer.Write(Utilities.Utilities.WriteFlags(Caps));
                    writer.Write(Utilities.Utilities.WriteFlags(Caps2));
                    writer.WriteInt32Array(Reserved2);

                    returned = MS.ToArray();
                }

            return(returned);
        }
Esempio n. 2
0
        public DDSHeader(BinaryReader reader)
        {
            if (reader.ReadInt32() != Size)
            {
                throw new Exception("DDSHeader: wrong header size");
            }

            Utilities.Utilities.ReadFlags(Flags, reader.ReadInt32(), typeof(HeaderFlags));
            Height            = reader.ReadInt32();
            Width             = reader.ReadInt32();
            PitchOrLinearSize = reader.ReadInt32();
            Depth             = reader.ReadInt32();
            MipMapCount       = reader.ReadInt32();
            Reserved          = reader.ReadInt32Array(11);
            DDSPixelFormat    = new DDSPixelFormat(reader);
            Utilities.Utilities.ReadFlags(Caps, reader.ReadInt32(), typeof(HeaderCaps));
            Utilities.Utilities.ReadFlags(Caps2, reader.ReadInt32(), typeof(HeaderCaps2));
            Reserved2 = reader.ReadInt32Array(3);
        }