Subpixelprecision (without antialias)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rune Zedeler

    #1

    Subpixelprecision (without antialias)

    Not sure whether this is the right group. Help on that appreciated as well.

    I need to draw lines in subpixelprecisi on. Downscaling the canvas from
    Graphics2D should imho do that.

    The program

    import java.awt.*;
    import javax.swing.*;
    public class TestGfx2D extends JPanel {
    public TestGfx2D() {
    JFrame f = new JFrame();
    setPreferredSiz e(new Dimension(16,16 ));
    f.add(this);
    f.pack();
    f.setVisible(tr ue);
    }
    public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D)g;
    g2.scale(.25,.2 5);
    for(int i=0; i<6; i++) {
    g2.drawLine(0,9 *i,40,10+9*i);
    }
    }
    public static void main(String[] args) {
    new TestGfx2D();
    }
    }

    thus should yield:

    |XXXX
    | XXXX
    |XXX XXX
    | XXXX
    |XX XXXX
    | XXXX
    |X XXXX
    | XXXX X
    | XXXX
    |XXXX XX
    | XXXX
    |XXX XXX
    | XXXX
    | XXXX

    - men it /yields/ on my system (sun java 5, ubuntu):

    |XXX
    | XXXXX
    |XXX XXX
    | XXXXX
    |XX XXX
    | XXX
    |XX XXXX
    | XXX XX
    | XXXX
    |XXX XX
    | XXXXX
    |XXX XXX
    | XXXXX
    | XXX

    I tried setting renderinghints, but I cannot get subpixelprecisi on
    without getting antialias at the same time :-(

    Are others experiencing the same, and does anybody know a workaround?
    (Really not into having to implement my own subpixel-stuff)

    -Rune
Working...