Esempio n. 1
0
        public static DdsPixelFormat ReadDdsPixelFormat(Stream inputStream)
        {
            DdsPixelFormat result = new DdsPixelFormat();

            result.Read(inputStream);
            return(result);
        }
Esempio n. 2
0
        private static DdsPixelFormat DdsPfDx(int fourCc)
        {
            DdsPixelFormat pixelFormat = new DdsPixelFormat
            {
                Size   = DefaultSize,
                Flags  = DdsPixelFormatFlag.FourCc,
                FourCc = fourCc
            };

            return(pixelFormat);
        }
Esempio n. 3
0
 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);
 }
Esempio n. 4
0
 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.");
 }
Esempio n. 5
0
        public static DdsPixelFormat DdsLuminance()
        {
            DdsPixelFormat pixelFormat = new DdsPixelFormat
            {
                Size        = DefaultSize,
                Flags       = DdsPixelFormatFlag.Luminance,
                RgbBitCount = 8,
                RBitMask    = 0x000000ff
            };

            return(pixelFormat);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
 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);
 }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
 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.");
 }
Esempio n. 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);
        }
Esempio n. 12
0
 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;
 }
Esempio n. 13
0
 public static DdsPixelFormat ReadDdsPixelFormat(Stream inputStream)
 {
     DdsPixelFormat result = new DdsPixelFormat();
     result.Read(inputStream);
     return result;
 }
Esempio n. 14
0
 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;
 }
Esempio n. 15
0
 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;
 }
Esempio n. 16
0
 private static DdsPixelFormat DdsPfDx(int fourCc)
 {
     DdsPixelFormat pixelFormat = new DdsPixelFormat
     {
         Size = DefaultSize,
         Flags = DdsPixelFormatFlag.FourCc,
         FourCc = fourCc
     };
     return pixelFormat;
 }
Esempio n. 17
0
 public static DdsPixelFormat DdsLuminance()
 {
     DdsPixelFormat pixelFormat = new DdsPixelFormat
     {
         Size = DefaultSize,
         Flags = DdsPixelFormatFlag.Luminance,
         RgbBitCount = 8,
         RBitMask = 0x000000ff
     };
     return pixelFormat;
 }
Esempio n. 18
0
 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;
 }
Esempio n. 19
0
 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;
 }