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);
}
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);
}
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;
}
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;
}
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;
}
Aggregations