Read BITMAPINFOHEADER and get width and height of the image

Hello

i wrote some code :

            FileStream fs = File.OpenRead(@"c:\Zapotec.bmp");
            BinaryReader breader = new BinaryReader(fs);
            breader.BaseStream.Seek(16,SeekOrigin.Begin);
            Int32 width = breader.ReadInt32();
            Int32 height = breader.ReadInt32();
            breader.BaseStream.Seek(2,SeekOrigin.Current);
            Int16 biBitCount = breader.ReadInt16();
           

            fs.Close();
            breader.Close();

but i am getting very large number in width  and in height
please help me to get the right size.
becouse if i am loading this image for example:
Bitmap bmp = new Bitmap(@"c:\Zapotec.bmp");
bmp.width  and bmp.height  much smoller.

please help me
i need only this 2 parameters and we are working with very big images so we can't load image we need only to get this 2 parameters.

thx

dcave555Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

OfficeLinemanCommented:
Suggest setting your first seek to 18, instead of 16.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bob LearnedCommented:
Is there a reason that you are doing it that way, instead of this way:

Bitmap bmp = new Bitmap(@"c:\windows\zapotec.bmp");
int height = bmp.Height;
int width = bmp.Width;

Bob
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.