use of java.awt.image.PixelGrabber in project entando-core by entando.
the class PNGImageResizer method hasAlpha.
protected boolean hasAlpha(Image image) throws ApsSystemException {
// If buffered image, the color model is readily available
if (image instanceof BufferedImage) {
BufferedImage bimage = (BufferedImage) image;
return bimage.getColorModel().hasAlpha();
}
// Use a pixel grabber to retrieve the image's color model;
// grabbing a single pixel is usually sufficient
PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false);
try {
pg.grabPixels();
} catch (InterruptedException e) {
throw new ApsSystemException("Error grabbing a single pixel", e);
}
// Get the image's color model
ColorModel cm = pg.getColorModel();
return cm.hasAlpha();
}
use of java.awt.image.PixelGrabber in project Lucee by lucee.
the class Image method hasAlpha.
/**
* This method returns true if the specified image has transparent pixels
* @param image
* @return
*/
public static boolean hasAlpha(java.awt.Image image) {
// If buffered image, the color model is readily available
if (image instanceof BufferedImage) {
BufferedImage bimage = (BufferedImage) image;
return bimage.getColorModel().hasAlpha();
}
// Use a pixel grabber to retrieve the image's color model;
// grabbing a single pixel is usually sufficient
PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false);
try {
pg.grabPixels();
} catch (InterruptedException e) {
}
// Get the image's color model
ColorModel cm = pg.getColorModel();
return cm.hasAlpha();
}
use of java.awt.image.PixelGrabber in project vcell by virtualcell.
the class TextImage method refreshVerticalImage.
/**
* This method was created by a SmartGuide.
* @param g java.awt.Graphics
*/
private void refreshVerticalImage(Component component) {
refreshImage(component);
if (verticalImage != null) {
return;
}
//
// copy image from horizontal image (image) to vertical image (verticalImage) (rotate 90 degrees)
//
int[] pixels = new int[width * height];
PixelGrabber pg = new PixelGrabber(image, 0, 0, width, height, pixels, 0, width);
try {
pg.grabPixels();
} catch (InterruptedException e) {
throw new RuntimeException("interrupted waiting for pixels!");
}
if ((pg.getStatus() & ImageObserver.ABORT) != 0) {
throw new RuntimeException("image fetch aborted or errored");
}
int[] transposedPixels = new int[width * height];
int transposed_i = 0;
int transposed_j = 0;
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
transposed_i = j;
transposed_j = width - 1 - i;
int newPixel = pixels[j * width + i];
//
if (newPixel != Color.black.getRGB()) {
newPixel = 0x00000000;
}
// pixels[j * width + i];
transposedPixels[transposed_i + transposed_j * height] = newPixel;
}
}
java.awt.image.MemoryImageSource memoryImageSource = new java.awt.image.MemoryImageSource(height, width, transposedPixels, 0, height);
Image tempImage = component.createImage(memoryImageSource);
int verticalWidth = -1;
int verticalHeight = -1;
while (verticalWidth == -1 || verticalHeight == -1) {
verticalWidth = tempImage.getWidth(component);
verticalHeight = tempImage.getHeight(component);
}
verticalImage = tempImage;
}
use of java.awt.image.PixelGrabber in project mlib by myshzzx.
the class JavaSIFT method convert.
private FloatArray2D convert(java.awt.Image img) {
FloatArray2D image;
PixelGrabber grabber = new PixelGrabber(img, 0, 0, -1, -1, true);
try {
grabber.grabPixels();
} catch (Exception e) {
throw new RuntimeException(e);
}
int[] data = (int[]) grabber.getPixels();
image = new FloatArray2D(grabber.getWidth(), grabber.getHeight());
for (int d = 0; d < data.length; d++) image.data[d] = normTo1(RGB2Grey(data[d]));
return image;
}
use of java.awt.image.PixelGrabber in project mlib by myshzzx.
the class FeatureCache method getImageData.
private int[] getImageData(Image img) {
PixelGrabber grabber = new PixelGrabber(img, 0, 0, -1, -1, true);
try {
grabber.grabPixels();
} catch (Exception e) {
throw new RuntimeException(e);
}
int[] data = (int[]) grabber.getPixels();
return data;
}
Aggregations