1
\$\begingroup\$

LWJGL3 provides me with simple wrappers around nothings' stb libraries. In order to load images I thus make use of the stb_image wrapper.

My issue is that when I use this wrapper library, all I get back is a unsigned char * pointing to the pixel data in the memory allocated by stbi. While I can work with this, it introduces two issues that are non-trivial to me:

  1. I have to explicitly manage this memory, thus either work with explicit free methods on any class that keeps the image-data any longer than during construction.
  2. Access to the actual image-data from java is, to say the least, somewhat convoluted. Not to speak of modifying it.

Q: Is there any standard way to load the image-data produced by the stbi library via LWJGL wrappers into standard java memory?

My goal is that I can free the stbi allocated memory immediately after loading and don't have to worry about it anymore.

I also want to be able to access the actual image data for optional processing after loading the image.

I am looking for either a pure JDK solution or a solution that uses LWJGL3 or any other library (the smaller the footprint the better) that results in a java-managed memory structure giving access to these bytes (i.e. an object that can be garbage collected without me having to do anything other than releasing any references to it).

\$\endgroup\$

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.