fix updatePixels() and mask()

This commit is contained in:
benfry
2010-02-27 13:36:43 +00:00
parent 0efc7c15c4
commit 5e075d4cec
2 changed files with 7 additions and 3 deletions

View File

@@ -913,8 +913,7 @@ public class PGraphicsAndroid2D extends PGraphics {
who.format == ARGB, tint ? tintPaint : null);
} else {
// rect.set(x1, y1, x2, y2);
if (who.bitmap == null ||
who.width != who.bitmap.getWidth() ||
if (who.width != who.bitmap.getWidth() ||
who.height != who.bitmap.getHeight()) {
// System.out.println("creating bitmap " + who.format + " " +
// who.width + "x" + who.height);
@@ -925,6 +924,10 @@ public class PGraphicsAndroid2D extends PGraphics {
who.modified = true;
}
if (who.modified) {
//System.out.println("mutable, recycled = " + who.bitmap.isMutable() + ", " + who.bitmap.isRecycled());
if (!who.bitmap.isMutable()) {
who.bitmap = Bitmap.createBitmap(who.width, who.height, Config.ARGB_8888);
}
who.bitmap.setPixels(who.pixels, 0, who.width, 0, 0, who.width, who.height);
who.modified = false;
}

View File

@@ -3,7 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2004-08 Ben Fry and Casey Reas
Copyright (c) 2004-10 Ben Fry and Casey Reas
Copyright (c) 2001-04 Massachusetts Institute of Technology
This library is free software; you can redistribute it and/or
@@ -605,6 +605,7 @@ public class PImage implements PConstants, Cloneable {
* Set alpha channel for an image using another image as the source.
*/
public void mask(PImage alpha) {
alpha.loadPixels();
mask(alpha.pixels);
}