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