Skip to content

Commit 161137e

Browse files
committed
update pixels/bitmap
1 parent 24acabb commit 161137e

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

core/src/processing/core/PImage.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,24 @@ public void loadPixels() { // ignore
257257
if (pixels == null || pixels.length != width*height) {
258258
pixels = new int[width*height];
259259
}
260+
260261
if (bitmap != null) {
261-
bitmap.getPixels(pixels, 0, width, 0, 0, width, height);
262+
if (modified) {
263+
// The pixels array has been used to do color manipulations, so
264+
// the bitmap should be updated
265+
if (!bitmap.isMutable()) {
266+
// create a mutable version of this bitmap
267+
bitmap = bitmap.copy(Config.ARGB_8888, true);
268+
}
269+
bitmap.setPixels(pixels, 0, width, mx1, my1, mx2 - mx1, my2 - my1);
270+
modified = false;
271+
} else {
272+
// Get wherever it is in the bitmap right now, we assume is the most
273+
// up-to-date version of the image.
274+
bitmap.getPixels(pixels, 0, width, 0, 0, width, height);
275+
}
262276
}
277+
263278
setLoaded();
264279
}
265280

0 commit comments

Comments
 (0)