Discussion:
from Format24bppRgb to Format8bppIndexed
(too old to reply)
tlemcenvisit via .NET 247
2005-06-02 11:39:27 UTC
Permalink
Hello
I'd like to change the format of a Bitmap from Format24bppRgb to Format8bppIndexed (GrayScale)
Please, help me

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>8GFAzJMl8Ei5zUUmjeDTNg==</Id>
Morten Wennevik
2005-06-02 12:52:09 UTC
Permalink
Hi,

PS! You can use nntp://msnews.microsoft.com to access this news server directly.

There is no simple way to transform the two formats. If you don't need to save the grayscale image you can simply swap the pixels or use a ColorMatrix when drawing it a Graphics object.

[How to convert a colour image to grayscale]
http://www.bobpowell.net/grayscale.htm

If you need to save a bitmap file as 8bpp indexed, then you need to do a bit of manual labour by creating a new bitmap, create a grayscale palette and transform the pixels from the 24bpp bitmap to an index in the 8pp bitmap.

I believe internet has an example on how to do this as well. However, I could not locate it at the moment.
Post by tlemcenvisit via .NET 247
Hello
I'd like to change the format of a Bitmap from Format24bppRgb to Format8bppIndexed (GrayScale)
Please, help me
-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>8GFAzJMl8Ei5zUUmjeDTNg==</Id>
--
Happy coding!
Morten Wennevik [C# MVP]
Bob Powell [MVP]
2005-06-02 14:31:45 UTC
Permalink
I don't have a specific atricle on grayscale palettes but the one on
modifying a colour palette for transparency shows the technique. To create
the palette is fairly simple just providing RGB values all the same for each
of the colours eg:

0,0,0 = black
255,255,255=white
128,128,128-50% gray etc.
--
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.
Post by Morten Wennevik
Hi,
PS! You can use nntp://msnews.microsoft.com to access this news server directly.
There is no simple way to transform the two formats. If you don't need to
save the grayscale image you can simply swap the pixels or use a
ColorMatrix when drawing it a Graphics object.
[How to convert a colour image to grayscale]
http://www.bobpowell.net/grayscale.htm
If you need to save a bitmap file as 8bpp indexed, then you need to do a
bit of manual labour by creating a new bitmap, create a grayscale palette
and transform the pixels from the 24bpp bitmap to an index in the 8pp
bitmap.
I believe internet has an example on how to do this as well. However, I
could not locate it at the moment.
On Thu, 02 Jun 2005 13:39:27 +0200, tlemcenvisit via .NET 247
Post by tlemcenvisit via .NET 247
Hello
I'd like to change the format of a Bitmap from Format24bppRgb to
Format8bppIndexed (GrayScale)
Please, help me
-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>8GFAzJMl8Ei5zUUmjeDTNg==</Id>
--
Happy coding!
Morten Wennevik [C# MVP]
TC
2005-06-03 04:04:16 UTC
Permalink
Morten Wennevik wrote:

(snip)
Post by Morten Wennevik
or use a ColorMatrix when drawing it a Graphics object.
No can do when he wants an indexed output, surely?

TC

Loading...