United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6182453 : Filling and drawing same GeneralPath do not match

Details
Type:
Bug
Submit Date:
2004-10-21
Status:
Closed
Updated Date:
2011-01-19
Project Name:
JDK
Resolved Date:
2006-02-22
Component:
client-libs
OS:
generic,windows_2000
Sub-Component:
2d
CPU:
generic,x86
Priority:
P3
Resolution:
Duplicate
Affected Versions:
5.0,6
Fixed Versions:

Related Reports
Duplicate:

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]
Service pack 4

A DESCRIPTION OF THE PROBLEM :
Sometimes the pixels touched by filling an area and then drawing the same area are not  aligned. The filling seems to 'spill' pixels outside of the outline, and seems not to fill all pixels inside the outline.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The bug can be seen by running the attached program.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I was expecting to see no visual distortion.
ACTUAL -
Blue pixels of the filling are seen outside the outline. White (background) pixels are left unfilled inside the outline.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.geom.*;
import java.awt.image.*;
import javax.swing.*;

public class Spill
{
    static public void main(String[] args)
    {
        /* Create an image */
        BufferedImage image = new BufferedImage(500,500,BufferedImage.TYPE_INT_RGB);
        Graphics2D graphics = image.createGraphics();
        graphics.setColor(Color.white);
        graphics.fillRect(0,0,image.getWidth(),image.getHeight());
        /* Make the shape */
        GeneralPath path = new GeneralPath();
        path.moveTo(-5.0f,-5.0f);
        path.lineTo(33.0f,-5.0f);
        path.lineTo(33.0f,19.0f);
        path.lineTo(-5.0f,19.0f);
        path.closePath();
        /* Render without error */
        graphics.translate(200.0,150.0);
        render(graphics,path);
        /* Render with error */
        graphics.translate(0.517747036277655,100.11394841313354);
        render(graphics,path);
        graphics.dispose();
        /* Show image */
        JFrame frame = new JFrame("Spill Test");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(new JLabel(new ImageIcon(image)));
        frame.pack();
        frame.show();
    }

    static private void render(Graphics2D graphics,GeneralPath path)
    {
        graphics.setColor(Color.blue);
        graphics.fill(path);
        graphics.setColor(Color.red);
        graphics.draw(path);
    }
}

---------- END SOURCE ----------
###@###.### 10/21/04 10:28 GMT

                                    

Comments
EVALUATION

This bug was fixed within the fix of the 4151279 by using the same code for tracking
boundaries of the GeneralPath in filling and drawing code. So, I'm closing this bug
as duplicate.
                                     
2006-02-22
EVALUATION

Contribution-Forum:https://jdk-collaboration.dev.java.net/servlets/ProjectForumMessageView?messageID=11504&forumID=1463
                                     
2006-02-17



Hardware and Software, Engineered to Work Together