List of usage examples for java.awt.image BufferedImage flush
public void flush()
From source file:Capture.java
public static void main(String[] args) { JFrame capture = new JFrame(); capture.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Toolkit kit = Toolkit.getDefaultToolkit(); final Dimension d = kit.getScreenSize(); capture.setSize(d);//from w w w . j ava 2 s .c o m Rectangle rect = new Rectangle(d); try { Robot robot = new Robot(); final BufferedImage image = robot.createScreenCapture(rect); image.flush(); JPanel panel = new JPanel() { public void paintComponent(Graphics g) { g.drawImage(image, 0, 0, d.width, d.height, this); } }; panel.setOpaque(false); panel.prepareImage(image, panel); panel.repaint(); capture.getContentPane().add(panel); } catch (Exception e) { e.printStackTrace(); } capture.setVisible(true); }
From source file:Main.java
public static void main(String[] args) throws Exception { BufferedImage bi = new BufferedImage(100, 100, BufferedImage.TYPE_USHORT_GRAY); Graphics2D g2d = bi.createGraphics(); g2d.setColor(Color.WHITE);/*from www.jav a 2 s . co m*/ g2d.fillRect(0, 0, 100, 100); g2d.setColor(new Color(255, 123, 0)); g2d.drawLine(100, 100, 1, 1); g2d.dispose(); BufferedImage scaledImage = new BufferedImage(1000, 1000, BufferedImage.TYPE_USHORT_GRAY); Graphics2D graphics2D = scaledImage.createGraphics(); graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); graphics2D.drawImage(bi, 0, 0, 1000, 1000, null); graphics2D.dispose(); ImageIO.write(scaledImage, "png", new File("c:/Java_Dev/Test.png")); bi.flush(); }
From source file:com.buddycloud.mediaserver.business.util.ImageUtils.java
public static BufferedImage createImagePreview(File image, int size) throws IOException { final BufferedImage img = ImageIO.read(image); final BufferedImage thumbnail = Scalr.resize(img, Method.ULTRA_QUALITY, size); img.flush(); return thumbnail; }
From source file:com.buddycloud.mediaserver.business.util.ImageUtils.java
public static BufferedImage createImagePreview(BufferedImage img, int width, int height) { final BufferedImage thumbnail = Scalr.resize(img, Method.ULTRA_QUALITY, width, height); img.flush(); return thumbnail; }
From source file:com.buddycloud.mediaserver.business.util.ImageUtils.java
public static BufferedImage createImagePreview(File image, int width, int height) throws IOException { final BufferedImage img = ImageIO.read(image); final BufferedImage thumbnail = Scalr.resize(img, Method.ULTRA_QUALITY, width, height); img.flush(); return thumbnail; }
From source file:pt.ist.expenditureTrackingSystem.presentationTier.actions.statistics.ChartGenerator.java
protected static byte[] createBarChartImage(final ChartData chartData) throws RuntimeException, IOException { final JFreeChart chart = createBarChart(chartData.getDataset(), chartData.getTitle()); final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); final BufferedImage bufferedImage = chart.createBufferedImage(625, 475); ImageIO.write(bufferedImage, "png", outputStream); bufferedImage.flush(); outputStream.close();// w ww . j av a 2s. c o m return outputStream.toByteArray(); }
From source file:pt.ist.expenditureTrackingSystem.presentationTier.actions.statistics.ChartGenerator.java
protected static byte[] createBarChartImage(final CategoryDataset categoryDataset, final String title) throws RuntimeException, IOException { final JFreeChart chart = createBarChart(categoryDataset, title); final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); final BufferedImage bufferedImage = chart.createBufferedImage(625, 475); ImageIO.write(bufferedImage, "png", outputStream); bufferedImage.flush(); outputStream.close();/*from www . j av a 2s. c om*/ return outputStream.toByteArray(); }
From source file:org.web4thejob.web.util.MediaUtil.java
public static BufferedImage createThumbnail(BufferedImage img) { if (img.getHeight() <= THUMBNAIL_HEIGHT) return img; BufferedImage resizedImage = resize(img, Method.AUTOMATIC, Mode.FIT_TO_HEIGHT, THUMBNAIL_HEIGHT); img.flush(); return resizedImage; }
From source file:Utils.java
public static BufferedImage createGradientMask(int width, int height, int orientation) { // algorithm derived from Romain Guy's blog BufferedImage gradient = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D g = gradient.createGraphics(); GradientPaint paint = new GradientPaint(0.0f, 0.0f, new Color(1.0f, 1.0f, 1.0f, 1.0f), orientation == SwingConstants.HORIZONTAL ? width : 0.0f, orientation == SwingConstants.VERTICAL ? height : 0.0f, new Color(1.0f, 1.0f, 1.0f, 0.0f)); g.setPaint(paint);// ww w. jav a 2s . c o m g.fill(new Rectangle2D.Double(0, 0, width, height)); g.dispose(); gradient.flush(); return gradient; }
From source file:net.ftb.util.DownloadUtils.java
/** * Used to download pack images from repo to hard disk * @param file Name of the image//from www . j ava 2s. c om * @param location Image save location in hard disk * @param type image type to use when saving */ public static void saveImage(String file, File location, String type) { // stupid code: tries to find working server twice. if (DownloadUtils.staticFileExists(file)) { try { URL url_ = new URL(DownloadUtils.getStaticCreeperhostLink(file)); BufferedImage tempImg = ImageIO.read(url_); ImageIO.write(tempImg, type, new File(location, file)); tempImg.flush(); } catch (IOException e) { Logger.logWarn("image download/save failed", e); new File(location, file).delete(); } } }