This might help.
/// <summary>Convert 16 bit gray to RGB</summary>
/// <param name="grayPixels">source pixels</param>
/// <param name="bitsStored">bits used [1..16]</param>
/// <returns>rgb pixels</returns>
public uint[] ConvertGray16ToRGB(ushort[] grayPixels, int bitsUsed) {
int pixelCount = grayPixels.Length;
uint[] rgbPixels = new uint[pixelCount];
int shift = bitsUsed - 8;
for (int i = 0; i < pixelCount; i++) {
uint gray = (uint)grayPixels[i] >> shift;
rgbPixels[i] = 0xff000000U | gray | (gray << 8) | (gray <<
16);
}
return(rgbPixels);
}
Success,
Jos Lavrijsen
"ke************@yahoo.com" wrote:
I am also trying to display 16bpp grayscale images. What is the right
way to convert them into RGB format? I devided each pixel value by 3
and assign the result to R/G/B. But the resultant images have lost
contrast almost completely. Any pointers are appreciated!
Bob Powell [MVP] wrote: Unfortunately you're unlikely to see this resolved by MS in the short term.
However you may be interested in the FreeImage library on SourceForge which
has a C# wrapper and supports lots of image formats.
--
Bob Powell [MVP]
Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"Jos Lavrijsen" <Jos La*******@discussions.microsoft.com> wrote in message
news:D7**********************************@microsof t.com... After searching newsgroups and discussions, i came to the following
conclusion.
Even though PixelFormat.Format16bppGrayScale is defined, it's NOT and will
NEVER
be supported by the .NET framework.
For our business (medical imaging), this is very disappointing.
16 bit gray is most common imageformat used for medical imaging.
Scaling back to 8 bit is not an option. We really need 16 bit accuracy
in our processing operations.
Does this mean that .NET is not meant for professional imaging?
Please reconsider support for 16 bit gray.
Thanks,
Jos Lavrijsen (Philips Medical Systems)