?
Solved

Read BITMAPINFOHEADER and get width and height of the image

Posted on 2006-04-25
2
Medium Priority
?
773 Views
Last Modified: 2008-01-09
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

0
Comment
Question by:dcave555
2 Comments
 
LVL 2

Accepted Solution

by:
OfficeLineman earned 2000 total points
ID: 16539511
Suggest setting your first seek to 18, instead of 16.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16540290
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
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Loops Section Overview
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question