Jel moguce da niko nije to napravio za NET (ili ja nisam mogao da nadjem).
Evo nakucao sam ti klasu za dobijanje dimenzija bitmape (bas za bmp). Treba ocitati 3 inta (bukvalno)
Ako ubacim jos neki format (npr. jpg) okacicu ...
Reference
http://www.fastgraph.com/help/bmp_header_format.html za bmp
Ova je za jpg
http://www.obrador.com/essentialjpeg/headerinfo.htm
Code:
//Autor Nebojsa
class ImageDimensions
{
private string fileName;
private int X, Y;
public ImageDimensions(string FileName)
{
this.fileName = FileName;
UInt16 signature;
if(File.Exists(fileName))
{
BinaryReader binReader = new BinaryReader(File.Open(fileName, FileMode.Open));
try
{
signature = binReader.ReadUInt16();
//formati
if (signature == 0x4D42)//bmp
{
binReader.ReadBytes(16);
this.X = binReader.ReadInt32();
this.Y = binReader.ReadInt32();
}
//jpg
}
catch (EndOfStreamException e)
{
this.X = 0;
this.Y = 0;
}
finally
{
binReader.Close();
}
}
}
public int GetWidth()
{
return this.X;
}
public int GetHeight()
{
return this.Y;
}
}
Code:
ImageDimensions id = new ImageDimensions("C:\\bmp.bmp");
int x=id.GetWidth();
int y=id.GetHeight();
string str = x + "x" + y;
MessageBox.Show(str);