# Displaying 16 bit raw images

## Recommended Posts

If I have an array of data (16 bit values) that represent pixel intensity (in other words a grayscale image), can anyone tell me how to display this data in a picture box in an MFC application? If the code is long or complicated I guess don't worry about it, but it seems like a simple thing that I've just spent way too much time digging around trying to solve. Thanks, Andrew

##### Share on other sites
I'm not much in the MFC, but AFAIK you have a Paint event for the picture box.
In it, you can do a blit to the HWND with the data, but I guess you'll need some data transforming before.

I would create a bitmap in memory. I'm not sure if there's an standard 16 bits greyscale bmp, but you can always do:

unsigned char R,G,B;for (i = 0; i < ArraySize; i++){    int Luminance = Array[i] * 256 / 65535;    R = G = B = Luminance;    ...}

And fill up a BitmapInfo structure with these values.
http://msdn.microsoft.com/en-us/library/aa921550.aspx

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
627700
• Total Posts
2978695

• 21
• 14
• 12
• 10
• 12