Click to See Complete Forum and Search --> : Retrieving image from memory
Pravish
June 16th, 2006, 12:20 AM
hi there,
i have a camera that, on interfacing, gives me the bitmap image into a memory alignment in the 'unsigned char'(LPBYTE) format...I m using VC++ 6.0 for some image processing stuff. I only require the rgb values of every pixel to process the image further. My question is that how do i retrieve the rgb values frm unsigned char format since they are 'int'(0-255)values.
KINDLY SUGGEST ME A SOLUTION
thanks
regards
golanshahar
June 16th, 2006, 02:19 AM
This thread (http://www.codeguru.com/forum/showthread.php?t=354381) might help you.
Cheers
Krishnaa
June 16th, 2006, 03:40 AM
There are functins like GetRValue, GetGValue, GetBValue.
golanshahar
June 16th, 2006, 05:26 AM
There are functins like GetRValue, GetGValue, GetBValue.
Just to be precise they are macros and not functions :D :wave:
Cheers
Pravish
June 26th, 2006, 11:21 PM
@golanshahar
Hi ,
I read the thread u linked me to in one of ur above replies.
I have certain doubts regarding the code u have mentioned up there...
www.codeguru.com/forum/showthread.php?t=354381
1> The GetRValue , GetGValue, and GetBValue macros take a DWORD value as a parameter and there is a BYTE value being passed in that code. Please clarify this. though i m not getting any error.
2>In the GetPIxel function , after calculating the value of nPosBuffer, I think it should be incremented by 1 everytime while calculating g and b. Am I right?
3>You have mentioned COLORREF rgb = RGB(r,g,b);
Please tell me how is it useful in GetPixel function.
Thank You for giving me ur time.
Do reply. My questions might sound foolish but I really need to get through this.
regards
Pravish
June 26th, 2006, 11:30 PM
@golanshahar
Hi ,
I read the thread u linked me to in one of ur above replies.
I have certain doubts regarding the code u have mentioned up there...
www.codeguru.com/forum/showthread.php?t=354381
1> The GetRValue , GetGValue, and GetBValue macros take a DWORD value as a parameter and there is a BYTE value being passed in that code. Please clarify this. though i m not getting any error.
2>In the GetPIxel function , after calculating the value of nPosBuffer, I think it should be incremented by 1 everytime while calculating g and b. Am I right?
3>You have mentioned COLORREF rgb = RGB(r,g,b);
Please tell me how is it useful in GetPixel function.
Thank You for giving me ur time.
Do reply. My questions might sound foolish but I really need to get through this.
regards
golanshahar
June 27th, 2006, 02:44 AM
1> The GetRValue , GetGValue, and GetBValue macros take a DWORD value as a parameter and there is a BYTE value being passed in that code. Please clarify this. though i m not getting any error.
You are right it should be more precise to pass DWORD, however passing a byte pointer the Marco will still "look" at it as DWORD that is why it working. :D
BTW another option the get the RGB from byte array is simple like that:
int nPosOnBuffer = nLineWidth*x + y*BitsPerPixel;
// case of RGB
int r = lpBits[nPosOnBuffer+0];
int g = lpBits[nPosOnBuffer+1];
int b = lpBits[nPosOnBuffer+2];
// case of BGR
int r = lpBits[nPosOnBuffer+2];
int g = lpBits[nPosOnBuffer+1];
int b = lpBits[nPosOnBuffer+0];
2>In the GetPIxel function , after calculating the value of nPosBuffer, I think it should be incremented by 1 everytime while calculating g and b. Am I right?
This is right if you using the other way I posted above, but if you using the macros you don’t need it.
3>You have mentioned COLORREF rgb = RGB(r,g,b);
Please tell me how is it useful in GetPixel function.
It is useful if you want to return COLORREF from rgb but if you don’t need to, then you don’t need this line. :)
Cheers
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.