Global API

Global functions, constants, and classes used universally across the library.

Classes

Typedefs

Enumerations

Variables

Debugging Functionality

Global C++ Functions

Downcasting from Core type to C++ type

Typedef Documentation

typedef uint32_t BLResult

Result code used by most Blend2D functions (32-bit unsigned integer).

The BLResultCode enumeration contains Blend2D result codes that contain Blend2D specific set of errors and an extended set of errors that can come from WIN32 or POSIX APIs. Since the success result code is zero it's recommended to use the following check to determine whether a call failed or not:

BLResult result = doSomething();
if (result != BL_SUCCESS) {
// `doSomething()` failed...
}

typedef uintptr_t BLBitWord

A type used to store a pack of bits (typedef to uintptr_t).

BitWord should be equal in size to a machine word.

typedef uint32_t BLTag

Tag is a 32-bit integer consisting of 4 characters in the following format:

tag = ((a << 24) | (b << 16) | (c << 8) | d)

Tags are used extensively by OpenType fonts and other binary formats like PNG. In most cases TAGs should only contain ASCII letters, digits, and spaces.

Blend2D uses BLTag in public and internal APIs to distinguish between a regular uint32_t and tag.

typedef void(* BLDestroyImplFunc)(void* impl, void* destroyData)

A function callback that is called when an Impl is destroyed. It's often used to notify that a data passed to a certain Impl is no longer in use.

typedef BLArrayView<char> BLStringView

View of char[] data used by String.

typedef BLArrayView<BLBoxI> BLRegionView

View of BLBoxI[] data used by Region.

typedef BLArrayView<void> BLDataView

View of untyped data.

Enumeration Type Documentation

BLResultCode : uint32_tenum

Blend2D result code.

ConstantDescription
BL_SUCCESS 

Successful result code.

BL_ERROR_OUT_OF_MEMORY 

Out of memory [ENOMEM].

BL_ERROR_INVALID_VALUE 

Invalid value/argument [EINVAL].

BL_ERROR_INVALID_STATE 

Invalid state [EFAULT].

BL_ERROR_INVALID_HANDLE 

Invalid handle or file. [EBADF].

BL_ERROR_VALUE_TOO_LARGE 

Value too large [EOVERFLOW].

BL_ERROR_NOT_INITIALIZED 

Not initialized (some instance is built-in none when it shouldn't be).

BL_ERROR_NOT_IMPLEMENTED 

Not implemented [ENOSYS].

BL_ERROR_NOT_PERMITTED 

Operation not permitted [EPERM].

BL_ERROR_IO 

IO error [EIO].

BL_ERROR_BUSY 

Device or resource busy [EBUSY].

BL_ERROR_INTERRUPTED 

Operation interrupted [EINTR].

BL_ERROR_TRY_AGAIN 

Try again [EAGAIN].

BL_ERROR_TIMED_OUT 

Timed out [ETIMEDOUT].

BL_ERROR_BROKEN_PIPE 

Broken pipe [EPIPE].

BL_ERROR_INVALID_SEEK 

File is not seekable [ESPIPE].

BL_ERROR_SYMLINK_LOOP 

Too many levels of symlinks [ELOOP].

BL_ERROR_FILE_TOO_LARGE 

File is too large [EFBIG].

BL_ERROR_ALREADY_EXISTS 

File/directory already exists [EEXIST].

BL_ERROR_ACCESS_DENIED 

Access denied [EACCES].

BL_ERROR_MEDIA_CHANGED 

Media changed [Windows::ERROR_MEDIA_CHANGED].

BL_ERROR_READ_ONLY_FS 

The file/FS is read-only [EROFS].

BL_ERROR_NO_DEVICE 

Device doesn't exist [ENXIO].

BL_ERROR_NO_ENTRY 

Not found, no entry (fs) [ENOENT].

BL_ERROR_NO_MEDIA 

No media in drive/device [ENOMEDIUM].

BL_ERROR_NO_MORE_DATA 

No more data / end of file [ENODATA].

BL_ERROR_NO_MORE_FILES 

No more files [ENMFILE].

BL_ERROR_NO_SPACE_LEFT 

No space left on device [ENOSPC].

BL_ERROR_NOT_EMPTY 

Directory is not empty [ENOTEMPTY].

BL_ERROR_NOT_FILE 

Not a file [EISDIR].

BL_ERROR_NOT_DIRECTORY 

Not a directory [ENOTDIR].

BL_ERROR_NOT_SAME_DEVICE 

Not same device [EXDEV].

BL_ERROR_NOT_BLOCK_DEVICE 

Not a block device [ENOTBLK].

BL_ERROR_INVALID_FILE_NAME 

File/path name is invalid [n/a].

BL_ERROR_FILE_NAME_TOO_LONG 

File/path name is too long [ENAMETOOLONG].

BL_ERROR_TOO_MANY_OPEN_FILES 

Too many open files [EMFILE].

BL_ERROR_TOO_MANY_OPEN_FILES_BY_OS 

Too many open files by OS [ENFILE].

BL_ERROR_TOO_MANY_LINKS 

Too many symbolic links on FS [EMLINK].

BL_ERROR_TOO_MANY_THREADS 

Too many threads [EAGAIN].

BL_ERROR_FILE_EMPTY 

File is empty (not specific to any OS error).

BL_ERROR_OPEN_FAILED 

File open failed [Windows::ERROR_OPEN_FAILED].

BL_ERROR_NOT_ROOT_DEVICE 

Not a root device/directory [Windows::ERROR_DIR_NOT_ROOT].

BL_ERROR_UNKNOWN_SYSTEM_ERROR 

Unknown system error that failed to translate to Blend2D result code.

BL_ERROR_INVALID_ALIGNMENT 

Invalid data alignment.

BL_ERROR_INVALID_SIGNATURE 

Invalid data signature or header.

BL_ERROR_INVALID_DATA 

Invalid or corrupted data.

BL_ERROR_INVALID_STRING 

Invalid string (invalid data of either UTF8, UTF16, or UTF32).

BL_ERROR_DATA_TRUNCATED 

Truncated data (more data required than memory/stream provides).

BL_ERROR_DATA_TOO_LARGE 

Input data too large to be processed.

BL_ERROR_DECOMPRESSION_FAILED 

Decompression failed due to invalid data (RLE, Huffman, etc).

BL_ERROR_INVALID_GEOMETRY 

Invalid geometry (invalid path data or shape).

BL_ERROR_NO_MATCHING_VERTEX 

Returned when there is no matching vertex in path data.

BL_ERROR_NO_MATCHING_COOKIE 

No matching cookie (BLContext).

BL_ERROR_NO_STATES_TO_RESTORE 

No states to restore (BLContext).

BL_ERROR_IMAGE_TOO_LARGE 

The size of the image is too large.

BL_ERROR_IMAGE_NO_MATCHING_CODEC 

Image codec for a required format doesn't exist.

BL_ERROR_IMAGE_UNKNOWN_FILE_FORMAT 

Unknown or invalid file format that cannot be read.

BL_ERROR_IMAGE_DECODER_NOT_PROVIDED 

Image codec doesn't support reading the file format.

BL_ERROR_IMAGE_ENCODER_NOT_PROVIDED 

Image codec doesn't support writing the file format.

BL_ERROR_PNG_MULTIPLE_IHDR 

Multiple IHDR chunks are not allowed (PNG).

BL_ERROR_PNG_INVALID_IDAT 

Invalid IDAT chunk (PNG).

BL_ERROR_PNG_INVALID_IEND 

Invalid IEND chunk (PNG).

BL_ERROR_PNG_INVALID_PLTE 

Invalid PLTE chunk (PNG).

BL_ERROR_PNG_INVALID_TRNS 

Invalid tRNS chunk (PNG).

BL_ERROR_PNG_INVALID_FILTER 

Invalid filter type (PNG).

BL_ERROR_JPEG_UNSUPPORTED_FEATURE 

Unsupported feature (JPEG).

BL_ERROR_JPEG_INVALID_SOS 

Invalid SOS marker or header (JPEG).

BL_ERROR_JPEG_INVALID_SOF 

Invalid SOF marker (JPEG).

BL_ERROR_JPEG_MULTIPLE_SOF 

Multiple SOF markers (JPEG).

BL_ERROR_JPEG_UNSUPPORTED_SOF 

Unsupported SOF marker (JPEG).

BL_ERROR_FONT_NO_CHARACTER_MAPPING 

Font has no character to glyph mapping data.

BL_ERROR_FONT_MISSING_IMPORTANT_TABLE 

Font has missing an important table.

BL_ERROR_FONT_FEATURE_NOT_AVAILABLE 

Font feature is not available.

BL_ERROR_FONT_CFF_INVALID_DATA 

Font has an invalid CFF data.

BL_ERROR_FONT_PROGRAM_TERMINATED 

Font program terminated because the execution reached the limit.

BL_ERROR_INVALID_GLYPH 

Invalid glyph identifier.

BLByteOrder : uint32_tenum

Byte order.

ConstantDescription
BL_BYTE_ORDER_LE 

Little endian byte-order.

BL_BYTE_ORDER_BE 

Big endian byte-order.

BL_BYTE_ORDER_NATIVE 

Native (host) byte-order.

BL_BYTE_ORDER_SWAPPED 

Swapped byte-order (BE if host is LE and vice versa).

BLDataAccessFlags : uint32_tenum

Data access flags.

ConstantDescription
BL_DATA_ACCESS_READ 

Read access.

BL_DATA_ACCESS_WRITE 

Write access.

BL_DATA_ACCESS_RW 

Read and write access.

BLDataSourceType : uint32_tenum

Data source type.

ConstantDescription
BL_DATA_SOURCE_TYPE_NONE 

No data source.

BL_DATA_SOURCE_TYPE_MEMORY 

Memory data source.

BL_DATA_SOURCE_TYPE_FILE 

File data source.

BL_DATA_SOURCE_TYPE_CUSTOM 

Custom data source.

BL_DATA_SOURCE_TYPE_COUNT 

Count of data source types.

BLModifyOp : uint32_tenum

Modification operation applied to Blend2D containers.

ConstantDescription
BL_MODIFY_OP_ASSIGN_FIT 

Assign operation and reserve only space to fit the input.

BL_MODIFY_OP_ASSIGN_GROW 

Assign operation and reserve more capacity for growing.

BL_MODIFY_OP_APPEND_FIT 

Append operation and reserve only space to fit the input.

BL_MODIFY_OP_APPEND_GROW 

Append operation and reserve more capacity for growing.

BL_MODIFY_OP_COUNT 

Count of data operations.

BLBooleanOp : uint32_tenum

Boolean operator.

ConstantDescription
BL_BOOLEAN_OP_COPY 

Result = B.

BL_BOOLEAN_OP_AND 

Result = A & B.

BL_BOOLEAN_OP_OR 

Result = A | B.

BL_BOOLEAN_OP_XOR 

Result = A ^ B.

BL_BOOLEAN_OP_SUB 

Result = A - B.

BLImplType : uint32_tenum

Impl type identifier used by to describe a Blend2D Impl.

ConstantDescription
BL_IMPL_TYPE_NULL 

Type is Null.

BL_IMPL_TYPE_BIT_ARRAY 

Type is BLBitArray.

BL_IMPL_TYPE_STRING 

Type is BLString.

BL_IMPL_TYPE_ARRAY_VAR 

Type is BLArray<T> where T is BLVariant or other ref-counted type.

BL_IMPL_TYPE_ARRAY_I8 

Type is BLArray<T> where T matches 8-bit signed integral type.

BL_IMPL_TYPE_ARRAY_U8 

Type is BLArray<T> where T matches 8-bit unsigned integral type.

BL_IMPL_TYPE_ARRAY_I16 

Type is BLArray<T> where T matches 16-bit signed integral type.

BL_IMPL_TYPE_ARRAY_U16 

Type is BLArray<T> where T matches 16-bit unsigned integral type.

BL_IMPL_TYPE_ARRAY_I32 

Type is BLArray<T> where T matches 32-bit signed integral type.

BL_IMPL_TYPE_ARRAY_U32 

Type is BLArray<T> where T matches 32-bit unsigned integral type.

BL_IMPL_TYPE_ARRAY_I64 

Type is BLArray<T> where T matches 64-bit signed integral type.

BL_IMPL_TYPE_ARRAY_U64 

Type is BLArray<T> where T matches 64-bit unsigned integral type.

BL_IMPL_TYPE_ARRAY_F32 

Type is BLArray<T> where T matches 32-bit floating point type.

BL_IMPL_TYPE_ARRAY_F64 

Type is BLArray<T> where T matches 64-bit floating point type.

BL_IMPL_TYPE_ARRAY_STRUCT_1 

Type is BLArray<T> where T is a struct of size 1.

BL_IMPL_TYPE_ARRAY_STRUCT_2 

Type is BLArray<T> where T is a struct of size 2.

BL_IMPL_TYPE_ARRAY_STRUCT_3 

Type is BLArray<T> where T is a struct of size 3.

BL_IMPL_TYPE_ARRAY_STRUCT_4 

Type is BLArray<T> where T is a struct of size 4.

BL_IMPL_TYPE_ARRAY_STRUCT_6 

Type is BLArray<T> where T is a struct of size 6.

BL_IMPL_TYPE_ARRAY_STRUCT_8 

Type is BLArray<T> where T is a struct of size 8.

BL_IMPL_TYPE_ARRAY_STRUCT_10 

Type is BLArray<T> where T is a struct of size 10.

BL_IMPL_TYPE_ARRAY_STRUCT_12 

Type is BLArray<T> where T is a struct of size 12.

BL_IMPL_TYPE_ARRAY_STRUCT_16 

Type is BLArray<T> where T is a struct of size 16.

BL_IMPL_TYPE_ARRAY_STRUCT_20 

Type is BLArray<T> where T is a struct of size 20.

BL_IMPL_TYPE_ARRAY_STRUCT_24 

Type is BLArray<T> where T is a struct of size 24.

BL_IMPL_TYPE_ARRAY_STRUCT_32 

Type is BLArray<T> where T is a struct of size 32.

BL_IMPL_TYPE_PATH 

Type is BLPath.

BL_IMPL_TYPE_REGION 

Type is BLRegion.

BL_IMPL_TYPE_IMAGE 

Type is BLImage.

BL_IMPL_TYPE_IMAGE_CODEC 

Type is BLImageCodec.

BL_IMPL_TYPE_IMAGE_DECODER 

Type is BLImageDecoder.

BL_IMPL_TYPE_IMAGE_ENCODER 

Type is BLImageEncoder.

BL_IMPL_TYPE_GRADIENT 

Type is BLGradient.

BL_IMPL_TYPE_PATTERN 

Type is BLPattern.

BL_IMPL_TYPE_CONTEXT 

Type is BLContext.

BL_IMPL_TYPE_FONT 

Type is BLFont.

BL_IMPL_TYPE_FONT_FACE 

Type is BLFontFace.

BL_IMPL_TYPE_FONT_DATA 

Type is BLFontData.

BL_IMPL_TYPE_FONT_LOADER 

Type is BLFontLoader.

BL_IMPL_TYPE_FONT_FEATURE_OPTIONS 

Type is BLFontFeatureOptions.

BL_IMPL_TYPE_FONT_VARIATION_OPTIONS 

Type is BLFontVariationOptions.

BL_IMPL_TYPE_COUNT 

Count of type identifiers including all reserved ones.

BLImplTraits : uint32_tenum

Impl traits that describe some details about a Blend2D Impl data.

ConstantDescription
BL_IMPL_TRAIT_MUTABLE 

The data this container holds is mutable if refCount == 1.

BL_IMPL_TRAIT_IMMUTABLE 

The data this container holds is always immutable.

BL_IMPL_TRAIT_EXTERNAL 

Set if the impl uses an external data (data is not part of impl).

BL_IMPL_TRAIT_FOREIGN 

Set if the impl was not allocated by blRuntimeAllocImpl().

BL_IMPL_TRAIT_VIRT 

Set if the impl provides a virtual function table (first member).

BL_IMPL_TRAIT_NULL 

Set if the impl is a built-in null instance (default constructed).

Function Documentation

BLResult blTraceError(BLResult result)static

Returns the result passed.

Provided for debugging purposes. Putting a breakpoint inside blTraceError() can help with tracing an origin of errors reported / returned by Blend2D as each error goes through this function.

It's a zero-cost solution that doesn't affect release builds in any way.

template<typename T>
T blAbs(const T& a)constexpr

Returns an absolute value of a.

template<typename T>
T blMin(const T& a, const T& b)constexpr[1/2]

Returns a minimum value of a and b.

template<typename T>
T blMax(const T& a, const T& b)constexpr[1/2]

Returns a maximum value of a and b.

template<typename T>
T blClamp(const T& a, const T& b, const T& c)constexpr

Clamps a to a range defined as [b, c].

template<typename T, typename... Args>
T blMin(const T& a, const T& b, Args&&... args)constexpr[2/2]

Returns a minimum value of all arguments passed.

template<typename T, typename... Args>
T blMax(const T& a, const T& b, Args&&... args)constexpr[2/2]

Returns a maximum value of all arguments passed.

template<typename T>
bool blEquals(const T& a, const T& b)

Returns true if a and b equals at binary level.

For example blEquals(NaN, NaN) == true.

template<typename T>
BLInternal::DownCast<T>::Type& blDownCast(T& ref)constexprstatic[1/4]

Downcasts a core type like BLContextCore into a C++ type like BLContext. Intended to be used by C++ users that work with C API as well (by either providing it directly or using some other code that uses Blend2D C API).

template<typename T>
const BLInternal::DownCast<T>::Type& blDownCast(const T& ref)constexprstatic[2/4]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T>
BLInternal::DownCast<T>::Type* blDownCast(T* ptr)constexprstatic[3/4]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T>
const BLInternal::DownCast<T>::Type* blDownCast(const T* ptr)constexprstatic[4/4]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Variable Documentation

BLVariantCore blNone[BL_IMPL_TYPE_COUNT]

Built-in none objects indexed by BLImplType