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

optional<ImageCodec> guessImageCodec(bytes_view 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 optional ImageCodec if the codec can be guessed; otherwise, an empty 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,
                 optional<int> quality = nullopt,
                 optional<ColorSubsampling> ss = 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 nullopt, which uses default quality).
Param ss Optional color subsampling parameter (default is nullopt).
Returns A byte vector containing the encoded JPEG image data.


webpEncode function

bytes webpEncode(RC<Image> image,
                 optional<float> quality = 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 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,
                  optional<int> quality = nullopt,
                  optional<ColorSubsampling> ss = 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 nullopt).
Param ss Optional color subsampling parameter (default is nullopt).
Returns A byte vector containing the encoded image data.


pngDecode function

expected<RC<Image>, ImageIOError>
pngDecode(bytes_view bytes,
          ImageFormat format = ImageFormat::Unknown)

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(bytes_view bytes,
          ImageFormat format = ImageFormat::Unknown)

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(bytes_view 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(bytes_view bytes,
           ImageFormat format = ImageFormat::Unknown)

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, bytes_view bytes,
            ImageFormat format = ImageFormat::Unknown)

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/