For Programmers: Free Programming Magazines  


Home > Archive > VC Language > January 2006 > Converting bitmap to pixel intensity array









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Converting bitmap to pixel intensity array
nah

2006-01-25, 7:23 pm

I have never done any image processing before. I would like to take a
grayscale bitmap image and convert it to a 2D array where each element
represents one of the image's pixel intensities. Would anyone be able to
steer me in the right direction? Thank you very much.
Nikolai.
Igor Tandetnik

2006-01-25, 7:23 pm

"nah" <nah@discussions.microsoft.com> wrote in message
news:EAF87A19-9030-4998-97D2-800293B070CA@microsoft.com
> I have never done any image processing before. I would like to take a
> grayscale bitmap image and convert it to a 2D array where each element
> represents one of the image's pixel intensities.


GetDIBits
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


RodgeFu

2006-01-26, 7:08 pm

just open the bmp file and read it to a memory block m_lpBMP and then

m_lpBMPFileHeader=(BITMAPFILEHEADER*)m_l
pBMP;
m_lpBMPInfoHeader=(BITMAPINFOHEADER*)(&m_lpBMPFileHeader[1]);
m_lpColorTable=(RGBQUAD*)(&m_lpBMPInfoHeader[1]);
m_lpDib=((char*)m_lpBMP+m_lpBMPFileHeade
r->bfOffBits);

the m_lpDib is what you want. Be careful that the width of Dib is always
n*32bit.
for example: if the bmp's depth is 1 and bmp's width is 21, the size of a
line of bmp is 1*21 = 21, but in memory it will still use 32bit to store a
line.

you can use

widthInDW=(m_lpBMPInfoHeader->biBitCount*m_lpBMPInfoHeader->biWidth +31) /32;

to get the size of a line in memory in dword

--
Hello World


"nah" wrote:

> I have never done any image processing before. I would like to take a
> grayscale bitmap image and convert it to a 2D array where each element
> represents one of the image's pixel intensities. Would anyone be able to
> steer me in the right direction? Thank you very much.
> Nikolai.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com