Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Reading pixel values using C++

Posted on 1997-10-14
2
Medium Priority
?
999 Views
Last Modified: 2008-03-03
I'am currently doing a project on data compression using C++. I need to open an image file and read the pixel values.  
Is there an equivalent of the getpixel command of C in C++?
Hope to hear from someone out there soon. Thanks in advance.
0
Comment
Question by:dnair
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1171334
an easy (though innefficient) method would be to create a memorydevice context and load it with the image.  then use getpixel.

Alternately, you can parse the image file if you know its format.  The windows bitmap formats are documented and not too hard to parse.  A Windows META file would be almost impossible to parse, specially in this context.  

I can provide more specifics on either technique.
0
 
LVL 10

Accepted Solution

by:
RONSLOW earned 100 total points
ID: 1171335
You can load an image from an external file with LoadImage (under win95 at least) - this creates a bitmap (or a DIB if you prefer).  Or you can directly read the image into a bitmap (lots of sample code around for this)

You can then either use GetPixel/SetPixel to access it pixel-by-pixel.

However, in your case, you would probably be better off with GetDIBits to get ALL the pixel data at once into a buffer that you can access any way you want.


0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

636 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