public static DdsPixelFormat ReadDdsPixelFormat(Stream inputStream) { DdsPixelFormat result = new DdsPixelFormat(); result.Read(inputStream); return(result); }
private static DdsPixelFormat DdsPfDx(int fourCc) { DdsPixelFormat pixelFormat = new DdsPixelFormat { Size = DefaultSize, Flags = DdsPixelFormatFlag.FourCc, FourCc = fourCc }; return(pixelFormat); }
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); }
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."); }
public static DdsPixelFormat DdsLuminance() { DdsPixelFormat pixelFormat = new DdsPixelFormat { Size = DefaultSize, Flags = DdsPixelFormatFlag.Luminance, RgbBitCount = 8, RBitMask = 0x000000ff }; return(pixelFormat); }
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); }
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); }
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); }
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); }
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."); }
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); }
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; }
public static DdsPixelFormat ReadDdsPixelFormat(Stream inputStream) { DdsPixelFormat result = new DdsPixelFormat(); result.Read(inputStream); return result; }
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; }
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; }
private static DdsPixelFormat DdsPfDx(int fourCc) { DdsPixelFormat pixelFormat = new DdsPixelFormat { Size = DefaultSize, Flags = DdsPixelFormatFlag.FourCc, FourCc = fourCc }; return pixelFormat; }
public static DdsPixelFormat DdsLuminance() { DdsPixelFormat pixelFormat = new DdsPixelFormat { Size = DefaultSize, Flags = DdsPixelFormatFlag.Luminance, RgbBitCount = 8, RBitMask = 0x000000ff }; return pixelFormat; }
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; }
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; }