mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
fix class cast by pulling image data separately (resolves #624)
This commit is contained in:
@@ -3007,7 +3007,19 @@ public class PGraphicsJava2D extends PGraphics {
|
||||
public void copy(PImage src,
|
||||
int sx, int sy, int sw, int sh,
|
||||
int dx, int dy, int dw, int dh) {
|
||||
g2.drawImage((Image) src.getNative(),
|
||||
Image nativeImage;
|
||||
if (src instanceof PGraphicsJava2D) {
|
||||
// if it's a Java2D drawing surface, use its backing image
|
||||
nativeImage = ((PGraphicsJava2D) src).image;
|
||||
} else if (src.getNative() instanceof Image) { // may be null
|
||||
// if it's something else that has a java.awt.Image as its native backing
|
||||
nativeImage = (Image) src.getNative();
|
||||
} else {
|
||||
// much slower: grab the pixels with get() and create a native image
|
||||
nativeImage = (Image) src.get(sx, sy, sw, sh).getNative();
|
||||
}
|
||||
|
||||
g2.drawImage(nativeImage,
|
||||
dx, dy, dx + dw, dy + dh,
|
||||
sx, sy, sx + sw, sy + sh, null);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
1290 (4.1.2?)
|
||||
X Fix ClassCastException with copy() and PGraphicsJava2D
|
||||
X https://github.com/processing/processing4/issues/624
|
||||
|
||||
|
||||
_ show an error when calling clear() on the main drawing surface
|
||||
_ https://github.com/processing/processing4/issues/627
|
||||
|
||||
|
||||
Reference in New Issue
Block a user