how to get and manipulate CBitmap information

1.2k Views Asked by At

I am a total newbie to c++ and non the less MFC so bare with my questions please.. i have been using MatLab throughout college to do image processing HERE IS THE QUESTION:

I have already read a .bmp image and stored it into a CBitmap object, but i have no idea how to get information from this object like (Width,Length) in pixels. In matlab i used to get a matrix when i read an image and i could easily apply filters to this matrix.

the image was read like

[1   3  123  13]
[12  33 34   14]
[131 46 32   67]

I could read value of individual pixels and do arithmetic operations to change it. Can I do the same with a CBitmap object? or should I read the image into something else like 2D arrays or something?

1

There are 1 best solutions below

0
On

Your first question is clear: how to get dimensions of the image in pixels.
Please try this:

CBitmap cbmp;
//load your bitmap here into the cbmp 
BITMAP aBmp;
cbmp.GetBitmap(&aBmp);
int imgWidthInPixels = aBmp.bmWidth;
int imgHeightInPixels = aBmp.bmHeight;