-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Image importing no longer working #63025
Comments
Try to delete the |
I restarted from scratch with the 4.0a12 local build, so there weren't any existing imports. I was having other issues when I attempted to import my 3.5x local build version (which both GD and C# versions work fine with), and I couldn't figure out what I needed or not any longer (e.g. the font .tres are no longer needed, but they don't get removed on import, so I wasn't sure what to do). Also, the import of the PNG worked. The first load appears in a Globals.gd that is auto-loaded, and the resource shows up there and in the debugger. When I attempt the duplicate() of the image, it does nothing. In fact, all attempts after the global load fail with it returning null, even if I do another load("res://image.png") with it. I actually did try that, specifically (that is, bypassing the global loaded one and loading to new variable from scratch; It doesn't work after the original globally loaded one does work). |
Hi, I've been able to recreate the issue in a minimum project. I have attached in a zip file. |
In the above test project, replacing these lines: new_texture = ImageTexture.new()
new_texture.create_from_image(image) with these lines: new_texture = ImageTexture.create_from_image(image) causes the image to successfully load. |
EDIT: |
I can confirm that this fixes the issues I'm having. As for the cannot duplicate or load an imported image, I meant it literally:
and later:
d would still be null in the debugger, even though this never failed:
I saw there was bug about variables in the debugger not showing correctly, so maybe that is partially to blame. Regardless, switching to static call fixes it in both my project and the demo code. Didn't occur to me that this was a documentation issue ... |
Ah, now that you mention it, ImageTexture code examples weren't updated. Also the most reliable way to test if something works is printing it. If the variable is null in the debugger then it's debugger bug xd So to sum up, ImageTexture is working as intended and it just needs documentation fixup (also the demos using ImageTexture need to be updated too). EDIT: |
From my perspective, I was immediately attempting to At least its an easy fix; Just wish it had occurred to me, so I could have prevented creating an issue for it (or maybe created an issue for the real cause, or just fixed it and pushed a pull request, or ...). |
Godot version
4.0a12
System information
Windows 10 Pro x64
Issue description
I cannot duplicate or load an imported image. After looking into it further, I attempted to run demo viewport/screen_capture, and it has a similar issue: When pushing the screen capture button, nothing happens. In the code, if you step through the callback for the button, it attempts to get a copy of the resource. The return in always null.
From my project, I am use load (even tried ResourceLoader.load) to load a PNG image that was imported as an Image (rather than a Texture2d as is the default), and when I call duplicate on the loaded image, I get nothing back.
Interestingly, I have an assert(image != null) before the duplicate call, and even though the debugger shows it as null, the assert never fails. The various calls made on the image also don't fail, but also don't appear to do anything.
I was using a local build of 4.x, but I also tried this with Alpha 12, with the same results.
Steps to reproduce
Load and run demo_project viewport/screen_capture. Attempt to capture screen by pushing screen capture button. Nothing happens.
Minimal reproduction project
demo_project/viewport/screen_capture
The text was updated successfully, but these errors were encountered: