示例#1
0
        protected virtual DDS.Header BuildDDSHeader(Texture texture)
        {
            if (texture.CompressionType == P8Compression)
            {
                throw new ArgumentException("P8 is not supported!");
            }

            var header = new DDS.Header
            {
                Size        = 124,
                Flags       = 0x21007,
                Height      = (uint)texture.Height,
                Width       = (uint)texture.Width,
                MipMapCount = 0,
            };

            var pixelFormat = new DDS.PixelFormat
            {
                Size = 32
            };

            if (texture.CompressionType == 0x00000015)
            {
                pixelFormat.Flags       = 0x41;
                pixelFormat.RGBBitCount = 0x20;
                pixelFormat.RBitMask    = 0xFF0000;
                pixelFormat.GBitMask    = 0xFF00;
                pixelFormat.BBitMask    = 0xFF;
                pixelFormat.ABitMask    = 0xFF000000;

                header.Caps = 0x40100A;
            }
            else
            {
                pixelFormat.Flags  = 4;
                pixelFormat.FourCC = texture.CompressionType;
                header.Caps        = 0x401008;
            }

            header.PixelFormat = pixelFormat;

            return(header);
        }
示例#2
0
 protected virtual void OutputTexture(Texture texture, DDS.Header header, BinaryWriter writer)
 {
     writer.Write(0x20534444);
     BinaryUtil.WriteStruct(writer, header);
     writer.Write(texture.Data);
 }