| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to get RGB W/O using libraries
Hey guys, i'm new to this so please bear with...
i'm trying to find a way to read from a bitmap file the color codes for each pixel. that is, if i go to bitmap pixel location (x, y), i have to find what the RGB values are. I can't use any libraries or pre defined functions so i have to start from scratch. any one know a GOOD refrence to get RGB values? |
|
#2
|
|||
|
|||
|
Best is to use GetRValue(),GetGValue() and GetBValue(). Since you are asked not to use pre-defined lib functions, read Three bytes of data then , Do following:
If you get a number "N" after reading 3 bytes of data, For Blue Value: N & 256 [As Blue' vlaue occurs in the last byte].Likewise, for Green value, the first eight bits be zero and all bits of first byte be zero too. Same for Red but bits for byte number 2 and 3 be zero. The GetRVlaue() and counterparts use the above tech. in getting the values.In VC++ theres a structure called RGBQUAD and COLORREF that have fields as R,Gand B. But for C , you can follow the approach of reading in 3 bytes and getting values after applying logical AND. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > How to get RGB W/O using libraries |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|