Lockbits and 8-bit grayscale images
-
I have to pass pixelformat as a parameter when performing lockbits. But for grayscale images, there is only "Format16bppGrayscale." Does this format work with 8 bit grayscale images? If not, how do i use lockbits with 8bit grayscale images?
-
I have to pass pixelformat as a parameter when performing lockbits. But for grayscale images, there is only "Format16bppGrayscale." Does this format work with 8 bit grayscale images? If not, how do i use lockbits with 8bit grayscale images?
-
No. Use
PixelFormat.Format8bppIndexed
.Despite everything, the person most likely to be fooling you next is yourself.
if its 8-bit then shouldn't the values range from 0-255? I get black pixel as 0 and white as 169. Is this what its supposed to be?
-
if its 8-bit then shouldn't the values range from 0-255? I get black pixel as 0 and white as 169. Is this what its supposed to be?
Hi, 169 is two thirds of 255, as if you started off with an RGB image and either one component was absent, or something else went terribly wrong in the color-to-grayscale conversion. Or did you have an ARGB image (A=alpha=opacity) and take the wrong 3 out of 4 bytes? :)
Luc Pattyn [Forum Guidelines] [My Articles]
Voting for dummies? No thanks. X|
-
Hi, 169 is two thirds of 255, as if you started off with an RGB image and either one component was absent, or something else went terribly wrong in the color-to-grayscale conversion. Or did you have an ARGB image (A=alpha=opacity) and take the wrong 3 out of 4 bytes? :)
Luc Pattyn [Forum Guidelines] [My Articles]
Voting for dummies? No thanks. X|
Hmm it must be the website that i downloaded the image from. Im using the Lena picture in grayscale, which i previously downloaded. I downloaded the color version of lena and converted into grayscale using photoshop. Pixels return intensities properly now. Thank you.
-
Hmm it must be the website that i downloaded the image from. Im using the Lena picture in grayscale, which i previously downloaded. I downloaded the color version of lena and converted into grayscale using photoshop. Pixels return intensities properly now. Thank you.
Are you sure that it actually is a grayscale image, and not an indexed image that had a palette of 170 grayscale colors? I found one Lena picture in grascale, that is a GIF image with a 215 color palette.
Despite everything, the person most likely to be fooling you next is yourself.