Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Creating Developer Defined BitmapPalette for 16-Bit Grayscale Image

$
0
0
Hi,
Wondering, if someone else knows/can help?
 
I am looking for a way to use a custom palette with 16-bit grayscale image data. I am looking to remap the pixels for display only (so can see normally image features that are too dark). I want to use the palette to avoid looping through all of the millions of pixels in the image (which does not meet my performance desires).
 
This code displays the 16-bit grayscale image correctly.
            PixelFormat pf = PixelFormats.Gray16; //int rawStride = ((width * pf.BitsPerPixel) + 7) / 8// Create a BitmapSource.            BitmapPalette palette = BitmapPalettes.Gray16;
            BitmapSource bitmap = BitmapSource.Create(
                width, 
                height,96, // 96 is dpi for X and Y96, 
                pf, 
                palette, 
                pixelData, 
                rawStride); return bitmap;
 
It seems to ignore a new custom palette (not in above code) unless I make the
PixelFormat pf = PixelFormats.Indexed<4|8>
but I do not see a PixelFormats.Indexed16 for 16-bit support.
 
Thanks for looking!

Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>