AoMBrgEditor.DdtFile.GetTexelFormat C# (CSharp) Method

GetTexelFormat() public method

public GetTexelFormat ( ) : string
return string
        public string GetTexelFormat()
        {
            switch (texelFormat)
            {
                case DdtTexelFormat.DXT1:
                    return "DXT1";
                case DdtTexelFormat.DXT3:
                    return "1555";
                case DdtTexelFormat.DXT5:
                    return "4444";
                default:
                    return "";
            }
        }

Usage Example

Beispiel #1
0
 public Dds(DdtFile ddt)
 {
     magic = 0x20534444;
     header.size = 124;
     header.flags |= DDS_HEADER.Flags.DDSD_CAPS | DDS_HEADER.Flags.DDSD_HEIGHT | DDS_HEADER.Flags.DDSD_WIDTH | DDS_HEADER.Flags.DDSD_PIXELFORMAT;
     header.height = (uint)(ddt.Height);
     header.width = (uint)(ddt.Width);
     string texelFormat = ddt.GetTexelFormat();
     switch (texelFormat)
     {
         case "DXT1"://dtx1
             header.flags |= DDS_HEADER.Flags.DDSD_LINEARSIZE;
             header.pitchOrLinearSize = (uint)(Math.Max(1, (ddt.Width + 3) / 4) * 8);
             header.ddspf.flags |= DDS_PIXELFORMAT.Flags.DDPF_FOURCC;
             header.ddspf.fourCC = BitConverter.ToUInt32(Encoding.UTF8.GetBytes(texelFormat), 0);
             break;
         case "DXT2":
         case "DXT3":
         case "DXT4":
         case "DXT5":
             header.flags |= DDS_HEADER.Flags.DDSD_LINEARSIZE;
             header.pitchOrLinearSize = (uint)(Math.Max(1, (ddt.Width + 3) / 4) * 16);
             header.ddspf.flags |= DDS_PIXELFORMAT.Flags.DDPF_FOURCC;
             header.ddspf.fourCC = BitConverter.ToUInt32(Encoding.UTF8.GetBytes(texelFormat), 0);
             break;
         case "1555":
             header.flags |= DDS_HEADER.Flags.DDSD_PITCH;
             header.pitchOrLinearSize = (uint)((ddt.Width * 16 + 7) / 8);
             header.ddspf.flags |= DDS_PIXELFORMAT.Flags.DDPF_RGB | DDS_PIXELFORMAT.Flags.DDPF_ALPHAPIXELS;
             header.ddspf.rGBBitCount = 16;
             header.ddspf.rBitMask = 0x7C00;
             header.ddspf.gBitMask = 0x3E0;
             header.ddspf.bBitMask = 0x1F;
             header.ddspf.aBitMask = 0x8000;
             break;
         case "4444":
             header.flags |= DDS_HEADER.Flags.DDSD_PITCH;
             header.pitchOrLinearSize = (uint)((ddt.Width * 16 + 7) / 8);
             header.ddspf.flags |= DDS_PIXELFORMAT.Flags.DDPF_RGB | DDS_PIXELFORMAT.Flags.DDPF_ALPHAPIXELS;
             header.ddspf.rGBBitCount = 16;
             header.ddspf.rBitMask = 0xF00;
             header.ddspf.gBitMask = 0xF0;
             header.ddspf.bBitMask = 0xF;
             header.ddspf.aBitMask = 0xF000;
             break;
     }
     if (ddt.mipMap > 1)
     {
         header.flags |= DDS_HEADER.Flags.DDSD_MIPMAPCOUNT;
         header.mipMapCount = (uint)(ddt.mipMap + 1);
         header.caps |= DDS_HEADER.Caps.DDSCAPS_MIPMAP | DDS_HEADER.Caps.DDSCAPS_COMPLEX;
     }
     header.reserved1 = new uint[11];
     header.ddspf.size = 32;
     header.caps |= DDS_HEADER.Caps.DDSCAPS_TEXTURE;
     bdata = ddt.imageData;
 }