Tycho Image — typed RGBA/HDR image IO (PNG/JPEG/PPM/BMP decode, PNG encode) for the Tycho stack
let img = @image.load_rgba("assets/logo.png")
let tex = dev.create_texture_format(img.width, img.height, @tycho.TextureFormat::RGBA8, img.data)pub suberror ImageError {
DecodeFailed(String)
IoFailed(String)
EncodeFailed(String)
}pub(all) struct HdrImage {
width : Int
height : Int
pixels : FixedArray[Float]
}pub(all) struct StbiGif {
width : Int
height : Int
frames : Int
channels_in_file : Int
channels : Int
delays : FixedArray[Int]
data : Bytes
}pub(all) struct StbiImage16 {
width : Int
height : Int
channels_in_file : Int
channels : Int
data : FixedArray[UInt16]
}pub(all) struct StbiImage8 {
width : Int
height : Int
channels_in_file : Int
channels : Int
data : Bytes
}pub(all) struct StbiImageF {
width : Int
height : Int
channels_in_file : Int
channels : Int
data : FixedArray[Float]
}pub(all) struct StbiInfo {
width : Int
height : Int
channels : Int
image_type : StbiImageType
is_16_bit : Bool
is_hdr : Bool
is_iphone_png : Bool
} derive(Eq, Debug)pub(all) struct StbiOptions {
flip_vertically : Bool
unpremultiply_iphone_png : Bool
convert_iphone_png_to_rgb : Bool
ldr_to_hdr_gamma : Float
ldr_to_hdr_scale : Float
hdr_to_ldr_gamma : Float
hdr_to_ldr_scale : Float
}fn read_file_bytes(path : String) -> Bytesfn save_png_rgba(path : String, width : Int, height : Int, data : Bytes, bgra? : Bool) -> Unit raise ImageErrorfn stbi_is_16_bit_from_memory(buffer : Bytes) -> Boolfn stbi_is_hdr_from_memory(buffer : Bytes) -> Boolfn stbi_load_16_from_memory(buffer : Bytes, desired_channels? : Int, options? : StbiOptions) -> StbiImage16?fn stbi_load_from_memory(buffer : Bytes, desired_channels? : Int, options? : StbiOptions) -> StbiImage8?fn stbi_load_gif_from_memory(buffer : Bytes, desired_channels? : Int, options? : StbiOptions) -> StbiGif?fn stbi_loadf_from_memory(buffer : Bytes, desired_channels? : Int, options? : StbiOptions) -> StbiImageF?fn stbi_zlib_decode(data : Bytes) -> Bytes?fn stbi_zlib_decode_noheader(data : Bytes) -> Bytes?Install
Download zipTycho Image — typed RGBA/HDR image IO (PNG/JPEG/PPM/BMP decode, PNG encode) for the Tycho stack