How to SetPixel from GetBitmapBits ?

I have retrieved the bits of a bitmap into a byte array pBits...
Bits per pixel is 16 and there is only one plane.

Now how do I calculate the RGB value for pixel x,y so that
I may SetPixel (x, y, ???) and get the same color as in the original
bitmap?  I'm hoping this is a straight calculation from pBits rather
than using something like SelectPalette( ).  Please be explicit.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You normally can't do a straight calculation, because depending on the color depth, the colors may be relative or absolute. In the case of 16 bits per pixel, it is a direct mapping. So if you know for sure this is the color depth the bitmaps will come in, you can map it directly into the palette. You can find examples as CodeGuru ( under bitmaps and palettes.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.