コード例 #1
0
 private void Read_DDS_PIXELFORMAT(DDS_PIXELFORMAT p, BinaryReader r)
 {
     p.dwSize        = r.ReadUInt32();
     p.dwFlags       = r.ReadUInt32();
     p.dwFourCC      = r.ReadUInt32();
     p.dwRGBBitCount = r.ReadUInt32();
     p.dwRBitMask    = r.ReadUInt32();
     p.dwGBitMask    = r.ReadUInt32();
     p.dwBBitMask    = r.ReadUInt32();
     p.dwABitMask    = r.ReadUInt32();
 }
コード例 #2
0
        private void Write_DDS_PIXELFORMAT(DDSFormat p, Stream s)
        {
            DDS_PIXELFORMAT fmt = getDDSPixelFormat(p);

            s.WriteInt32(DDS_PIXELFORMAT_size);
            s.WriteUInt32(fmt.dwFlags);
            s.WriteUInt32(fmt.dwFourCC);
            s.WriteUInt32(fmt.dwRGBBitCount);
            s.WriteUInt32(fmt.dwRBitMask);
            s.WriteUInt32(fmt.dwGBitMask);
            s.WriteUInt32(fmt.dwBBitMask);
            s.WriteUInt32(fmt.dwABitMask);
        }
コード例 #3
0
        private DDS_PIXELFORMAT getDDSPixelFormat(DDSFormat format)
        {
            DDS_PIXELFORMAT pixelFormat = new DDS_PIXELFORMAT();

            switch (format)
            {
            case DDSFormat.DXT1:
                pixelFormat.dwFlags  = DDPF_FOURCC;
                pixelFormat.dwFourCC = FOURCC_DXT1;
                break;

            case DDSFormat.DXT3:
                pixelFormat.dwFlags  = DDPF_FOURCC;
                pixelFormat.dwFourCC = FOURCC_DXT3;
                break;

            case DDSFormat.DXT5:
                pixelFormat.dwFlags  = DDPF_FOURCC;
                pixelFormat.dwFourCC = FOURCC_DXT5;
                break;

            case DDSFormat.ATI2:
                pixelFormat.dwFlags  = DDPF_FOURCC;
                pixelFormat.dwFourCC = FOURCC_ATI2;
                break;

            case DDSFormat.V8U8:
                pixelFormat.dwFlags       = 0x80000;
                pixelFormat.dwRGBBitCount = 0x10;
                pixelFormat.dwRBitMask    = 0xFF;
                pixelFormat.dwGBitMask    = 0xFF00;
                pixelFormat.dwBBitMask    = 0x00;
                pixelFormat.dwABitMask    = 0x00;
                break;

            case DDSFormat.G8:
                pixelFormat.dwFlags       = DDPF_LUMINANCE;
                pixelFormat.dwRGBBitCount = 0x08;
                pixelFormat.dwRBitMask    = 0xFF;
                pixelFormat.dwGBitMask    = 0x00;
                pixelFormat.dwBBitMask    = 0x00;
                pixelFormat.dwABitMask    = 0x00;
                break;

            case DDSFormat.ARGB:
                pixelFormat.dwFlags       = DDPF_ALPHAPIXELS | DDPF_RGB;
                pixelFormat.dwRGBBitCount = 0x20;
                pixelFormat.dwRBitMask    = 0xFF0000;
                pixelFormat.dwGBitMask    = 0xFF00;
                pixelFormat.dwBBitMask    = 0xFF;
                pixelFormat.dwABitMask    = 0xFF000000;
                break;

            case DDSFormat.RGB:
                pixelFormat.dwFlags       = DDPF_RGB;
                pixelFormat.dwRGBBitCount = 0x18;
                pixelFormat.dwRBitMask    = 0xFF0000;
                pixelFormat.dwGBitMask    = 0xFF00;
                pixelFormat.dwBBitMask    = 0xFF;
                pixelFormat.dwABitMask    = 0x00;
                break;

            default:
                throw new Exception("invalid texture format " + ddsFormat);
            }
            return(pixelFormat);
        }
コード例 #4
0
ファイル: DDSImage.cs プロジェクト: ME3Explorer/ME3Explorer
 private void Read_DDS_PIXELFORMAT(DDS_PIXELFORMAT p, BinaryReader r)
 {
     p.dwSize = r.ReadInt32();
     p.dwFlags = r.ReadInt32();
     p.dwFourCC = r.ReadInt32();
     p.dwRGBBitCount = r.ReadInt32();
     p.dwRBitMask = r.ReadInt32();
     p.dwGBitMask = r.ReadInt32();
     p.dwBBitMask = r.ReadInt32();
     p.dwABitMask = r.ReadInt32();
 }