Decodes common encoded image formats into renderer-independent GPUI.Raster values.
decode/1 runs native decoding on a dirty CPU scheduler. File access remains
explicit through load/1, so applications can perform it in their own
supervised task and report progress or cancellation through normal OTP
messages.
Decoding rejects encoded inputs larger than 100 MiB, dimensions above 16,384 pixels, and decoders requiring more than 256 MiB of allocation. These limits keep malformed or adversarial images from exhausting the native runtime.
Summary
Functions
Decodes PNG, JPEG, WebP, GIF, TIFF, BMP, or ICO image bytes.
Reads and decodes an image file. Call from a supervised task when used by UI code.
Types
@type decode_error() :: :invalid_image
@type load_error() :: decode_error() | File.posix()
Functions
@spec decode(binary()) :: {:ok, GPUI.Raster.t()} | {:error, decode_error()}
Decodes PNG, JPEG, WebP, GIF, TIFF, BMP, or ICO image bytes.
@spec load(Path.t()) :: {:ok, GPUI.Raster.t()} | {:error, load_error()}
Reads and decodes an image file. Call from a supervised task when used by UI code.