Search in sources :

Example 86 with BufferedImage

use of java.awt.image.BufferedImage in project javatari by ppeccin.

the class SwingHelper method asCompatibleImage.

public static BufferedImage asCompatibleImage(Image img) {
    BufferedImage ret = defaultScreenDeviceConfiguration().createCompatibleImage(img.getWidth(null), img.getHeight(null));
    Graphics2D gc = ret.createGraphics();
    gc.drawImage(img, 0, 0, null);
    gc.dispose();
    return ret;
}
Also used : BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D)

Example 87 with BufferedImage

use of java.awt.image.BufferedImage in project javatari by ppeccin.

the class SwingHelper method asCompatibleImage.

public static BufferedImage asCompatibleImage(Image img, int transparency) {
    BufferedImage ret = defaultScreenDeviceConfiguration().createCompatibleImage(img.getWidth(null), img.getHeight(null), transparency);
    Graphics2D gc = ret.createGraphics();
    gc.setComposite(AlphaComposite.Src);
    gc.drawImage(img, 0, 0, null);
    gc.dispose();
    return ret;
}
Also used : BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D)

Example 88 with BufferedImage

use of java.awt.image.BufferedImage in project jforum2 by rafaelsteil.

the class Captcha method writeCaptchaImage.

public void writeCaptchaImage() {
    BufferedImage image = SessionFacade.getUserSession().getCaptchaImage();
    if (image == null) {
        return;
    }
    OutputStream outputStream = null;
    try {
        outputStream = JForumExecutionContext.getResponse().getOutputStream();
        ImageIO.write(image, "jpg", outputStream);
    } catch (IOException ex) {
        logger.error(ex);
    } finally {
        if (outputStream != null) {
            try {
                outputStream.close();
            } catch (IOException ex) {
            }
        }
    }
}
Also used : OutputStream(java.io.OutputStream) IOException(java.io.IOException) BufferedImage(java.awt.image.BufferedImage)

Example 89 with BufferedImage

use of java.awt.image.BufferedImage in project jforum2 by rafaelsteil.

the class AttachmentCommon method createSaveThumb.

private void createSaveThumb(String path) {
    try {
        BufferedImage image = ImageUtils.resizeImage(path, ImageUtils.IMAGE_JPEG, SystemGlobals.getIntValue(ConfigKeys.ATTACHMENTS_IMAGES_MAX_THUMB_W), SystemGlobals.getIntValue(ConfigKeys.ATTACHMENTS_IMAGES_MAX_THUMB_H));
        ImageUtils.saveImage(image, path + "_thumb", ImageUtils.IMAGE_JPEG);
    } catch (Exception e) {
        logger.error(e.toString(), e);
    }
}
Also used : BufferedImage(java.awt.image.BufferedImage) BadExtensionException(net.jforum.exceptions.BadExtensionException) AttachmentException(net.jforum.exceptions.AttachmentException) AttachmentSizeTooBigException(net.jforum.exceptions.AttachmentSizeTooBigException)

Example 90 with BufferedImage

use of java.awt.image.BufferedImage in project hid-serial by rayshobby.

the class StyledString method getParagraghSpacer.

/**
	 * Create a graphic image character to simulate paragraph breaks
	 * 
	 * @param ww
	 * @return a blank image to manage paragraph ends.
	 */
private ImageGraphicAttribute getParagraghSpacer(int ww) {
    if (ww == Integer.MAX_VALUE)
        ww = 1;
    BufferedImage img = new BufferedImage(ww, 10, BufferedImage.TYPE_INT_ARGB);
    Graphics g = img.getGraphics();
    g.setColor(new Color(255, 255, 255, 0));
    g.fillRect(0, 0, img.getWidth(), img.getHeight());
    return new ImageGraphicAttribute(img, GraphicAttribute.TOP_ALIGNMENT);
}
Also used : Graphics(java.awt.Graphics) ImageGraphicAttribute(java.awt.font.ImageGraphicAttribute) Color(java.awt.Color) BufferedImage(java.awt.image.BufferedImage)

Aggregations

BufferedImage (java.awt.image.BufferedImage)1364 Graphics2D (java.awt.Graphics2D)335 IOException (java.io.IOException)186 File (java.io.File)164 Graphics (java.awt.Graphics)91 ByteArrayInputStream (java.io.ByteArrayInputStream)80 Color (java.awt.Color)74 ByteArrayOutputStream (java.io.ByteArrayOutputStream)74 Test (org.junit.Test)72 WritableRaster (java.awt.image.WritableRaster)65 Rectangle (java.awt.Rectangle)60 AffineTransform (java.awt.geom.AffineTransform)52 LayoutlibDelegate (com.android.tools.layoutlib.annotations.LayoutlibDelegate)46 InputStream (java.io.InputStream)46 Image (java.awt.Image)43 Dimension (java.awt.Dimension)42 ImageWriter (javax.imageio.ImageWriter)40 Point (java.awt.Point)36 ArrayList (java.util.ArrayList)36 ImageIcon (javax.swing.ImageIcon)35