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
loadImage() requires a PGraphics which makes API harder to use #4501
Comments
Hi @jdf, can you give me a short example? The check is there because we have asynchronous saving and some people like to call If there is a good reason to call |
Sure. Several Python Mode examples were broken by this commit, but the general form is img = loadImage('banana.jpg')
def setup():
size(300, 300)
def draw():
image(img, 0, 0) |
Is there a reason that the PGraphics has to be the synchronization provider? |
You still won't be able to load
I just tried
Yes, PGraphicsOpenGL launches DMA transfers to get pixels from graphics card without blocking the cpu and it has to complete them on the rendering thread. However, it can be solved to make it work in your case, that is not the problem. Sketch path is going to be your problem, and I don't think we can solve that one. |
Thanks very much for your detailed answers. While it happens to be the case that sketch path is indeed available for a Python mode sketch from the get-go, I understand that it may not be convenient to make it so for Java mode. Again, thanks for your consideration. |
You're welcome!
Not on my machine. Python mode in Processing 3.0.2 just loads null and crashes with NullPointerException when I try to draw the image. img1 = loadImage("layer1.jpg")
def setup():
size(640, 360)
def draw():
background(0)
image(img1, 0, 0) # NullPointerException here When I move the loadImage into def setup():
size(640, 360)
global img1
img1 = loadImage("layer1.jpg")
def draw():
background(0)
image(img1, 0, 0) # works It might just be a coincidence on your side (maybe you are launching processing from the sketch folder), but generally sketch path before
I would also liked if it just worked everywhere, but sadly it's not possible with the current architecture. |
How about with an up-to-date processing? What build of Python Mode? Anyway, it won't work anymore at all, so it's mooooooot. |
Python mode 3015. Nope, doesn't work with 3.0 nor with 3.1.1 (where I fixed the problem with PGraphics you mentioned). It just tells me files are not accessible and then crashes with NullPonterException when I try to draw the image (which is null). However, I don't see how it could have worked in the past, unless it's some coincidence in OSX version. |
Well then. That seems to be that! |
Yeah... sorry. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
There's no way to call loadImage() from outside of
setup()
or other blessed main thread methods because ofhttps://github.com/processing/processing/blob/master/core/src/processing/core/PApplet.java#L5250
but, if I understand correctly from following the code around, this is just to guard against certain circumstances when concurrently loading images from the network. In the case of trying to create an image from a local data file, can't that check be skipped?
The text was updated successfully, but these errors were encountered: