How to kill java2D dithering? RenderingHints does not disable unwanted dithering

A

andreas.ryland

I have seen this question being posted before, and some workarounds
suggested, however it always seemed to be in an applet context and as
such the worarounds were not usable to me.

Using the code pasted below, I draw a directcolormodel image on a
indexcolormodel image, with a ready-calculated indexcolormodel
provided.

But the images have problems and the quality is not good because solid
filled areas are dithered into half tones when half tones are available
in the palette in the indexcolormodel provided. I try to stop java from
changing the colors of the pixels in my image by setting the dither
disble rendering hint but this has no effect.

Is this a bug or do I have to take and special steps to make the
rendring hint count ?

BufferedImage newImage = new
BufferedImage(image.getWidth(),image.getHeight(),BufferedImage.TYPE_BYTE_INDEXED,(IndexColorModel)cm);
gfx.setRenderingHint(RenderingHints.KEY_DITHERING,RenderingHints.VALUE_DITHER_DISABLE);
gfx.drawImage(image,0,0,null);
gfx.dispose();
 
A

Andrey Kuznetsov

BufferedImage newImage = new
BufferedImage(image.getWidth(),image.getHeight(),BufferedImage.TYPE_BYTE_INDEXED,(IndexColorModel)cm);
gfx.setRenderingHint(RenderingHints.KEY_DITHERING,RenderingHints.VALUE_DITHER_DISABLE);
gfx.drawImage(image,0,0,null);
gfx.dispose();

are you already tried with getRGB() and setRGB()?

Andrey
 

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

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,701
Latest member
XavierQ83

Latest Threads

Top