Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resizing window outside setup causes NPE when saving surface pixels #162

Closed
processing-bot opened this issue Jan 21, 2021 · 2 comments
Closed

Comments

@processing-bot
Copy link
Collaborator

Created by: PixelCatalyst

Description

After using surface.setSize() to resize window outside setup() invoking save() causes NullPointerException. Also, image of the window frame is saved under chosen filename but it has 0 bytes and .tif extension after .jpg or .png. This only happens when non-default renderer is enabled - P2D, P3D or OPENGL.

Code to replicate:

void setup() {
 size(500, 500, P3D); //can also be P2D or OPENGL
}
void draw() {
 background(255);
 
 surface.setSize(400, 400);
 save("test.png"); //NPE thrown here
 exit();
}

Stacktrace:

java.lang.NullPointerExceptionjava.lang.NullPointerException at 
java.desktop/java.awt.image.BufferedImage.setRGB(BufferedImage.java:1058) at 
processing.awt.ShimAWT.saveImageIO(ShimAWT.java:374) at processing.awt.ShimAWT.saveImage(ShimAWT.java:334) at 
processing.core.PImage.saveImpl(PImage.java:3349) at 
processing.opengl.PGraphicsOpenGL.saveImpl(PGraphicsOpenGL.java:764) at processing.core.PImage.save(PImage.java:3308) at 
processing.core.PGraphics.save(PGraphics.java:8584) at processing.core.PApplet.save(PApplet.java:3978) at 
szie_surfaceresize.draw(szie_surfaceresize.java:26) at processing.core.PApplet.handleDraw(PApplet.java:2458) at 
processing.opengl.PSurfaceJOGL$DrawListener.display(PSurfaceJOGL.java:950) at 
jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:692) at 
jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:674) at 
jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:443) at 
jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1293) at 
jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147) at 
com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:768) at 
com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:81) at 
com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:453) at 
com.jogamp.opengl.util.FPSAnimator$MainTask.run(FPSAnimator.java:178) at 
java.base/java.util.TimerThread.mainLoop(Timer.java:556) at 
java.base/java.util.TimerThread.run(Timer.java:506)java.io.IOException: image save failed. at 
processing.awt.ShimAWT.saveImageIO(ShimAWT.java:420) at processing.awt.ShimAWT.saveImage(ShimAWT.java:334) at 
processing.core.PImage.saveImpl(PImage.java:3349) at 
processing.opengl.PGraphicsOpenGL.saveImpl(PGraphicsOpenGL.java:764) at processing.core.PImage.save(PImage.java:3308) at 
processing.core.PGraphics.save(PGraphics.java:8584) at processing.core.PApplet.save(PApplet.java:3978) at 
szie_surfaceresize.draw(szie_surfaceresize.java:26) at processing.core.PApplet.handleDraw(PApplet.java:2458) at 
processing.opengl.PSurfaceJOGL$DrawListener.display(PSurfaceJOGL.java:950) at 
jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:692) at 
jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:674) at 
jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:443) at 
jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1293) at 
jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147) at 
com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:768) at 
com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:81) at 
com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:453) at 
com.jogamp.opengl.util.FPSAnimator$MainTask.run(FPSAnimator.java:178) at 
java.base/java.util.TimerThread.mainLoop(Timer.java:556) at 
java.base/java.util.TimerThread.run(Timer.java:506)NullPointerException

Your Environment

  • Processing version: Processing4 built up to commit e96622d
  • Operating System and OS version: Windows 10 build 19042.685
@processing-bot
Copy link
Collaborator Author

Created by: benfry

Thanks for the report. I've tracked down a partial fix for 4.0 beta 5.

Longer-term fix noted here: #387

@processing-bot
Copy link
Collaborator Author

Created by: github-actions[bot]

This issue has been automatically locked. To avoid confusion with reports that have already been resolved, closed issues are automatically locked 30 days after the last comment. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant