We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › scale smooth or fast
Page Index Toggle Pages: 1
scale smooth or fast (Read 1398 times)
scale smooth or fast
Nov 28th, 2006, 11:38pm
 
hello,

my sketch displays an image ten times its size. on the macintosh it gets blurry - but it should not!

I read in the jdk api, scaling an image takes a parameter, SCALE_FAST or SCALE_SMOOTH - is there a way to pass these to the image function in processing?

thank you in advance

peter
Re: scale smooth or fast
Reply #1 - Nov 28th, 2006, 11:51pm
 
Oops,

I am a little late to read the api doc - every PImage has a public field "smooth" - Now its set to false - I will report how this did in safari.

does this mean, java 1.4 on linux is missing a smooth scaler?

peter
Help: scale smooth or fast
Reply #2 - Dec 3rd, 2006, 3:08am
 
hello again,

So I did some testing: I set the source PImage's field "smooth" to false, and also called "noSmooth()" in setup. still in safari the image gets blurry when mapped to the drawing surface. (unlike java 1.5 in windows, or java 1.4 on linux.)

Please advise on how to set smooth to false in the applet window's context. the sketch now is online at http://www.myzel.net/botcafe/applet.html - it also sets the undocumented g.smooth to false, to no avail.

Thank you.

Peter
Re: scale smooth or fast
Reply #3 - Dec 3rd, 2006, 9:06pm
 
i don't scale the image via getScaledInstance() (unnecessary overhead), so that route won't work. the problem is that apple has chosen to always smooth images in java2d by default in their java2d implementation (think different!)

i assume that this is a matter of tweaking a renderinghint somewhere, though some google digging turned up nothing for me. i would consider the windows/linux implementation correct.. according to this:
http://developer.apple.com/documentation/Java/Conceptual/JavaPropVMInfoRef/Articles/JavaSystemProperties.html#//apple_ref/doc/uid/TP40001975-DontLinkElementID_6
a system property might have some effect, but that seems excessive, and setProperty() may even throw a security exception in an applet (wee!)

if anyone has any clues on this one, they'd be most appreciated.
Re: scale smooth or fast
Reply #4 - Dec 3rd, 2006, 9:25pm
 
found it, will make the change for 0124. in the meantime, you can use this:

Graphics2D g2 = ((PGraphicsJava2D)g).g2;

g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,                        RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);

for 0124, i'll switch between nearest neighbor and bicubic on smooth() and noSmooth(), so that should make it consistent between platforms.
Re: scale smooth or fast
Reply #5 - Dec 4th, 2006, 1:16pm
 
Thank you, fry! You are the best - setting the hint works perfectly.

The incredible amount of polish makes processing shine - so a little light falls onto my feeble sketches too Smiley

Peter
Page Index Toggle Pages: 1