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

Discussion in 'Java' started by andreas.ryland@gmail.com, Jun 19, 2006.

  1. Guest

    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();
     
    , Jun 19, 2006
    #1
    1. Advertising

  2. > 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

    --
    http://uio.imagero.com Unified I/O for Java
    http://reader.imagero.com Java image reader
    http://jgui.imagero.com Java GUI components and utilities
     
    Andrey Kuznetsov, Jun 20, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. powerman
    Replies:
    0
    Views:
    791
    powerman
    Apr 5, 2006
  2. Marco Schmidt

    Re: Using Component based on Java2D

    Marco Schmidt, Jul 1, 2003, in forum: Java
    Replies:
    0
    Views:
    800
    Marco Schmidt
    Jul 1, 2003
  3. Bura Tino

    Java2D transparency: a long delay

    Bura Tino, Jul 1, 2003, in forum: Java
    Replies:
    4
    Views:
    1,207
    S. Balk
    Jul 2, 2003
  4. Replies:
    1
    Views:
    2,402
  5. Timo Nentwig
    Replies:
    6
    Views:
    538
Loading...

Share This Page