dpp::utility::image_data
utility.h
std::unique_ptr< std::byte[]> std::unique_ptr<std::byte[]> dpp::utility::image_data::data data dpp::utility::image_data::data = nullptr

Data in bytes of the image.

uint32_t uint32_t dpp::utility::image_data::size size dpp::utility::image_data::size = 0

Size of the data in bytes.

image_type image_type dpp::utility::image_data::type type dpp::utility::image_data::type = {}

Type of the image.

image_type

dpp::utility::image_data::image_data
()=default
image_data
dpp::utility::image_data::image_data

Construct an empty image.

dpp::utility::image_data::image_data
(const image_data &rhs)
image_data
dpp::utility::image_data::image_data
const image_data & rhs

Copy an image.

rhs

Image to copy

dpp::utility::image_data::image_data
(image_data &&rhs) noexcept=default
image_data
dpp::utility::image_data::image_data
image_data && rhs

Move an image.

rhs

Image to copy

dpp::utility::image_data::image_data
(image_type format, const std::byte *bytes, uint32_t byte_size)
image_data
dpp::utility::image_data::image_data
image_type format
const std::byte * bytes
uint32_t byte_size

Construct from byte buffer.

format

Image format

bytes

Data of the image

byte_size

Image size in bytes

image_type

dpp::utility::image_data::image_data
(image_type format, std::string_view bytes)
image_data
dpp::utility::image_data::image_data
image_type format
std::string_view bytes

Construct from string buffer.

format

Image format

bytes

Data in a string

image_type

std::string std::string dpp::utility::image_data::base64_encode () const base64_encode dpp::utility::image_data::base64_encode

Encode to base64.

std::string New string with the image data encoded in base64

bool bool dpp::utility::image_data::empty () const noexcept empty dpp::utility::image_data::empty

Check if this is an empty image.

bool Whether the image is empty or not

std::string std::string dpp::utility::image_data::get_file_extension () const get_file_extension dpp::utility::image_data::get_file_extension

Get the file extension.

Alias for file_extension

std::string File extension e.g. `.png`

std::string std::string dpp::utility::image_data::get_mime_type () const get_mime_type dpp::utility::image_data::get_mime_type

Get the mime type.

Alias for mime_type

std::string File mime type e.g. "image/png"

image_data & image_data & dpp::utility::image_data::operator= (const image_data &rhs) operator= dpp::utility::image_data::operator= const image_data & rhs

Copy an image data.

rhs

Image to copy

self for chaining

image_data & image_data & dpp::utility::image_data::operator= (image_data &&rhs) noexcept=default operator= dpp::utility::image_data::operator= image_data && rhs

Move an image data.

rhs

Image to move from

self for chaining

void void dpp::utility::image_data::set (image_type format, const std::byte *bytes, uint32_t byte_size) set dpp::utility::image_data::set image_type format const std::byte * bytes uint32_t byte_size

Set image data.

format

Format of the image

bytes

Data of the image

byte_size

Image size in bytes

void void dpp::utility::image_data::set (image_type format, std::string_view bytes) set dpp::utility::image_data::set image_type format std::string_view bytes

Set image data.

format

Image format

bytes

Data of the image

json json dpp::utility::image_data::to_nullable_json () const to_nullable_json dpp::utility::image_data::to_nullable_json

Build a data URI scheme suitable for sending to Discord.

https://discord.com/developers/docs/reference#image-data

The data URI scheme as a json or null if empty

Image to be received or sent to API calls.

This class is carefully crafted to be 16 bytes, this is why we use a ptr + 4 byte size instead of a vector. We want this class to be substitutable with iconhash in data structures.

T
dpp::utility::image_data
data
size
type
image_type
byte
std::unique_ptr< T >
ptr
std::unique_ptr< std::byte[]>
ptr
< std::byte[]>
uint32_t
- dpp::utility::image_data
  base64_encode
- dpp::utility::image_data
  data
- dpp::utility::image_data
  empty
- dpp::utility::image_data
  get_file_extension
- dpp::utility::image_data
  get_mime_type
- dpp::utility::image_data
  image_data
- dpp::utility::image_data
  image_data
- dpp::utility::image_data
  image_data
- dpp::utility::image_data
  image_data
- dpp::utility::image_data
  image_data
- dpp::utility::image_data
  operator=
- dpp::utility::image_data
  operator=
- dpp::utility::image_data
  set
- dpp::utility::image_data
  set
- dpp::utility::image_data
  size
- dpp::utility::image_data
  to_nullable_json
- dpp::utility::image_data
  type