public void Save(ref BinaryWriter output, ref BitmapGroup.BitmapBlock image) { Header head = new Header(); head.Generate(ref image); head.Save(ref output); }
public void Generate(ref BitmapGroup.BitmapBlock image) { caps1 = caps1 + (short)DDSEnum.DDSCAPS_TEXTURE; if (image.NumMipmaps > 0) { caps1 = caps1 + (int)DDSEnum.DDSCAPS_MIPMAP; } caps1 = caps1 + (short)DDSEnum.DDSCAPS_COMPLEX; caps2 = 0; Reserved = new int[2]; Reserved[0] = 0; Reserved[1] = 0; }
public void Generate(ref BitmapGroup.BitmapBlock image) { size = 32; Flags = 0; if (image.Format == BitmapGroup.BitmapDataFormat.Dxt1) { FourCC = "DXT1"; Flags += (short)DDSEnum.DDPF_FOURCC; } else if (image.Format == BitmapGroup.BitmapDataFormat.Dxt2) { FourCC = "DXT3"; Flags += (short)DDSEnum.DDPF_FOURCC; } else if (image.Format == BitmapGroup.BitmapDataFormat.Dxt4) { FourCC = "DXT4"; Flags += (short)DDSEnum.DDPF_FOURCC; } else { FourCC = "\0\0\0\0"; Flags += (short)DDSEnum.DDPF_RGB; } if (image.Format == BitmapGroup.BitmapDataFormat.R5G6B5) { RGBBitCount = 16; } else if (image.Format == BitmapGroup.BitmapDataFormat.A1R5G5B5) { RGBBitCount = 16; Flags += (short)DDSEnum.DDPF_ALPHAPIXELS; } else if (image.Format == BitmapGroup.BitmapDataFormat.A4R4G4B4) { RGBBitCount = 16; Flags += (short)DDSEnum.DDPF_ALPHAPIXELS; } else if (image.Format == BitmapGroup.BitmapDataFormat.X8R8G8B8) { RGBBitCount = 32; Flags += (short)DDSEnum.DDPF_ALPHAPIXELS; } else if (image.Format == BitmapGroup.BitmapDataFormat.A8R8G8B8) { RGBBitCount = 32; Flags += (short)DDSEnum.DDPF_ALPHAPIXELS; } else { RGBBitCount = 0; } if (image.Format == BitmapGroup.BitmapDataFormat.R5G6B5) { RBitMask = 63488; GBitMask = 2016; BBitMask = 31; RGBAlphaBitMask = 0; } else if (image.Format == BitmapGroup.BitmapDataFormat.A1R5G5B5) { RBitMask = 31744; GBitMask = 992; BBitMask = 31; RGBAlphaBitMask = 32768; } else if (image.Format == BitmapGroup.BitmapDataFormat.A4R4G4B4) { RBitMask = 61440; GBitMask = 240; BBitMask = 15; RGBAlphaBitMask = 15728640; } else if (image.Format == BitmapGroup.BitmapDataFormat.X8R8G8B8) { RBitMask = 1044480; GBitMask = 65280; BBitMask = 255; RGBAlphaBitMask = (int)278190080; } else if (image.Format == BitmapGroup.BitmapDataFormat.A8R8G8B8) { RBitMask = 16711680; GBitMask = 65280; BBitMask = 255; //RGBAlphaBitMask = (int)4278190080; } else { RBitMask = 0; GBitMask = 0; BBitMask = 0; RGBAlphaBitMask = 0; } }
public void Generate(ref BitmapGroup.BitmapBlock image) { size_of_structure = 124; Flags += (int)DDSEnum.DDSD_CAPS; Flags += (int)DDSEnum.DDSD_PIXELFORMAT; Flags += (int)DDSEnum.DDSD_WIDTH; Flags += (int)DDSEnum.DDSD_HEIGHT; if (image.Format == BitmapGroup.BitmapDataFormat.Dxt1 || image.Format == BitmapGroup.BitmapDataFormat.Dxt2 || image.Format == BitmapGroup.BitmapDataFormat.Dxt4) { Flags += (int)DDSEnum.DDSD_LINEARSIZE; } else { Flags += (short)DDSEnum.DDSD_PITCH; } Height = image.Height; Width = image.Width; int RGBBitCount = 0; if (image.Format == BitmapGroup.BitmapDataFormat.R5G6B5) { RGBBitCount = 16; } else if (image.Format == BitmapGroup.BitmapDataFormat.A1R5G5B5) { RGBBitCount = 16; } else if (image.Format == BitmapGroup.BitmapDataFormat.A4R4G4B4) { RGBBitCount = 16; } else if (image.Format == BitmapGroup.BitmapDataFormat.X8R8G8B8) { RGBBitCount = 32; } else if (image.Format == BitmapGroup.BitmapDataFormat.A8R8G8B8) { RGBBitCount = 32; } if (((short)image.Flags & (short)DDSEnum.DDSD_PITCH) > 0) { PitchOrLinearSize = image.Width * (RGBBitCount / 8); } if (((short)image.Flags & (int)DDSEnum.DDSD_LINEARSIZE) > 0) { PitchOrLinearSize = image.BitmapSize(); } Depth = 0; MipMapCount = image.NumMipmaps; if (MipMapCount > 0) { Flags += (int)DDSEnum.DDSD_MIPMAPCOUNT; } Reserved1 = new int[11]; Reserved1[0] = 0; Reserved1[1] = 0; Reserved1[2] = 0; Reserved1[3] = 0; Reserved1[4] = 0; Reserved1[5] = 0; Reserved1[6] = 0; Reserved1[7] = 0; Reserved1[8] = 0; Reserved1[9] = 0; Reserved1[10] = 0; ddfPixelFormat.Generate(ref image); ddsCaps.Generate(ref image); }
public void Generate(ref BitmapGroup.BitmapBlock image) { ddsd.Generate(ref image); }