Skip to content

File include/brisk/graphics/ImageFormats.hpp


ImageCodec enum

enum class ImageCodec

Enum representing the various image codecs supported for encoding and decoding.

PNG enumerator (ImageCodec::PNG)

Portable Network Graphics

BMP enumerator (ImageCodec::BMP)

Bitmap Image File

JPEG enumerator (ImageCodec::JPEG)

Joint Photographic Experts Group

WEBP enumerator (ImageCodec::WEBP)

WebP Image Format


ImageIOError enum

enum class ImageIOError

Enum representing potential image I/O errors.

CodecError enumerator (ImageIOError::CodecError)

Error related to codec processing

InvalidFormat enumerator (ImageIOError::InvalidFormat)

Error due to an invalid image format


defaultImageQuality variable

inline int defaultImageQuality = 98

Default image quality for encoding.

This value is used as the default quality setting when encoding images, with a typical range of 0 (lowest quality) to 100 (highest quality).


ColorSubsampling enum

enum class ColorSubsampling

Enum representing color subsampling methods for images.

S444 enumerator (ColorSubsampling::S444)

4:4:4 color subsampling (no subsampling)

S422 enumerator (ColorSubsampling::S422)

4:2:2 color subsampling (horizontal subsampling)

S420 enumerator (ColorSubsampling::S420)

4:2:0 color subsampling (both horizontal and vertical subsampling)


defaultColorSubsampling variable

inline ColorSubsampling defaultColorSubsampling =
    ColorSubsampling::S420

Default color subsampling method.


guessImageCodec function

std::optional<ImageCodec> guessImageCodec(BytesView bytes)

Guesses the image codec based on the provided byte data.
Param bytes A view of the byte data to analyze for codec detection.
Returns An std::optional ImageCodec if the codec can be guessed; otherwise, an empty std::optional.


pngEncode function

Bytes pngEncode(RC<Image> image)

Encodes an image to PNG format.
Param image A reference-counted pointer to the image to be encoded.
Returns A byte vector containing the encoded PNG image data.


bmpEncode function

Bytes bmpEncode(RC<Image> image)

Encodes an image to BMP format.
Param image A reference-counted pointer to the image to be encoded.
Returns A byte vector containing the encoded BMP image data.


jpegEncode function

Bytes jpegEncode(
    RC<Image> image,
    std::optional<int> quality = std::nullopt,
    std::optional<ColorSubsampling> ss = std::nullopt)

Encodes an image to JPEG format.
Param image A reference-counted pointer to the image to be encoded.
Param quality Optional quality parameter for encoding (default is std::nullopt, which uses default quality).
Param ss Optional color subsampling parameter (default is std::nullopt).
Returns A byte vector containing the encoded JPEG image data.


webpEncode function

Bytes webpEncode(
    RC<Image> image,
    std::optional<float> quality = std::nullopt,
    bool lossless = false)

Encodes an image to WEBP format.
Param image A reference-counted pointer to the image to be encoded.
Param quality Optional quality parameter for encoding (default is std::nullopt).
Param lossless Flag indicating whether to use lossless encoding (default is false).
Returns A byte vector containing the encoded WEBP image data.


imageEncode function

Bytes imageEncode(
    ImageCodec codec, RC<Image> image,
    std::optional<int> quality = std::nullopt,
    std::optional<ColorSubsampling> ss = std::nullopt)

Encodes an image to the specified format using the provided codec.
Param codec The image codec to use for encoding.
Param image A reference-counted pointer to the image to be encoded.
Param quality Optional quality parameter for encoding (default is std::nullopt).
Param ss Optional color subsampling parameter (default is std::nullopt).
Returns A byte vector containing the encoded image data.


pngDecode function

expected<RC<Image>, ImageIOError>
pngDecode(BytesView bytes,
          ImageFormat format = ImageFormat::Unknown,
          bool premultiplyAlpha = false)

Decodes a PNG image from the provided byte data.
Param bytes A view of the byte data representing a PNG image.
Param format Optional image format to use for decoding (returns original format if not specified).
Returns An expected result containing a reference-counted pointer to the decoded image or an ImageIOError.


bmpDecode function

expected<RC<Image>, ImageIOError>
bmpDecode(BytesView bytes,
          ImageFormat format = ImageFormat::Unknown,
          bool premultiplyAlpha = false)

Decodes a BMP image from the provided byte data.
Param bytes A view of the byte data representing a BMP image.
Param format Optional image format to use for decoding (returns original format if not specified).
Returns An expected result containing a reference-counted pointer to the decoded image or an ImageIOError.


jpegDecode function

expected<RC<Image>, ImageIOError>
jpegDecode(BytesView bytes,
           ImageFormat format = ImageFormat::Unknown)

Decodes a JPEG image from the provided byte data.
Param bytes A view of the byte data representing a JPEG image.
Param format Optional image format to use for decoding (returns original format if not specified).
Returns An expected result containing a reference-counted pointer to the decoded image or an ImageIOError.


webpDecode function

expected<RC<Image>, ImageIOError>
webpDecode(BytesView bytes,
           ImageFormat format = ImageFormat::Unknown,
           bool premultiplyAlpha = false)

Decodes a WEBP image from the provided byte data.
Param bytes A view of the byte data representing a WEBP image.
Param format Optional image format to use for decoding (returns original format if not specified).
Returns An expected result containing a reference-counted pointer to the decoded image or an ImageIOError.


imageDecode function

expected<RC<Image>, ImageIOError>
imageDecode(ImageCodec codec, BytesView bytes,
            ImageFormat format = ImageFormat::Unknown,
            bool premultiplyAlpha = false)

Decodes an image from the provided byte data using the specified codec.
Param codec The image codec to use for decoding.
Param bytes A view of the byte data representing the image.
Param format Optional image format to use for decoding (returns original format if not specified).
Returns An expected result containing a reference-counted pointer to the decoded image or an ImageIOError.


Auto-generated from sources, Revision , https://github.com/brisklib/brisk/blob//include/brisk/