Byte[] fileData;
FileStream fs = new FileStream(fileName, FileMode.Open);//class for files
fileData = new byte[fs.Length];//the number of elemnts of array is the lenght of the file
fs.Read(fileData, 0, fileData.Length);//write the content of the file on the array fileData
fs.Close();
答案 0 :(得分:1)
Image newImage = Image.FromStream(fs);
newImage.Width
newImage.Height
我认为代码非常明显。只需将它放在打开和关闭文件流之间的某处。
编辑:
byte[] fileData = new byte[4];
FileStream fs = new FileStream(fileName, FileMode.Open);
fs.Seek(18, SeekOrigin.Begin);
fs.Read(fileData, 0, 4);
uint width = BitConverter.ToUInt32(fileData, 0);
fs.Read(fileData, 0, 4);
uint height = BitConverter.ToUInt32(fileData, 0);
fs.Close();