[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Bitmap files

Posted on 1998-05-24
6
Medium Priority
?
182 Views
Last Modified: 2012-05-04
How can i read each pixel of a Bitmap file, please give me some code?
0
Comment
Question by:bolso
  • 6
6 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1164680
In what language?
0
 
LVL 22

Expert Comment

by:nietod
ID: 1164681
Probably C++, right?  (I'm not totally stupid.  I thought this was the window section.)
0
 
LVL 22

Accepted Solution

by:
nietod earned 200 total points
ID: 1164682
answer coming.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 22

Expert Comment

by:nietod
ID: 1164683
What I would do is load the bitmap from the file using LoadImage().  Then you don't have to "parse" the information in the file  (which can be done if you are interested in doing it that way.)

To load the image you would do.

HBITMAP ImgHnd = LoadImage(NULL,"c:\path\filename.bmp",IMAGE_BITMAP,0,0,LR_DEFAULTSIZE | LR_LOADFROMFILE);

This loads the image as a screen compatible bitmap.  I'm assuming that is what you want.  If you don't want it screen compatible it can be used to load a DIB bitmap.  

continues.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1164684
To read the pixels, you need to select the bitmap into a compatible device context.  To do that you would do

HDC DCHnd = CreateDC("DISPLAY",NULL,NULL,NULL);
HDC DCMem = CreateCompativleDC(DCHnd);

DeleteDC(DCHnd);

HBITMAP OldBitMap = SelectObject(DCMem,ImgHnd);// Select in image loaded from LoadImage().

// now use GetPixel() to get the pixels, like
COLOREF Color = GetPixel(DCMem,1,1);

DeleteDC(DCMem);

I hope this helps.  Ask if you have questions.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1164685
I have to go, but If you want to quickly get the pixel information in an array.  You can load the image as a DIB bitmap by specifying LR_CREATEDIBSECTION in the LoadImage() and then use GetDIBits() to get all the pixels at once.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

829 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