Here's a brief code sample that demonstrates the problem: resize the window to
full screen and look at the rendering of the number '258' to easily spot the
seaming pattern.
[code]
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
import java.awt.image.WritableRaster;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class TileBugTest {
public static class TestFrame extends JFrame{
public JPanel panel;
//public BufferedImage buff;
public TestFrame(String title){
super(title);
final int width = 300;
final int height = 300;
final BufferedImage im = new BufferedImage(width,
height, BufferedImage.TYPE_INT_ARGB);
WritableRaster r = im.getRaster();
DataBufferInt db = (DataBufferInt) r.getDataBuffer();
int[] bufdata = db.getData();
for(int i = 0; i < height*width; i++){
int c = (int) (Math.random() * 255);
bufdata[i] = (int)((c << 16) + (c << 8) + (c) +
(255 << 24));
}
im.flush();
Graphics g = im.getGraphics();
for (int i = 0; i < height; i+=12){
char[] chs = ("" + (i-6)).toCharArray();
g.setColor(new Color(255,255, 255));
g.fillRect(4, i-10, 40, 10);
g.setColor(new Color(0,0,0));
g.drawChars(chs, 0, chs.length, 8, i);
}
panel = new JPanel() {
@Override
public void paintComponent(Graphics gc) {
Graphics2D gfx = (Graphics2D) gc;
gfx.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
//gfx.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
gfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
double xScaleFactor = ((double)
this.getWidth()) / width;
double yScaleFactor = ((double)
this.getHeight()) / height;
AffineTransform af = new
AffineTransform();
af.setToScale(xScaleFactor,
yScaleFactor);
//gfx.setClip(clip)
gfx.drawImage(im, 0,0, this.getWidth(),
this.getHeight(), 0, 0, width, height, null);
}
};
this.getContentPane().add(panel);
this.setSize(400, 400);
this.setVisible(true);
}
}
public static void main(String[] args){
TestFrame tf = new TestFrame("test");
}
}
[/code]
[Message sent by forum member 'jacobspd' (jacobspd)]
http://forums.java.net/jive/thread.jspa?messageID=328514
===========================================================================
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".