Jim, Thanks for the explanation.

I ran into this problem trying to render filled and outlined ellipses into a
back buffer.  I was using the Ellipse2D shape, and I was running Sun's JRE
(1.3+) on Win2K & WinXP.

The problems were:

1. Both outlined and filled ellipse looked bad (angular, asymmetric) when
    drawn to offscreen buffer.
2. Ellipse filling did not touch outline in some places; and in other
    places, filling bled through outline.
3. Neither the offscreen ellipse outline nor filling matched the onscreen
    version.

My test applet is below.

In my test, I tried applying a value-quality hint but it doesn't help.
Using anti-alias is not an option (too fuzzy, etc.)

/* EllipseTest.java */

import java.awt.*;
import java.awt.geom.Ellipse2D;

/** Tests Graphics2D ellipse. */
public class EllipseTest extends java.applet.Applet {

    public void init() {
        setLayout(new java.awt.BorderLayout());
    }

    public void paint(Graphics g) {

        // on screen
        g.setColor(Color.BLUE);
        g.drawRect(5, 5, 90, 90);
        Graphics2D g2 = (Graphics2D) g;
        //g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
        //    RenderingHints.VALUE_ANTIALIAS_ON);
        //g2.setRenderingHint(RenderingHints.KEY_RENDERING,
        //    RenderingHints.VALUE_RENDER_QUALITY);
        Shape s = new Ellipse2D.Double(5, 5, 90, 90);
        g2.setPaint(Color.RED);
        g2.fill(s);
        g2.setPaint(Color.BLACK);
        g2.draw(s);

        // off screen
        Image image = createImage(100, 100);
        Graphics gi = image.getGraphics();
        gi.setColor(Color.BLUE);
        gi.drawRect(5, 5, 90, 90);
        Graphics2D gi2 = (Graphics2D) gi;
        //gi2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
        //    RenderingHints.VALUE_ANTIALIAS_ON);
        gi2.setRenderingHint(RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY);
        gi2.setPaint(Color.RED);
        gi2.fill(s);
        gi2.setPaint(Color.BLACK);
        gi2.draw(s);
        g2.drawImage(image, 100, 0, this);
    }
}


----- Original Message -----
From: "Jim Graham" <[EMAIL PROTECTED]>
To: "Joe Bowbeer" <[EMAIL PROTECTED]>
Cc: "Discussion list for Java 2D API" <[EMAIL PROTECTED]>
Sent: Tuesday, September 02, 2003 3:52 PM
Subject: Re: [JAVA2D] Odd shaped circles revisited


Hi Joe,

--Joe Bowbeer wrote:
> Is any progress being made with bug 4151279?
>
> http://developer.java.sun.com/developer/bugParade/bugs/4151279.html
>
> Is this scheduled to be fixed in Tiger 1.5?
>
> Is this the right place to ask about this?

This is the best place I can think of to ask this question.

This is a complicated issue whose full and complete solution will
definitely exceed the Tiger timeframe as it would involve finding
agreement between a lot of different internal rendering algorithms.

But I think we can address at least one known "really bad offender"
in the Tiger time frame which is the fact that our software renderer
maintains subpixel precision when filling arcs, ovals, and Shapes
but rounds to integers when drawing their (thin) outlines.  This
not only creates inconsistencies between the fills and the draws,
but it means that our draws are fairly angular and crooked.

Some of the things that make it complicated are:

- Some of the bug reports talk about fillOval and others
  talk about drawOval, yet customers that add their voices
  to such reports don't always distinguish their problems
- The comment about "good enough" in the bug you cited
  was specifically referring to filled ovals and those,
  by and large, do appear fairly consistent and symmetric
  although many of the comments will include test cases
  based on drawOval and claim we are wrong.
- Internally there are many pathways that we might take
  to satisfy the same rendering request depending on
  which attributes you set:
- We might use X11 or GDI
- We might use software loops
- We might express arcs and ovals as Cubic beziers
- We might draw outlines using bresenham
- We might draw outlines by converting to
  a "Stroke Shape" and filling it
- We might use different pipelines for
  filling vs. drawing depending on the
  attributes specified

I could share some anecdotes of our experiences with some of the
platform API's attempts to draw arcs, but basically we aren't
always the bad guys here and we have to discover their problems
before we can work around them.

Hopefully that answer helped.  If you have a specific test case
that you are specifically worried about, it might help to identify
it (using our comments web form on java.sun.com) rather than cite
that bug report (which talks about both filled and drawn ovals)...

...jim

===========================================================================
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".

Reply via email to