I reported another bug I came across about one month ago, but did not get any repsonse till now.
The ID is: 409145 - but its not visible till now.
The bug-report was that the size of volatile/managed images created via Component.createImage() is limited.
However I’ve found out some other facts which seem to show that this is an Java2D and not a driver bug:
-
The size of the image is limited to the highest-level-heavyweight component. If you have a component-hirarchy of JFrame(500, 500)->(AWT)Panel(300, 300)->(AWT)Panel(100, 100) and you create the image on the highest-level panel (100, 100) then the size of the backbuffer-image will be limited to 100, 100.
If you use JPanels instead of Panels your image is limited to (500, 500), because that is the size of the highest-level heavyweight component (JFrame in this case).
This happens for both, Volatile and Managed images.
-
If I increase the size of the generated image to something bigger than 4096, everything works quiet fine. (I then then accerlation is turned off).
-
This bug happend in 1.5 and the Mustang-builds too.
Hope this helps, lg Clemens
I also have an ugly test-case:
import java.awt.*;
import javax.swing.*;
/**
* (c) Clemens Eisserer
*/
public class OGLTest extends Panel implements Runnable
{
Image contentImage;
public static final int contentWith = 200;
public static final int contentHeight = 4096;
int currScrollPos = 0;
public OGLTest()
{
Frame f = new Frame();
f.setSize(800, 800);
f.setVisible(true);
f.setLayout(null);
this.setLocation(20, 20);
this.setSize(500, 500);
f.add(this);
contentImage = createImage(contentWith, contentHeight);
drawContent();
Thread t = new Thread(this);
t.start();
}
public void paint(Graphics g)
{
g.setColor(Color.white);
g.fillRect(0, 0, 500, 500);
g.setColor(Color.black);
g.drawString("That is the clipping test", 100, 100);
g.setClip(0, 150, 500, 300);
g.drawImage(contentImage, 0, currScrollPos, this);
}
public void run()
{
while(true)
{
currScrollPos--;
if(currScrollPos < -(contentHeight-300)) currScrollPos = 0;
Thread.yield();
this.repaint();
}
}
private void drawContent()
{
Graphics contentG = contentImage.getGraphics();
GradientPaint paint = new GradientPaint(0f, 0f, Color.red, (float) contentWith, (float) contentHeight, Color.yellow, true);
((Graphics2D) contentG).setPaint(paint);
contentG.fillRect(0, 0, contentWith, contentHeight);
contentG.setColor(Color.black);
((Graphics2D) contentG).setPaint(null);
contentG.drawRect(1, 1, contentWith-2, contentHeight-2);
for(int i=0; i < contentHeight; i+= 20)
{
contentG.drawString(String.valueOf(i), 20, i);
}
}
public static void main(String[] args)
{
new OGLTest();
}
}