This commit is contained in:
benfry
2010-02-26 20:00:58 +00:00
parent 4fb9821a33
commit 9e0170c2bc
2 changed files with 4 additions and 159 deletions
@@ -924,127 +924,7 @@ public class PGraphicsAndroid2D extends PGraphics {
}
// class ImageCache {
// PImage source;
// boolean tinted;
// int tintedColor;
// int tintedPixels[]; // one row of tinted pixels
// BufferedImage image;
//
// public ImageCache(PImage source) {
// this.source = source;
// // even if RGB, set the image type to ARGB, because the
// // image may have an alpha value for its tint().
//// int type = BufferedImage.TYPE_INT_ARGB;
// //System.out.println("making new buffered image");
//// image = new BufferedImage(source.width, source.height, type);
// }
//
// /**
// * Update the pixels of the cache image. Already determined that the tint
// * has changed, or the pixels have changed, so should just go through
// * with the update without further checks.
// */
// public void update(boolean tint, int tintColor) {
// int bufferType = BufferedImage.TYPE_INT_ARGB;
// boolean opaque = (tintColor & 0xFF000000) == 0xFF000000;
// if (source.format == RGB) {
// if (!tint || (tint && opaque)) {
// bufferType = BufferedImage.TYPE_INT_RGB;
// }
// }
// boolean wrongType = (image != null) && (image.getType() != bufferType);
// if ((image == null) || wrongType) {
// image = new BufferedImage(source.width, source.height, bufferType);
// }
//
// WritableRaster wr = image.getRaster();
// if (tint) {
// if (tintedPixels == null || tintedPixels.length != source.width) {
// tintedPixels = new int[source.width];
// }
// int a2 = (tintColor >> 24) & 0xff;
// int r2 = (tintColor >> 16) & 0xff;
// int g2 = (tintColor >> 8) & 0xff;
// int b2 = (tintColor) & 0xff;
//
// if (bufferType == BufferedImage.TYPE_INT_RGB) {
// //int alpha = tintColor & 0xFF000000;
// int index = 0;
// for (int y = 0; y < source.height; y++) {
// for (int x = 0; x < source.width; x++) {
// int argb1 = source.pixels[index++];
// int r1 = (argb1 >> 16) & 0xff;
// int g1 = (argb1 >> 8) & 0xff;
// int b1 = (argb1) & 0xff;
//
// tintedPixels[x] = //0xFF000000 |
// (((r2 * r1) & 0xff00) << 8) |
// ((g2 * g1) & 0xff00) |
// (((b2 * b1) & 0xff00) >> 8);
// }
// wr.setDataElements(0, y, source.width, 1, tintedPixels);
// }
// // could this be any slower?
//// float[] scales = { tintR, tintG, tintB };
//// float[] offsets = new float[3];
//// RescaleOp op = new RescaleOp(scales, offsets, null);
//// op.filter(image, image);
//
// } else if (bufferType == BufferedImage.TYPE_INT_ARGB) {
// int index = 0;
// for (int y = 0; y < source.height; y++) {
// if (source.format == RGB) {
// int alpha = tintColor & 0xFF000000;
// for (int x = 0; x < source.width; x++) {
// int argb1 = source.pixels[index++];
// int r1 = (argb1 >> 16) & 0xff;
// int g1 = (argb1 >> 8) & 0xff;
// int b1 = (argb1) & 0xff;
// tintedPixels[x] = alpha |
// (((r2 * r1) & 0xff00) << 8) |
// ((g2 * g1) & 0xff00) |
// (((b2 * b1) & 0xff00) >> 8);
// }
// } else if (source.format == ARGB) {
// for (int x = 0; x < source.width; x++) {
// int argb1 = source.pixels[index++];
// int a1 = (argb1 >> 24) & 0xff;
// int r1 = (argb1 >> 16) & 0xff;
// int g1 = (argb1 >> 8) & 0xff;
// int b1 = (argb1) & 0xff;
// tintedPixels[x] =
// (((a2 * a1) & 0xff00) << 16) |
// (((r2 * r1) & 0xff00) << 8) |
// ((g2 * g1) & 0xff00) |
// (((b2 * b1) & 0xff00) >> 8);
// }
// } else if (source.format == ALPHA) {
// int lower = tintColor & 0xFFFFFF;
// for (int x = 0; x < source.width; x++) {
// int a1 = source.pixels[index++];
// tintedPixels[x] =
// (((a2 * a1) & 0xff00) << 16) | lower;
// }
// }
// wr.setDataElements(0, y, source.width, 1, tintedPixels);
// }
// // Not sure why ARGB images take the scales in this order...
//// float[] scales = { tintR, tintG, tintB, tintA };
//// float[] offsets = new float[4];
//// RescaleOp op = new RescaleOp(scales, offsets, null);
//// op.filter(image, image);
// }
// } else {
// wr.setDataElements(0, 0, source.width, source.height, source.pixels);
// }
// this.tinted = tint;
// this.tintedColor = tintColor;
// }
// }
//////////////////////////////////////////////////////////////
// SHAPE
+3 -38
View File
@@ -120,15 +120,6 @@ public class PImage implements PConstants, Cloneable {
*/
public PImage(int width, int height) {
init(width, height, RGB);
// toxi: is it maybe better to init the image with max alpha enabled?
//for(int i=0; i<pixels.length; i++) pixels[i]=0xffffffff;
// fry: i'm opting for the full transparent image, which is how
// photoshop works, and our audience oughta be familiar with.
// also, i want to avoid having to set all those pixels since
// in java it's super slow, and most using this fxn will be
// setting all the pixels anyway.
// toxi: agreed and same reasons why i left it out ;)
}
@@ -174,35 +165,9 @@ public class PImage implements PConstants, Cloneable {
/**
* Construct a new PImage from a java.awt.Image. This constructor assumes
* that you've done the work of making sure a MediaTracker has been used
* to fully download the data and that the img is valid.
* Construct a new PImage from an Android bitmap. The pixels[] array is not
* initialized, nor is data copied to it, until loadPixels() is called.
*/
/*
public PImage(java.awt.Image img) {
if (img instanceof BufferedImage) {
BufferedImage bi = (BufferedImage) img;
width = bi.getWidth();
height = bi.getHeight();
pixels = new int[width * height];
WritableRaster raster = bi.getRaster();
raster.getDataElements(0, 0, width, height, pixels);
} else { // go the old school java 1.0 route
width = img.getWidth(null);
height = img.getHeight(null);
pixels = new int[width * height];
PixelGrabber pg =
new PixelGrabber(img, 0, 0, width, height, pixels, 0, width);
try {
pg.grabPixels();
} catch (InterruptedException e) { }
}
format = RGB;
// cache = null;
}
*/
public PImage(Bitmap image) {
this.bitmap = image;
this.width = image.getWidth();
@@ -224,7 +189,7 @@ public class PImage implements PConstants, Cloneable {
// wr.setDataElements(0, 0, width, height, pixels);
// return image;
// }
public Bitmap getImage() {
public Bitmap getBitmap() {
return bitmap;
}