/** * Tries to use H/W-accelerated code for an image for display purposes. * Note that transparent parts of the image might be replaced by solid * color. Additional image information not used by the current diplay * hardware may be discarded, like extra bith depth etc. * * @param pImage any {@code Image} * @return a {@code BufferedImage} */ public static BufferedImage accelerate(Image pImage) { return accelerate(pImage, null, DEFAULT_CONFIGURATION); }
/** * Tries to use H/W-accelerated code for an image for display purposes. * Note that transparent parts of the image might be replaced by solid * color. Additional image information not used by the current diplay * hardware may be discarded, like extra bith depth etc. * * @param pImage any {@code Image} * @param pConfiguration the {@code GraphicsConfiguration} to accelerate * for * * @return a {@code BufferedImage} */ public static BufferedImage accelerate(Image pImage, GraphicsConfiguration pConfiguration) { return accelerate(pImage, null, pConfiguration); }
public void run() { JFrame frame = new JFrame(pTitle); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationByPlatform(true); JPanel pane = new JPanel(new BorderLayout()); GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration(); BufferedImageIcon icon = new BufferedImageIcon(ImageUtil.accelerate(pImage, gc)); JScrollPane scroll = new JScrollPane(new JLabel(icon)); scroll.setBorder(null); pane.add(scroll); frame.setContentPane(pane); frame.pack(); frame.setVisible(true); } });
image = ImageUtil.accelerate(image); layer = ImageUtil.accelerate(layer);
/** * Tries to use H/W-accelerated code for an image for display purposes. * Note that transparent parts of the image might be replaced by solid * color. Additional image information not used by the current diplay * hardware may be discarded, like extra bith depth etc. * * @param pImage any {@code Image} * @return a {@code BufferedImage} */ public static BufferedImage accelerate(Image pImage) { return accelerate(pImage, null, DEFAULT_CONFIGURATION); }
/** * Tries to use H/W-accellerated code for an image for display purposes. * Note that transparent parts of the image might be replaced by solid * color. Additional image information not used by the current diplay * hardware may be discarded, like extra bith depth etc. * * @param pImage any {@code Image} * @return a {@code BufferedImage} */ public static BufferedImage accelerate(Image pImage) { return accelerate(pImage, null, DEFAULT_CONFIGURATION); }
/** * Tries to use H/W-accelerated code for an image for display purposes. * Note that transparent parts of the image might be replaced by solid * color. Additional image information not used by the current diplay * hardware may be discarded, like extra bith depth etc. * * @param pImage any {@code Image} * @param pConfiguration the {@code GraphicsConfiguration} to accelerate * for * * @return a {@code BufferedImage} */ public static BufferedImage accelerate(Image pImage, GraphicsConfiguration pConfiguration) { return accelerate(pImage, null, pConfiguration); }
/** * Tries to use H/W-accellerated code for an image for display purposes. * Note that transparent parts of the image might be replaced by solid * color. Additional image information not used by the current diplay * hardware may be discarded, like extra bith depth etc. * * @param pImage any {@code Image} * @param pConfiguration the {@code GraphicsConfiguration} to accelerate * for * * @return a {@code BufferedImage} */ public static BufferedImage accelerate(Image pImage, GraphicsConfiguration pConfiguration) { return accelerate(pImage, null, pConfiguration); }
public void run() { JFrame frame = new JFrame(pTitle); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationByPlatform(true); JPanel pane = new JPanel(new BorderLayout()); GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration(); BufferedImageIcon icon = new BufferedImageIcon(ImageUtil.accelerate(pImage, gc)); JScrollPane scroll = new JScrollPane(new JLabel(icon)); scroll.setBorder(null); pane.add(scroll); frame.setContentPane(pane); frame.pack(); frame.setVisible(true); } });
public void run() { JFrame frame = new JFrame(pTitle); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationByPlatform(true); JPanel pane = new JPanel(new BorderLayout()); GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration(); BufferedImageIcon icon = new BufferedImageIcon(ImageUtil.accelerate(pImage, gc)); JScrollPane scroll = new JScrollPane(new JLabel(icon)); scroll.setBorder(null); pane.add(scroll); frame.setContentPane(pane); frame.pack(); frame.setVisible(true); } });
private BufferedImage box(final BufferedImage pImage, final int pMaxDimension) { // TODO: ImageUtil.toRGB method? ColorConvertOp MUCH faster than ImageUtil.toBuffered(img, type) BufferedImage image = pImage; if (image.getType() == 0) { try { ColorConvertOp op = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_sRGB), null); image = op.filter(image, new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_4BYTE_ABGR_PRE)); } catch (Exception e) { e.printStackTrace(); image = ImageUtil.accelerate(image); } } if (image.getWidth() > pMaxDimension || image.getHeight() > pMaxDimension) { int w, h; if (image.getWidth() > image.getHeight()) { w = pMaxDimension; h = (int) Math.round(w / (image.getWidth() / (double) image.getHeight())); } else { h = pMaxDimension; w = (int) Math.round(h * (image.getWidth() / (double) image.getHeight())); } return ImageUtil.createResampled(image, w, h, Image.SCALE_DEFAULT); } return image; } }
image = ImageUtil.accelerate(image); layer = ImageUtil.accelerate(layer);