大家好 我正在尝试获取bmp文件,然后显示它,我应该通过获取bmp的头信息并将其逐像素加载到数组中然后设置像素以显示bmp图片而不使用位图类。
enter code here
enter code here public void display(String filename)
{
FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
string headerCode = br.ReadChar().ToString() + br.ReadChar().ToString();
MessageBox.Show(headerCode);
if (headerCode == "BM")
{
int bfSize = br.ReadInt32();
int bfReserved1 = br.ReadInt16();
int bfReserved2 = br.ReadInt16();
int bfoffbits = br.ReadInt32();
int biSize = br.ReadInt32();
int biWidth = br.ReadInt32();
int biHeight = br.ReadInt32();
int biPlanes = br.ReadInt16();
int biBitCount = br.ReadInt16();
int biCompression = br.ReadInt32();
int biSizeImage = br.ReadInt32();
int biXPelsPerMeter = br.ReadInt32();
int biYPelsPerMeter = br.ReadInt32();
int biClrUsed = br.ReadInt32();
int biClrImportant = br.ReadInt32();
int rgbRed = 0;
int rgbGreen = 0;
int rgbBlue = 0;
Bitmap bmp = new Bitmap(biWidth, biHeight);
PictureBox1.Size = new System.Drawing.Size(biWidth, biHeight);
try
{
PictureBox1.Image = bmp;
我应该这样做,但没有位图类和缓冲区,应该获取bmp文件的标题并将其加载到数组中然后读取文件以获取高度和宽度以及其他需要按像素显示bmp像素的信息但不使用位图类
答案 0 :(得分:-2)
我会将位图加载到c#中,然后将其转换为jpg / png等等.Bmp对于网络来说并不好,因为它们是大的。