Package limn.graphics
Interface ImageDecoder
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Decodes encoded image bytes (PNG/JPG/…) into an
Image. The LWJGL
backend installs an stb_image-based decoder; tests can inject a fake.-
Method Summary
Modifier and TypeMethodDescriptiondecode(byte[] fileBytes) Called from any thread, including several at once. It runs on the caller's thread fromImages.decode(byte[])and on theUiworker pool fromImages.decodeAsync(byte[])andImages.loadShared(java.nio.file.Path), which is what lets those exist at all, so an implementation must be pure CPU, must need no GL context and no window, and must keep no state between calls unless it is synchronized.
-
Method Details
-
decode
Called from any thread, including several at once. It runs on the caller's thread fromImages.decode(byte[])and on theUiworker pool fromImages.decodeAsync(byte[])andImages.loadShared(java.nio.file.Path), which is what lets those exist at all, so an implementation must be pure CPU, must need no GL context and no window, and must keep no state between calls unless it is synchronized.fileBytesis read, never written.- Parameters:
fileBytes- the full encoded file- Returns:
- the decoded RGBA image; a fresh instance per call, because that instance's identity is the texture-cache key
- Throws:
RuntimeException- if the bytes cannot be decoded
-