This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Is there any way, when using the ResourceLoader to load an image directly (not going through a texture) to tell it up front that it should be stored as FORMAT_R8? I'm pulling in a pretty large image that only contains an alpha channel, and while I can convert it right after load, it feels like not the most efficient use of memory.

in Engine by (24 points)

I haven't used it much, but are you aware of the Image class?

https://docs.godotengine.org/en/stable/classes/class_image.html

Yes, that's what I'm using to load it. But it doesn't let me specify the format at load time.

(Currently messing with different file formats to see if I can get Godot to auto-detect what the file is.)

Ah, yeah, got it. Poking around, I wonder about...

  • Load the raw data via File.get_buffer() to load the data as a PoolByteArray
  • Create the image via Image.create_from_data() which accepts the data from a PoolByteArray and allows a format to be specified...

Though, I've never tried it...

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.