コード例 #1
0
ファイル: DdsPixelFormat.cs プロジェクト: shdwdln/FtexTool
        public static DdsPixelFormat ReadDdsPixelFormat(Stream inputStream)
        {
            DdsPixelFormat result = new DdsPixelFormat();

            result.Read(inputStream);
            return(result);
        }
コード例 #2
0
ファイル: DdsPixelFormat.cs プロジェクト: shdwdln/FtexTool
        private static DdsPixelFormat DdsPfDx(int fourCc)
        {
            DdsPixelFormat pixelFormat = new DdsPixelFormat
            {
                Size   = DefaultSize,
                Flags  = DdsPixelFormatFlag.FourCc,
                FourCc = fourCc
            };

            return(pixelFormat);
        }
コード例 #3
0
ファイル: DdsPixelFormat.cs プロジェクト: shdwdln/FtexTool
 protected bool Equals(DdsPixelFormat other)
 {
     return(Size == other.Size &&
            Flags == other.Flags &&
            FourCc == other.FourCc &&
            RgbBitCount == other.RgbBitCount &&
            RBitMask == other.RBitMask &&
            GBitMask == other.GBitMask &&
            BBitMask == other.BBitMask &&
            ABitMask == other.ABitMask);
 }
コード例 #4
0
ファイル: DdsPixelFormat.cs プロジェクト: kkkkyue/FtexTool
 public static int CalculateImageSize(DdsPixelFormat pixelFormat, int width, int height)
 {
     if (pixelFormat.RgbBitCount > 0)
         return (width*height*pixelFormat.RgbBitCount)/8;
     if (pixelFormat.Equals(DdsPfDxt1()))
         return ((width*height*32)/8)/8;
     if (pixelFormat.Equals(DdsPfDxt3()))
         return ((width*height*32)/4)/8;
     if (pixelFormat.Equals(DdsPfDxt5()))
         return ((width*height*32)/4)/8;
     throw new NotImplementedException("Could not calculate the image size of the current pixel format.");
 }
コード例 #5
0
ファイル: DdsPixelFormat.cs プロジェクト: shdwdln/FtexTool
        public static DdsPixelFormat DdsLuminance()
        {
            DdsPixelFormat pixelFormat = new DdsPixelFormat
            {
                Size        = DefaultSize,
                Flags       = DdsPixelFormatFlag.Luminance,
                RgbBitCount = 8,
                RBitMask    = 0x000000ff
            };

            return(pixelFormat);
        }
コード例 #6
0
ファイル: DdsPixelFormat.cs プロジェクト: shdwdln/FtexTool
        public static DdsPixelFormat DdsPfR8G8B8()
        {
            DdsPixelFormat pixelFormat = new DdsPixelFormat
            {
                Size        = DefaultSize,
                Flags       = DdsPixelFormatFlag.Rgb,
                FourCc      = 0,
                RgbBitCount = 24,
                RBitMask    = 0x00ff0000,
                GBitMask    = 0x0000ff00,
                BBitMask    = 0x000000ff,
                ABitMask    = 0x00000000
            };

            return(pixelFormat);
        }
コード例 #7
0
ファイル: DdsPixelFormat.cs プロジェクト: shdwdln/FtexTool
        public static DdsPixelFormat DdsPfR5G6B5()
        {
            DdsPixelFormat pixelFormat = new DdsPixelFormat
            {
                Size        = DefaultSize,
                Flags       = DdsPixelFormatFlag.Rgb,
                FourCc      = 0,
                RgbBitCount = 16,
                RBitMask    = 0x0000f800,
                GBitMask    = 0x000007e0,
                BBitMask    = 0x0000001f,
                ABitMask    = 0x00000000
            };

            return(pixelFormat);
        }
コード例 #8
0
ファイル: DdsPixelFormat.cs プロジェクト: shdwdln/FtexTool
 public static int GetMinimumImageSize(DdsPixelFormat pixelFormat)
 {
     if (pixelFormat.Equals(DdsPfDxt1()))
     {
         return(8);
     }
     if (pixelFormat.Equals(DdsPfDxt3()))
     {
         return(16);
     }
     if (pixelFormat.Equals(DdsPfDxt5()))
     {
         return(16);
     }
     return(4);
 }
コード例 #9
0
ファイル: DdsPixelFormat.cs プロジェクト: shdwdln/FtexTool
        public static DdsPixelFormat DdsPfA4R4G4B4()
        {
            DdsPixelFormat pixelFormat = new DdsPixelFormat
            {
                Size        = DefaultSize,
                Flags       = DdsPixelFormatFlag.Rgba,
                FourCc      = 0,
                RgbBitCount = 16,
                RBitMask    = 0x00000f00,
                GBitMask    = 0x000000f0,
                BBitMask    = 0x0000000f,
                ABitMask    = 0x0000f000
            };

            return(pixelFormat);
        }
コード例 #10
0
ファイル: DdsPixelFormat.cs プロジェクト: shdwdln/FtexTool
 public static int CalculateImageSize(DdsPixelFormat pixelFormat, int width, int height, int depth)
 {
     if (pixelFormat.RgbBitCount > 0)
     {
         return((int)((long)width * height * depth * pixelFormat.RgbBitCount / 8));
     }
     if (pixelFormat.Equals(DdsPfDxt1()))
     {
         return((int)((long)width * height * depth) / 2); // ((width*height*32)/8)/8;
     }
     if (pixelFormat.Equals(DdsPfDxt3()))
     {
         return(width * height * depth);  // ((width*height*32)/4)/8;
     }
     if (pixelFormat.Equals(DdsPfDxt5()))
     {
         return(width * height * depth);  // ((width*height*32)/4)/8;
     }
     throw new ArgumentException("Could not calculate the image size of the current pixel format.");
 }
コード例 #11
0
        public static DdsFileHeader Read(Stream inputStream)
        {
            DdsFileHeader result = new DdsFileHeader();
            BinaryReader  reader = new BinaryReader(inputStream, Encoding.Default, true);

            result.Size              = reader.ReadInt32();
            result.Flags             = (DdsFileHeaderFlags)reader.ReadInt32();
            result.Height            = reader.ReadInt32();
            result.Width             = reader.ReadInt32();
            result.PitchOrLinearSize = reader.ReadInt32();
            result.Depth             = reader.ReadInt32();
            result.MipMapCount       = reader.ReadInt32();
            // int Reserved1[11];
            reader.Skip(44);
            result.PixelFormat = DdsPixelFormat.ReadDdsPixelFormat(inputStream);
            result.Caps        = (DdsSurfaceFlags)reader.ReadInt32();
            result.Caps2       = (DdsCubemap)reader.ReadInt32();
            result.Caps3       = reader.ReadInt32();
            result.Caps4       = reader.ReadInt32();
            // int Reserved2;
            reader.Skip(4);
            return(result);
        }
コード例 #12
0
ファイル: DdsPixelFormat.cs プロジェクト: kkkkyue/FtexTool
 public static DdsPixelFormat DdsPfA4R4G4B4()
 {
     DdsPixelFormat pixelFormat = new DdsPixelFormat
     {
         Size = DefaultSize,
         Flags = DdsPixelFormatFlag.Rgba,
         FourCc = 0,
         RgbBitCount = 16,
         RBitMask = 0x00000f00,
         GBitMask = 0x000000f0,
         BBitMask = 0x0000000f,
         ABitMask = 0x0000f000
     };
     return pixelFormat;
 }
コード例 #13
0
ファイル: DdsPixelFormat.cs プロジェクト: kkkkyue/FtexTool
 public static DdsPixelFormat ReadDdsPixelFormat(Stream inputStream)
 {
     DdsPixelFormat result = new DdsPixelFormat();
     result.Read(inputStream);
     return result;
 }
コード例 #14
0
ファイル: DdsPixelFormat.cs プロジェクト: kkkkyue/FtexTool
 public static int GetMinimumImageSize(DdsPixelFormat pixelFormat)
 {
     if (pixelFormat.Equals(DdsPfDxt1()))
         return 8;
     if (pixelFormat.Equals(DdsPfDxt3()))
         return 16;
     if (pixelFormat.Equals(DdsPfDxt5()))
         return 16;
     return 4;
 }
コード例 #15
0
ファイル: DdsPixelFormat.cs プロジェクト: kkkkyue/FtexTool
 protected bool Equals(DdsPixelFormat other)
 {
     return Size == other.Size &&
            Flags == other.Flags &&
            FourCc == other.FourCc &&
            RgbBitCount == other.RgbBitCount &&
            RBitMask == other.RBitMask &&
            GBitMask == other.GBitMask &&
            BBitMask == other.BBitMask &&
            ABitMask == other.ABitMask;
 }
コード例 #16
0
ファイル: DdsPixelFormat.cs プロジェクト: kkkkyue/FtexTool
 private static DdsPixelFormat DdsPfDx(int fourCc)
 {
     DdsPixelFormat pixelFormat = new DdsPixelFormat
     {
         Size = DefaultSize,
         Flags = DdsPixelFormatFlag.FourCc,
         FourCc = fourCc
     };
     return pixelFormat;
 }
コード例 #17
0
ファイル: DdsPixelFormat.cs プロジェクト: kkkkyue/FtexTool
 public static DdsPixelFormat DdsLuminance()
 {
     DdsPixelFormat pixelFormat = new DdsPixelFormat
     {
         Size = DefaultSize,
         Flags = DdsPixelFormatFlag.Luminance,
         RgbBitCount = 8,
         RBitMask = 0x000000ff
     };
     return pixelFormat;
 }
コード例 #18
0
ファイル: DdsPixelFormat.cs プロジェクト: kkkkyue/FtexTool
 public static DdsPixelFormat DdsPfA1R5G5B5()
 {
     DdsPixelFormat pixelFormat = new DdsPixelFormat
     {
         Size = DefaultSize,
         Flags = DdsPixelFormatFlag.Rgba,
         FourCc = 0,
         RgbBitCount = 16,
         RBitMask = 0x00007c00,
         GBitMask = 0x000003e0,
         BBitMask = 0x0000001f,
         ABitMask = 0x00008000
     };
     return pixelFormat;
 }
コード例 #19
0
ファイル: DdsPixelFormat.cs プロジェクト: kkkkyue/FtexTool
 public static DdsPixelFormat DdsPfR8G8B8()
 {
     DdsPixelFormat pixelFormat = new DdsPixelFormat
     {
         Size = DefaultSize,
         Flags = DdsPixelFormatFlag.Rgb,
         FourCc = 0,
         RgbBitCount = 24,
         RBitMask = 0x00ff0000,
         GBitMask = 0x0000ff00,
         BBitMask = 0x000000ff,
         ABitMask = 0x00000000
     };
     return pixelFormat;
 }