Solved

Bitmap files

Posted on 1998-05-24
6
166 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 100 total points
ID: 1164682
answer coming.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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.

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now