all groups > dotnet drawing api > january 2007 >
You're in the

dotnet drawing api

group:

8 bit indexed bitmap object saves to jpg as 24 bit...


8 bit indexed bitmap object saves to jpg as 24 bit... James Maeding
1/22/2007 5:11:54 PM
dotnet drawing api:
I've been studying all the articles I can find on GDI+, and putting together a function to convert image colors and
types.
I am finding that I can quantize an image to 8 bit colors, and then save to png format perfectly with:
bitmap.save(filename, ImageFormat.png)
When I do the same thing to jpg, I get a 24 bit color jpg every time.
I know jpg supports an indexed 8 bit palette, and can make them all day in other progs like corel photo-paint.

I can watch the bitmap object to inspect it just before the save, its exactly the same every time.
The only difference is I am doing bitmap.save(filename, ImageFormat.Jpeg) instead of bitmap.save(filename,
ImageFormat.png)

I tried going the bitmap.save(filename, ImageCodecInfo, EncoderParameters) in case I needed to set the quality of the
jpg to 100 or something. didn't work.

Any suggestions? I must be missing something simple. I thought if I start with the exact same bitmap object with same
properties for both cases, the save method would behave but its not.
Re: 8 bit indexed bitmap object saves to jpg as 24 bit... James Maeding
1/22/2007 8:00:34 PM
funny how we can be our own worst enemy. I am actually hoping you are right because that would answer my question.
The reason I think jpg's can support indexed is I can open one in corel photo paint, and convert color to 8 bit
paletted. I can load that into a bitmap object and the palete is 256 colors, indexed.
I was sold on that but maybe that is a bit special (no pun..) somehow.
I agree its a lossy format, and have no opinion on if its suited to indexed colors.
I just know the paletted ones are a lot smaller than the 24 bit.
I'll be going with png's, but I wanted to be able to go to any format with my tool.
thx



"Nik Coughlin" <nrkn.com@gmail.com>
[quoted text, click to view]
|>> I've been studying all the articles I can find on GDI+, and putting
|>> together a function to convert image colors and types.
|>> I am finding that I can quantize an image to 8 bit colors, and then
|>> save to png format perfectly with: bitmap.save(filename,
|>> ImageFormat.png)
|>> When I do the same thing to jpg, I get a 24 bit color jpg every time.
|>> I know jpg supports an indexed 8 bit palette, and can make them all
|>> day in other progs like corel photo-paint.
|>
|>Where you're going wrong is, despite what you "know", jpeg doesn't support
|>indexed palettes at all. It's a lossy compression format intended for
|>storing photograph-type images. It is fundamentally unsuited to indexed
|>images.
Re: 8 bit indexed bitmap object saves to jpg as 24 bit... James Maeding
1/22/2007 8:02:29 PM
it seems that might be the case - and that is fine with me. I don't like jpg a lot as most people do not realize its
lossier with every save. thx for the reply

"Michael C" <nospam@nospam.com>
[quoted text, click to view]
|>> I've been studying all the articles I can find on GDI+, and putting
|>> together a function to convert image colors and
|>> types.
|>> I am finding that I can quantize an image to 8 bit colors, and then save
|>> to png format perfectly with:
|>> bitmap.save(filename, ImageFormat.png)
|>> When I do the same thing to jpg, I get a 24 bit color jpg every time.
|>> I know jpg supports an indexed 8 bit palette, and can make them all day in
|>> other progs like corel photo-paint.
|>
|>Paint shop pro forces the image to 24 bit. Maybe this is a feature only of
|>corel and not generally supported?
|>
|>Michael
Re: 8 bit indexed bitmap object saves to jpg as 24 bit... James Maeding
1/22/2007 8:39:36 PM
wow, I wonder what else I have been missing :)
you are dead on correct, it flips back to 24 bit color in corel pp.
I guess I so rarely use jpg's (I use tif's) that I didn't notice it. I could have sworn it worked, you should have made
a bet with me <g>.
Its like fighting with my wife now, the more I say the dumber I look....

thanks for the schooling.


"Nik Coughlin" <nrkn.com@gmail.com>
|>> "Nik Coughlin" <nrkn.com@gmail.com>
|>>>> Where you're going wrong is, despite what you "know", jpeg doesn't
|>>>> support indexed palettes at all. It's a lossy compression format
|>>>> intended for storing photograph-type images. It is fundamentally
|>>>> unsuited to indexed images.
|>
[quoted text, click to view]
|>> funny how we can be our own worst enemy. I am actually hoping you
|>> are right because that would answer my question. The reason I think
|>> jpg's can support indexed is I can open one in corel photo paint, and
|>> convert color to 8 bit paletted. I can load that into a bitmap
|>> object and the palete is 256 colors, indexed.
|>> I was sold on that but maybe that is a bit special (no pun..) somehow.
|>> I agree its a lossy format, and have no opinion on if its suited to
|>> indexed colors.
|>> I just know the paletted ones are a lot smaller than the 24 bit.
|>> I'll be going with png's, but I wanted to be able to go to any format
|>> with my tool.
|>
|>Interesting. What happens if you open a jpeg, convert to 8 bit indexed,
|>save it as jpeg, close the file, then re-open it?
Re: 8 bit indexed bitmap object saves to jpg as 24 bit... Michael C
1/23/2007 1:59:47 PM
[quoted text, click to view]

Paint shop pro forces the image to 24 bit. Maybe this is a feature only of
corel and not generally supported?

Michael

Re: 8 bit indexed bitmap object saves to jpg as 24 bit... Nik Coughlin
1/23/2007 2:47:51 PM
[quoted text, click to view]

Where you're going wrong is, despite what you "know", jpeg doesn't support
indexed palettes at all. It's a lossy compression format intended for
storing photograph-type images. It is fundamentally unsuited to indexed
images.

Re: 8 bit indexed bitmap object saves to jpg as 24 bit... Nik Coughlin
1/23/2007 5:19:22 PM
[quoted text, click to view]

Interesting. What happens if you open a jpeg, convert to 8 bit indexed,
save it as jpeg, close the file, then re-open it?

Re: 8 bit indexed bitmap object saves to jpg as 24 bit... Nik Coughlin
1/23/2007 5:48:58 PM
[quoted text, click to view]

Betcha $50 I'm right :P

Oops, too late

AddThis Social Bookmark Button