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.

@FunctionalInterface public interface ImageDecoder
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 Type
    Method
    Description
    decode(byte[] fileBytes)
    Called from any thread, including several at once. It runs on the caller's thread from Images.decode(byte[]) and on the Ui worker pool from Images.decodeAsync(byte[]) and Images.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

      Image decode(byte[] fileBytes)
      Called from any thread, including several at once. It runs on the caller's thread from Images.decode(byte[]) and on the Ui worker pool from Images.decodeAsync(byte[]) and Images.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. fileBytes is 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