mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Merge pull request #1107 from pnngocdoan/fix-mask
Add error check for pixelDensity in mask()
This commit is contained in:
@@ -866,6 +866,14 @@ public class PImage implements PConstants, Cloneable {
|
||||
*/
|
||||
public void mask(PImage img) {
|
||||
img.loadPixels();
|
||||
if (this.pixelWidth != img.pixelWidth || this.pixelHeight != img.pixelHeight) {
|
||||
if (this.pixelDensity != img.pixelDensity) {
|
||||
throw new IllegalArgumentException("mask() requires the mask image to have the same pixel size after adjusting for pixelDensity.");
|
||||
}
|
||||
else if (this.width != img.width || this.height != img.height) {
|
||||
throw new IllegalArgumentException("mask() requires the mask image to have the same width and height.");
|
||||
}
|
||||
}
|
||||
mask(img.pixels);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user