Search in sources :

Example 1 with BufferedImage

use of java.awt.image.BufferedImage in project deeplearning4j by deeplearning4j.

the class DrawReconstruction method readjustToData.

public void readjustToData() {
    this.width = data.columns();
    this.height = data.rows();
    img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
}
Also used : BufferedImage(java.awt.image.BufferedImage)

Example 2 with BufferedImage

use of java.awt.image.BufferedImage in project jmonkeyengine by jMonkeyEngine.

the class MipMapGenerator method resizeToPowerOf2.

public static void resizeToPowerOf2(Image image) {
    BufferedImage original = ImageToAwt.convert(image, false, true, 0);
    int potWidth = FastMath.nearestPowerOfTwo(image.getWidth());
    int potHeight = FastMath.nearestPowerOfTwo(image.getHeight());
    int potSize = Math.max(potWidth, potHeight);
    BufferedImage scaled = scaleDown(original, potSize, potSize);
    AWTLoader loader = new AWTLoader();
    Image output = loader.load(scaled, false);
    image.setWidth(potSize);
    image.setHeight(potSize);
    image.setDepth(0);
    image.setData(output.getData(0));
    image.setFormat(output.getFormat());
    image.setMipMapSizes(null);
}
Also used : AWTLoader(com.jme3.texture.plugins.AWTLoader) BufferedImage(java.awt.image.BufferedImage) Image(com.jme3.texture.Image) BufferedImage(java.awt.image.BufferedImage)

Example 3 with BufferedImage

use of java.awt.image.BufferedImage in project jmonkeyengine by jMonkeyEngine.

the class LwjglWindow method imagesToGLFWImages.

/**
     * Convert array of images to array of {@link GLFWImage}.
     */
private GLFWImage[] imagesToGLFWImages(final Object[] images) {
    final GLFWImage[] out = new GLFWImage[images.length];
    for (int i = 0; i < images.length; i++) {
        final BufferedImage image = (BufferedImage) images[i];
        out[i] = imageToGLFWImage(image);
    }
    return out;
}
Also used : GLFWImage(org.lwjgl.glfw.GLFWImage) GLFW.glfwWindowHint(org.lwjgl.glfw.GLFW.glfwWindowHint) BufferedImage(java.awt.image.BufferedImage)

Example 4 with BufferedImage

use of java.awt.image.BufferedImage in project jmonkeyengine by jMonkeyEngine.

the class LwjglWindow method imageToGLFWImage.

/**
     * Convert the {@link BufferedImage} to the {@link GLFWImage}.
     */
private GLFWImage imageToGLFWImage(BufferedImage image) {
    if (image.getType() != BufferedImage.TYPE_INT_ARGB_PRE) {
        final BufferedImage convertedImage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB_PRE);
        final Graphics2D graphics = convertedImage.createGraphics();
        final int targetWidth = image.getWidth();
        final int targetHeight = image.getHeight();
        graphics.drawImage(image, 0, 0, targetWidth, targetHeight, null);
        graphics.dispose();
        image = convertedImage;
    }
    final ByteBuffer buffer = BufferUtils.createByteBuffer(image.getWidth() * image.getHeight() * 4);
    for (int i = 0; i < image.getHeight(); i++) {
        for (int j = 0; j < image.getWidth(); j++) {
            int colorSpace = image.getRGB(j, i);
            buffer.put((byte) ((colorSpace << 8) >> 24));
            buffer.put((byte) ((colorSpace << 16) >> 24));
            buffer.put((byte) ((colorSpace << 24) >> 24));
            buffer.put((byte) (colorSpace >> 24));
        }
    }
    buffer.flip();
    final GLFWImage result = GLFWImage.create();
    result.set(image.getWidth(), image.getHeight(), buffer);
    return result;
}
Also used : GLFWImage(org.lwjgl.glfw.GLFWImage) ByteBuffer(java.nio.ByteBuffer) BufferedImage(java.awt.image.BufferedImage) GLFW.glfwWindowHint(org.lwjgl.glfw.GLFW.glfwWindowHint) Graphics2D(java.awt.Graphics2D)

Example 5 with BufferedImage

use of java.awt.image.BufferedImage in project jmonkeyengine by jMonkeyEngine.

the class LwjglDisplay method imagesToByteBuffers.

private ByteBuffer[] imagesToByteBuffers(Object[] images) {
    ByteBuffer[] out = new ByteBuffer[images.length];
    for (int i = 0; i < images.length; i++) {
        BufferedImage image = (BufferedImage) images[i];
        out[i] = imageToByteBuffer(image);
    }
    return out;
}
Also used : ByteBuffer(java.nio.ByteBuffer) BufferedImage(java.awt.image.BufferedImage)

Aggregations

BufferedImage (java.awt.image.BufferedImage)4235 Graphics2D (java.awt.Graphics2D)795 IOException (java.io.IOException)700 File (java.io.File)622 Test (org.junit.Test)242 Graphics (java.awt.Graphics)238 Color (java.awt.Color)217 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)201 ByteArrayInputStream (java.io.ByteArrayInputStream)187 WritableRaster (java.awt.image.WritableRaster)182 ByteArrayOutputStream (java.io.ByteArrayOutputStream)180 Image (java.awt.Image)155 Point (java.awt.Point)154 InputStream (java.io.InputStream)151 Rectangle (java.awt.Rectangle)149 ArrayList (java.util.ArrayList)141 ImageIcon (javax.swing.ImageIcon)133 AffineTransform (java.awt.geom.AffineTransform)131 FunctionException (lucee.runtime.exp.FunctionException)122 ColorModel (java.awt.image.ColorModel)92