save a Bitmap as grayscale

  • Thread starter Thread starter RicercatoreSbadato
  • Start date Start date
R

RicercatoreSbadato

I'm using bmp.Save() and the bmp is in PixelFormat.Format8bppIndexed.
But when I open the image with Gimp, it tells me that the image is RGB
and not grayscale.
 
Hello



What format are you using for saving? JPEG ?



Some image file formats has a special field in their header, which is set to
1 for grayscale images, for example (or a special flag). In the case you
even don't need to write your palette to the file. So, I suppose, that you
saved your image as an ordinary 8 bpp indexed imaged, with a palette of
grayscale gradients. Yes, your image looks grayscale, but Gimp thinks it's
not, because it seeing a palette and does not analyze it.



I have similar issue with my image processing library. I was loading
grayscale JPEG, but GDI+ was creating just 8 bpp indexed image and there was
no any chance to resolve if the image is grayscale. So, I am analyzing
palette of 8 bpp indexed images, to resolve if it's grayscale or colored.



Hope you will find the way.
 
Help me plz. I want to save into BMP format. Which is the flag I have
to modify? Thanks.. ;)
 
Oh, it's not obvious how to make it using GDI+. I can only suggest, that you
should try to use EncoderParameters class to specify, that you want to save
your image as grayscale. But there is no much documents on using it.
 
But U know another way to do it (whitout GDI+)?
I've seen your code of the Image Processing but neither U had resolved
this problem..

My goal is to transform a lot of image in grayscale, maybe I could use
an external module..
 
Hi Ricercatore,

You can create a Greayscale bitmap the same size as you original and
then call SetPixel() for each GetPixel() in the source bitmap. Then you
just Save() the greyscale bitmap.

Hope that helps,
Jan
 
RicercatoreSbadato said:
I'm using bmp.Save() and the bmp is in PixelFormat.Format8bppIndexed.

I haven't actually done this, but...

Doesn't that format mean indexed to a palette, not grayscale? The palette
might happen to have nothing but grays on it, but that's not the same as a
grayscale image.
 
You are telling me to use the "PixelFormat.Format16bppGrayScale" and
save() ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top