Приветствую всех!
В общем-то суть: необходимо считать файл формата bmp вручную в объекты след. классов:
public class BITMAPFILEHEADER
{
public UInt16 bfType { get; set; }
public UInt32 bfSize { get; set; }
public UInt16 bfReserved1 { get; set; }
public UInt16 bfReserved2 { get; set; }
public UInt32 bfOffBits { get; set; }
}
public class BITMAPINFOHEADER
{
public UInt32 biSize { get; set; }
public UInt32 biWidth { get; set; }
public UInt32 biHeight { get; set; }
public UInt16 biPlanes { get; set; }
public UInt16 biBitCount { get; set; }
public UInt32 biCompression { get; set; }
public UInt32 biSizeImage { get; set; }
public UInt32 biXPelsMeter { get; set; }
public UInt32 biYPelsMeter { get; set; }
public UInt32 biClrUsed { get; set; }
public UInt32 biClrImportant { get; set; }
}
public class RGBTriplet
{
public byte red { get; set; }
public byte green { get; set; }
public byte blue { get; set; }
}
и оставшуюся часть файла в массив byte[].
Собственно проблема: как это сделать?
Пытался использовать BinaryReader:
var fs = new FileStream(@"D:\1.bmp", FileMode.Open, FileAccess.Read);
var br = new BinaryReader(fs);
var image = new BitmapImage();
image.BFH.bfType = br.ReadUInt16();
image.BFH.bfSize = br.ReadUInt32();
// и так далее по полям
но выкидывает exception на image.BFH.bfType = br.ReadUInt16();
Может кто-нибудь что-нибудь посоветовать по сути?