Topaz 5.0
Topaz Game Engine
Loading...
Searching...
No Matches
IO Library

Description

High-level library for wrangling files of various formats.

This library contains support for a handful of common file formats, allowing you to import them without having to implement a parser yourself.

Classes

struct  tz::io::image_header
 Describes basic information about an image. More...
 

Function Documentation

◆ image_info()

std::expected< image_header, tz::error_code > tz::io::image_info ( std::span< const std::byte > img_file_data)

Retrieve info about an image loaded in memory.

Parameters
img_file_dataData read directly from an image file. See below for the list of supported image file formats.
Returns
A image_header containing basic information about the image, or some tz::error_code if the image data could not be parsed.

The image file formats guaranteed are:

  • jpg
  • png
  • bmp

Other file formats that aren't listed here might still work, but you should consider anything not on this list an implementation detail that could lose support suddenly in a new release.

◆ parse_image()

tz::error_code tz::io::parse_image ( std::span< const std::byte > img_file_data,
std::span< std::byte > buffer )

Load an image from file data resident in memory.

Parameters
img_file_dataData read directly from an image file. See the detailsof image_info for a list of supported image file formats.
bufferA buffer of memory into which decoded image data will be written. It is your responsibility to provide a buffer that is of sufficient size. To decipher the size needed, see image_info.
Returns
tz::error_code::success If the image data was successfully decoded.
tz::error_code::oom If the buffer you provided was not of sufficient size.
tz::error_code::unknown_error If image decoding failed for some other reason.