When I run this case I can just make out 29 extremely faint bars on the
screen which is exactly how many possible colors there are between the
endpoints you chose so it looks like I am seeing adjacent colors on a
true-color display. I'm a bit surprised that my eyes are that sensitive
and that my LCD panels are that accurate (these are decent, but not
top-of-the-line, monitors and often consumer LCD monitors don't really
provide the full 256 shades of each color component so I guess I lucked
out there).
If you see it worse on other monitors (in particular, fewer than 29 bars
across the window) then it may be that those aren't true 24-bit
panels/displays.
We currently only worry about dithering on 8-bit indexed destinations.
We have a request outstanding for dithering on 15/16-bit displays, but
we haven't gotten to it. This would be the first request for dithering
on a TrueColor display. ;-)
I agree that the problem is visible, but it is a lot less visible with
colors and with other parts of the grayscale spectrum (you chose a band
of 30 colors just below 50% luminance where it is most noticeable). It
would be a fairly low priority for us to fix right now. Perhaps when we
add support for >8bit per component image formats we might address
issues like this. You might want to file a feature request on this so
it doesn't get lost...
...jim
[EMAIL PROTECTED] wrote:
I was bored, so here's a test case... I can see the banding, just barely. I
suppose some monitors will make it look worse than others. In any case I think
the solution is dithering, but you will have to do it manually, simply
supplying the rendering hint
(g2.setRenderingHint(RenderingHints.KEY_DITHERING,RenderingHints.VALUE_DITHER_ENABLE);
) doesn't seem to have an effect on the behavior of GradientPaint.
[code]
/*
* Gradient.java
*
* Created on June 5, 2006, 10:29 PM
*
*/
package scott.palmer;
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JFrame;
import javax.swing.JPanel;
/**
*
* @author Scott Palmer
*/
public class Gradient extends JPanel
{
public static void main(String [] args)
{
JFrame f = new JFrame("Gradient with Banding issues");
f.setContentPane(new Gradient());
f.setSize(800,200);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
protected void paintComponent(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;
g2.setPaint(new GradientPaint(
0,0,new Color(101,101,101),
getWidth(),0,new Color(130,130,130)));
g2.fillRect(0,0,getWidth(),getHeight());
}
}
[/code]
[Message sent by forum member 'swpalmer' (swpalmer)]
http://forums.java.net/jive/thread.jspa?messageID=119469
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".