Skip to content

JAVA2D copy is broken (ClassCastException) #624

Closed
@processing-bot

Description

@processing-bot

Created by: clankill3r

OSX 10.15.7
Processing 4.1.1

void setup() {
  size(600, 600, JAVA2D);
  PGraphics pg1 = createGraphics(600, 600, JAVA2D);
  pg1.beginDraw();
  pg1.background(0);
  pg1.endDraw();
  
  PGraphics pg2 = createGraphics(600, 600, JAVA2D);
  pg2.beginDraw();
  pg2.background(255);
  pg2.copy(pg1, 0, 0, width/2, height/2, 0, 0, width/2, height/2);
  pg2.endDraw();
}

In PGraphicsJava2D we have:

@Override
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(),
               dx, dy, dx + dw, dy + dh,
               sx, sy, sx + sw, sy + sh, null);
}

The cast happens there, (but a fix seems to be more complex then changing the cast there).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions