There appears to be a bug in your method.  Was this a cut-and-paste error?

[EMAIL PROTECTED] wrote:
Hi.

I am writing an Applet for viewing large (~2600x3500) tiff files. Here is my 
scaling method

public static BufferedImage getScaledInstance( Image img, int targetWidth,
            int targetHeight, Object hint, boolean higherQuality ) {

            [...lines deleted for brevity...]

            ret = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
            Graphics2D g2 = ret.createGraphics();
            g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint);

            g2.drawImage(img, 0, 0, w, h, null);
            g2.dispose();

This line should be added here:

              img = ret;


        } while (w != targetWidth || h != targetHeight);
        [...more lines deleted for brevity...]
    }

Does that help the timings any? It should definitely improve the quality of the results for this case.

Also, which version of the JDK are you using and what kind of image is returned from the ImageIO.read method? Doing a System.out.println() on the returned BufferedImage will print out a lot of detail about its type and internal storage structure. Also, if you run with the command line argument "-Dsun.java2d.trace=log" you can see which kinds of operations are used for the scaling operations.

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