Hello Forum ! Profiling one of our app I spotted Image.getScaledInstance() taking more time ! searched on web and found this: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6196792
I wrote utility method as follows for getting the same result as Image.getScaledInstance() but should be faster. it does not work :( shows half image in specified region ! public static javax.swing.ImageIcon getScaledImage(javax.swing.ImageIcon icon, int width, int height) { // maintain the aspect ratio as in Image.getScaledInstance() int iconWidth = icon.getIconWidth(); int iconHeight = icon.getIconHeight(); if (width < 0) { if (height < 0) { width = iconWidth; height = iconHeight; } else { width = iconWidth * height / iconHeight; } } else if (height < 0) { height = iconHeight * width / iconWidth; } java.awt.Image image = icon.getImage(); java.awt.image.BufferedImage bi = new java.awt.image.BufferedImage(width, height, java.awt.image.BufferedImage.TYPE_INT_RGB); java.awt.Graphics2D g2d = bi.createGraphics(); g2d.setRenderingHint(java.awt.RenderingHints.KEY_INTERPOLATION, java.awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR); g2d.drawImage(image, 0, 0, null); g2d.dispose(); javax.swing.ImageIcon iImage = new javax.swing.ImageIcon(bi); return iImage; } Any ideas? Thank you. Nitin [Message sent by forum member 'nitinchauhan' (nitinchauhan)] http://forums.java.net/jive/thread.jspa?messageID=138932 =========================================================================== 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".