Search in sources :

Example 11 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 12 with BufferedImage

use of java.awt.image.BufferedImage in project darkFunction-Editor by darkFunction.

the class SpriteImageController method addSpriteButtonActionPerformed.

// </editor-fold>//GEN-END:initComponents
private void addSpriteButtonActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_addSpriteButtonActionPerformed
    File[] selectedFiles = this.showSetImageChooser();
    if (selectedFiles != null) {
        CustomNode parentNode = (CustomNode) nameTree.getSelectedNodeDir();
        if (parentNode == null)
            parentNode = _lastSelectedDirNode;
        if (parentNode == null)
            parentNode = (CustomNode) nameTree.getModel().getRoot();
        ArrayList<GraphicObject> graphicList = new ArrayList();
        for (int i = 0; i < selectedFiles.length; ++i) {
            try {
                BufferedImage bufferedImage = ImageIO.read(selectedFiles[i]);
                SpriteGraphic graphic = new SpriteGraphic(bufferedImage, new java.awt.Point(0, 0), new Rectangle(0, 0, bufferedImage.getWidth(), bufferedImage.getHeight()));
                graphicList.add(graphic);
            } catch (IOException e) {
                JOptionPane.showMessageDialog(this, "Could not import " + selectedFiles[i].getName(), "Image not added", JOptionPane.ERROR_MESSAGE);
            }
        }
        cmdManager.execute(new AddGraphicListToSheetCommand(nameTree, parentNode, viewPanel, graphicList));
    }
}
Also used : ArrayList(java.util.ArrayList) Rectangle(java.awt.Rectangle) IOException(java.io.IOException) BufferedImage(java.awt.image.BufferedImage) File(java.io.File)

Example 13 with BufferedImage

use of java.awt.image.BufferedImage in project android_frameworks_base by ParanoidAndroid.

the class Bitmap_Delegate method createCopy.

/**
     * Creates and returns a copy of a given BufferedImage.
     * <p/>
     * if alpha is different than 255, then it is applied to the alpha channel of each pixel.
     *
     * @param image the image to copy
     * @param imageType the type of the new image
     * @param alpha an optional alpha modifier
     * @return a new BufferedImage
     */
/*package*/
static BufferedImage createCopy(BufferedImage image, int imageType, int alpha) {
    int w = image.getWidth();
    int h = image.getHeight();
    BufferedImage result = new BufferedImage(w, h, imageType);
    int[] argb = new int[w * h];
    image.getRGB(0, 0, image.getWidth(), image.getHeight(), argb, 0, image.getWidth());
    if (alpha != 255) {
        final int length = argb.length;
        for (int i = 0; i < length; i++) {
            int a = (argb[i] >>> 24 * alpha) / 255;
            argb[i] = (a << 24) | (argb[i] & 0x00FFFFFF);
        }
    }
    result.setRGB(0, 0, w, h, argb, 0, w);
    return result;
}
Also used : BufferedImage(java.awt.image.BufferedImage)

Example 14 with BufferedImage

use of java.awt.image.BufferedImage in project android_frameworks_base by ParanoidAndroid.

the class Bitmap_Delegate method nativeCreate.

// ---- native methods ----
@LayoutlibDelegate
static /*package*/
Bitmap nativeCreate(int[] colors, int offset, int stride, int width, int height, int nativeConfig, boolean mutable) {
    int imageType = getBufferedImageType(nativeConfig);
    // create the image
    BufferedImage image = new BufferedImage(width, height, imageType);
    if (colors != null) {
        image.setRGB(0, 0, width, height, colors, offset, stride);
    }
    // create a delegate with the content of the stream.
    Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.nativeToConfig(nativeConfig));
    return createBitmap(delegate, mutable, Bitmap.getDefaultDensity());
}
Also used : BufferedImage(java.awt.image.BufferedImage) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 15 with BufferedImage

use of java.awt.image.BufferedImage in project android_frameworks_base by ParanoidAndroid.

the class Bitmap_Delegate method nativeCopy.

@LayoutlibDelegate
static /*package*/
Bitmap nativeCopy(int srcBitmap, int nativeConfig, boolean isMutable) {
    Bitmap_Delegate srcBmpDelegate = sManager.getDelegate(srcBitmap);
    if (srcBmpDelegate == null) {
        return null;
    }
    BufferedImage srcImage = srcBmpDelegate.getImage();
    int width = srcImage.getWidth();
    int height = srcImage.getHeight();
    int imageType = getBufferedImageType(nativeConfig);
    // create the image
    BufferedImage image = new BufferedImage(width, height, imageType);
    // copy the source image into the image.
    int[] argb = new int[width * height];
    srcImage.getRGB(0, 0, width, height, argb, 0, width);
    image.setRGB(0, 0, width, height, argb, 0, width);
    // create a delegate with the content of the stream.
    Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.nativeToConfig(nativeConfig));
    return createBitmap(delegate, isMutable, Bitmap.getDefaultDensity());
}
Also used : BufferedImage(java.awt.image.BufferedImage) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

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