Unable to pass PGraphic to image()

edited September 2016 in Programming Questions

I have a PGraphics object in a costume class, everything works fine, until I try drawing it with the image() function. This returns an ArrayIndexOutOfBoundsException, makes no sense.

Tagged:

Answers

  • Seems to be related to the pixelDensity() setting.

  • Try using image((PImage)x);, where x is the PGraphics object.

  • Are you calling pixelDensity() only once, and immediately after size(), as per the pixelDensity reference page?

    The ArrayIndexOutOfBoundsException usually means that something expected your PGraphics / PImage to be one size, but when it tried reading discovered that it was actually a different size. Adding an explicit size at creation time -- or co-ercing it into another form, like a PImage -- or avoiding the resizing/redensity-ing that caused the mismatch in the first place -- these might be solutions.

    A possibly related open bug:

Sign In or Register to comment.