Can't render PGraphics object using image() within a PDF #4473

Closed
alignedleft opened this Issue May 13, 2016 · 3 comments

Comments

Projects
None yet
3 participants
@alignedleft
Member

alignedleft commented May 13, 2016

@almoce logged this issue here: processing/processing-docs#431

If you run this example, an error is triggered:

ClassCastException sun.java2d.SunGraphics2D cannot be cast to java.awt.Image

Is this a bug? Shouldn't you be able to use image() to display/output a PGraphics object, even within the PDF renderer? (Or perhaps this isn't supported for PDFs.)

import processing.pdf.*;

PGraphics pg;

void setup() {
  size(100, 100, PDF, "output.pdf");
  pg = createGraphics(100, 100);
  noLoop();
}

void draw() {
  pg.beginDraw();
  pg.background(100);
  pg.stroke(255);
  pg.line(0, 0, 100, 100);
  pg.endDraw();

  image(pg, 0, 0);
}
@benfry

This comment has been minimized.

Show comment
Hide comment
@benfry

benfry May 14, 2016

Member

That's really odd. It should work, and the error it's throwing is strange as well. Will have to look into it.

Member

benfry commented May 14, 2016

That's really odd. It should work, and the error it's throwing is strange as well. Will have to look into it.

@lwaxman

This comment has been minimized.

Show comment
Hide comment
@lwaxman

lwaxman Jun 20, 2016

Hey Ben & Scott, just noting I'm having this issue as well. Trying to find a work-around, but not getting anywhere. Anyway, thanks for all your hard work.

lwaxman commented Jun 20, 2016

Hey Ben & Scott, just noting I'm having this issue as well. Trying to find a work-around, but not getting anywhere. Anyway, thanks for all your hard work.

@benfry benfry closed this in f8d77c8 Aug 13, 2016

@benfry

This comment has been minimized.

Show comment
Hide comment
@benfry

benfry Aug 13, 2016

Member

Found and fixed for 3.2.

Member

benfry commented Aug 13, 2016

Found and fixed for 3.2.

benfry added a commit that referenced this issue Aug 13, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment