Blured Icons - any chance to avoid it on 100% zoom?

40 views
Skip to first unread message

jles...@gmx.de

unread,
Apr 18, 2014, 1:53:12 PM4/18/14
to piccolo...@googlegroups.com
Hey guys
I have a question concerning Icons, rendered by a PImage node. Even if I display the Icons with a 100% zoom (i.e. no scaling necessary), the icons are displayed kind of blurred. As soon as a start dragging the nodes around, the icons look clear until I release the mouse. On mouse release Piccolo seems to perform a beatifying phase were it applies anti aliazing and things like that. However, concerning the icons, this turns out as an "uglifying".

Is there any chance to improve that?

Cheers,
Jan


PS: Despite of little issues like the one above - great framework!!

icons-blured.png
icons-clean-during-drag.png

Michael Heuer

unread,
Apr 18, 2014, 3:04:17 PM4/18/14
to piccolo...@googlegroups.com
Jan wrote:
> I have a question concerning Icons, rendered by a PImage node. Even if I
> display the Icons with a 100% zoom (i.e. no scaling necessary), the icons
> are displayed kind of blurred. As soon as a start dragging the nodes around,
> the icons look clear until I release the mouse. On mouse release Piccolo
> seems to perform a beatifying phase were it applies anti aliazing and things
> like that. However, concerning the icons, this turns out as an "uglifying".
>
> Is there any chance to improve that?

Yes, for performance reasons PCanvas allows different quality of
rendering at different times

http://www.piccolo2d.org/doc/piccolo2d.java/release-3.0/core/org/piccolo2d/PCanvas.html#setAnimatingRenderQuality%28int%29

http://www.piccolo2d.org/doc/piccolo2d.java/release-3.0/core/org/piccolo2d/PCanvas.html#setDefaultRenderQuality%28int%29

http://www.piccolo2d.org/doc/piccolo2d.java/release-3.0/core/org/piccolo2d/PCanvas.html#setInteractingRenderQuality%28int%29

At mouse release you are seeing a change from interacting to default
render quality. You can use these methods to all the same render
quality all the time.


If you need finer grained access to the Graphics2D context you'll need
to override one of the drawing methods in PNode and set the rendering
hints directly

http://docs.oracle.com/javase/7/docs/api/java/awt/Graphics2D.html#setRenderingHints%28java.util.Map%29

I have examples of doing this but I can't remember which library of
mine those are in. I can dig if you'd like.

michael

Lalit Pant

unread,
Apr 18, 2014, 11:22:30 PM4/18/14
to piccolo...@googlegroups.com
I ran into something similar recently (in Kojo: http://www.kogics.net/kojo). The fix was to override paint() in a PImage subclass and add the following rendering hint:
        g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR)

With this, there is no blurring at 100% zoom, but the image looks more jagged when you zoom in.

Note - I use high quality rendering for animation, interaction, and as a default.

Cheers,
- Lalit

jles...@gmx.de

unread,
Apr 19, 2014, 11:32:00 AM4/19/14
to piccolo...@googlegroups.com
Ah, perfekt. I added both of your tricks. Michaels render quality to always have the best one as long as I can afford it ;-)
And the rendering hint in a derived PImage class when the scale factor is 1.0 (i.e. 100% Zoom). So it simply looks like that now in my code:

    @Override
    protected void paint(PPaintContext paintContext) {
        if (paintContext.getScale() == 1.0d) {
            final Graphics2D g2 = paintContext.getGraphics();
            g2.setRenderingHint(
                 RenderingHints.KEY_INTERPOLATION,
                 RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
        }
        super.paint(paintContext);
Reply all
Reply to author
Forward
0 new messages