use of java.awt.image.PixelGrabber in project metro-jax-ws by eclipse-ee4j.
the class AttachmentHelper method handlePixels.
private static Iterator handlePixels(Image img, Rectangle rect) {
int x = rect.x;
int y = rect.y;
int w = rect.width;
int h = rect.height;
int[] pixels = new int[w * h];
PixelGrabber pg = new PixelGrabber(img, x, y, w, h, pixels, 0, w);
try {
pg.grabPixels();
} catch (InterruptedException e) {
System.err.println("interrupted waiting for pixels!");
return null;
}
if ((pg.getStatus() & ImageObserver.ABORT) != 0) {
System.err.println("image fetch aborted or errored");
return null;
}
ArrayList tmpList = new ArrayList();
for (int j = 0; j < h; j++) {
for (int i = 0; i < w; i++) {
tmpList.add(handleSinglePixel(x + i, y + j, pixels[j * w + i]));
}
}
return tmpList.iterator();
}
use of java.awt.image.PixelGrabber in project metro-jax-ws by eclipse-ee4j.
the class AttachmentHelper method handlePixels.
private static Iterator handlePixels(Image img, Rectangle rect) {
int x = rect.x;
int y = rect.y;
int w = rect.width;
int h = rect.height;
int[] pixels = new int[w * h];
PixelGrabber pg = new PixelGrabber(img, x, y, w, h, pixels, 0, w);
try {
pg.grabPixels();
} catch (InterruptedException e) {
System.err.println("interrupted waiting for pixels!");
return null;
}
if ((pg.getStatus() & ImageObserver.ABORT) != 0) {
System.err.println("image fetch aborted or errored");
return null;
}
ArrayList tmpList = new ArrayList();
for (int j = 0; j < h; j++) {
for (int i = 0; i < w; i++) {
tmpList.add(handleSinglePixel(x + i, y + j, pixels[j * w + i]));
}
}
return tmpList.iterator();
}
use of java.awt.image.PixelGrabber in project openosrs-dev by blurite.
the class ImageUtil method getImageSpritePixels.
/**
* Converts the buffered image into a sprite image and returns it
* @param image The image to be converted
* @param client Current client instance
* @return The buffered image as a sprite image
*/
public static SpritePixels getImageSpritePixels(BufferedImage image, Client client) {
int[] pixels = new int[image.getWidth() * image.getHeight()];
try {
PixelGrabber g = new PixelGrabber(image, 0, 0, image.getWidth(), image.getHeight(), pixels, 0, image.getWidth());
g.setColorModel(new DirectColorModel(32, 0xff0000, 0xff00, 0xff, 0xff000000));
g.grabPixels();
// check for == 0, not actual transparency
for (int i = 0; i < pixels.length; i++) {
if ((pixels[i] & 0xFF000000) == 0) {
pixels[i] = 0;
}
}
} catch (InterruptedException ex) {
log.debug("PixelGrabber was interrupted: ", ex);
}
return client.createSpritePixels(pixels, image.getWidth(), image.getHeight());
}
use of java.awt.image.PixelGrabber in project unethicalite by unethicalite.
the class class125 method method2743.
@ObfuscatedName("c")
@ObfuscatedSignature(descriptor = "([BI)Lpt;", garbageValue = "-2047697021")
public static final SpritePixels method2743(byte[] var0) {
BufferedImage var1 = null;
try {
var1 = ImageIO.read(new ByteArrayInputStream(var0));
int var2 = var1.getWidth();
int var3 = var1.getHeight();
int[] var4 = new int[var3 * var2];
PixelGrabber var5 = new PixelGrabber(var1, 0, 0, var2, var3, var4, 0, var2);
var5.grabPixels();
return new SpritePixels(var4, var2, var3);
} catch (IOException var7) {
} catch (InterruptedException var8) {
}
return new SpritePixels(0, 0);
}
use of java.awt.image.PixelGrabber in project mars-sim by mars-sim.
the class PerformanceTest method pixelGrabber.
public static int[] pixelGrabber(Image image) {
// image.getWidth();
int W = 300;
// image.getHeight();
int H = 150;
int[] mapPixels = new int[W * H];
PixelGrabber grabber = new PixelGrabber(image, 0, 0, W, H, mapPixels, 0, W);
try {
grabber.grabPixels();
} catch (InterruptedException e) {
System.out.println("grabber error");
}
if ((grabber.status() & ImageObserver.ABORT) != 0)
System.out.println("grabber error");
return mapPixels;
}
Aggregations