template<UnsignedInt dimensions>
Magnum::CompressedImage class

Compressed image.

Stores multi-dimensional compressed image data together with layout and compressed block format description. See CompressedImageView for a non-owning alternative.

This class can act as a drop-in replacement for CompressedImageView and Trade::ImageData APIs and is implicitly convertible to CompressedImageView. Particular graphics API wrappers provide additional image classes, for example GL::CompressedBufferImage. See also Image for equivalent functionality targeted on non-compressed image formats.

Basic usage

The image takes ownership of a passed Containers::Array, together with a CompressedPixelFormat and size in pixels:

CompressedImage2D image{CompressedPixelFormat::Bc1RGBUnorm,
    {512, 256}, Containers::Array<char>{ValueInit, }};

It's also possible to create just an image placeholder, storing only the image properties without data or size. That is useful for example to specify desired format of image queries in graphics APIs:

GL::Texture2D texture;
CompressedImage2D image = texture.compressedImage(0, CompressedImage2D{});

As with CompressedImageView, this class supports extra storage parameters and implementation-specific compressed pixel format specification. See its documentation for more information.

Public types

enum (anonymous): UnsignedInt { Dimensions = dimensions }

Constructors, destructors, conversion operators

CompressedImage(CompressedPixelStorage storage, CompressedPixelFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data, ImageFlags<dimensions> flags = {}) explicit noexcept
Constructor.
CompressedImage(CompressedPixelFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data, ImageFlags<dimensions> flags = {}) explicit noexcept
Constructor.
template<class T>
CompressedImage(CompressedPixelStorage storage, T format, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data, ImageFlags<dimensions> flags = {}) explicit noexcept
Construct a compressed image with implementation-specific format.
template<class T>
CompressedImage(T format, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data, ImageFlags<dimensions> flags = {}) explicit noexcept
Construct a compressed image with implementation-specific format.
CompressedImage(CompressedPixelStorage storage) noexcept
Construct an image placeholder.
CompressedImage() noexcept
Construct an image placeholder.
CompressedImage(const CompressedImage<dimensions>&) deleted
Copying is not allowed.
CompressedImage(CompressedImage<dimensions>&& other) noexcept
Move constructor.
operator BasicCompressedImageView<dimensions>() const
Conversion to a view.
operator BasicMutableCompressedImageView<dimensions>() new in 2019.10
Conversion to a mutable view.

Public functions

auto operator=(const CompressedImage<dimensions>&) -> CompressedImage<dimensions>& deleted
Copying is not allowed.
auto operator=(CompressedImage<dimensions>&& other) -> CompressedImage<dimensions>& noexcept
Move assignment.
auto flags() const -> ImageFlags<dimensions> new in Git master
Layout flags.
auto storage() const -> CompressedPixelStorage
Storage of compressed pixel data.
auto format() const -> CompressedPixelFormat
Format of compressed pixel data.
auto size() const -> const VectorTypeFor<dimensions, Int>&
Image size in pixels.
auto dataProperties() const -> std::pair<VectorTypeFor<dimensions, std::size_t>, VectorTypeFor<dimensions, std::size_t>>
Compressed image data properties.
auto data() & -> Containers::ArrayView<char>
Raw image data.
auto data() const & -> Containers::ArrayView<const char>
auto data() && -> Containers::Array<char> new in 2019.10
Raw image data from a r-value.
auto data() const && -> Containers::Array<char> deleted new in 2019.10
template<class T>
auto data() -> T* deprecated in 2019.10
Image data in a particular type.
template<class T>
auto data() const -> const T* deprecated in 2019.10
Image data in a particular type.
auto release() -> Containers::Array<char>
Release data storage.

Enum documentation

template<UnsignedInt dimensions>
enum Magnum::CompressedImage<dimensions>::(anonymous): UnsignedInt

Enumerators
Dimensions

Image dimension count

Function documentation

template<UnsignedInt dimensions>
Magnum::CompressedImage<dimensions>::CompressedImage(CompressedPixelStorage storage, CompressedPixelFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data, ImageFlags<dimensions> flags = {}) explicit noexcept

Constructor.

Parameters
storage Storage of compressed pixel data
format Format of compressed pixel data
size Image size
data Image data
flags Image layout flags

For a 3D image, if flags contain ImageFlag3D::CubeMap, the size is expected to match its restrictions.

template<UnsignedInt dimensions>
Magnum::CompressedImage<dimensions>::CompressedImage(CompressedPixelFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data, ImageFlags<dimensions> flags = {}) explicit noexcept

Constructor.

Parameters
format Format of compressed pixel data
size Image size
data Image data
flags Image layout flags

Equivalent to calling CompressedImage(CompressedPixelStorage, CompressedPixelFormat, const VectorTypeFor<dimensions, Int>&, Containers::Array<char>&&, ImageFlags<dimensions>) with default-constructed CompressedPixelStorage.

template<UnsignedInt dimensions> template<class T>
Magnum::CompressedImage<dimensions>::CompressedImage(CompressedPixelStorage storage, T format, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data, ImageFlags<dimensions> flags = {}) explicit noexcept

Construct a compressed image with implementation-specific format.

Parameters
storage Storage of compressed pixel data
format Format of compressed pixel data
size Image size
data Image data
flags Image layout flags

Uses compressedPixelFormatWrap() internally to convert format to CompressedPixelFormat.

For a 3D image, if flags contain ImageFlag3D::CubeMap, the size is expected to match its restrictions.

template<UnsignedInt dimensions> template<class T>
Magnum::CompressedImage<dimensions>::CompressedImage(T format, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data, ImageFlags<dimensions> flags = {}) explicit noexcept

Construct a compressed image with implementation-specific format.

Parameters
format Format of compressed pixel data
size Image size
data Image data
flags Image layout flags

Equivalent to calling CompressedImage(CompressedPixelStorage, T, const VectorTypeFor<dimensions, Int>&, Containers::Array<char>&&, ImageFlags<dimensions>) with default-constructed CompressedPixelStorage.

template<UnsignedInt dimensions>
Magnum::CompressedImage<dimensions>::CompressedImage(CompressedPixelStorage storage) noexcept

Construct an image placeholder.

Parameters
storage Storage of compressed pixel data

Format is undefined, size is zero, data is nullptr and data layout flags are empty. Move over a non-empty instance to make it useful.

template<UnsignedInt dimensions>
Magnum::CompressedImage<dimensions>::CompressedImage() noexcept

Construct an image placeholder.

Equivalent to calling CompressedImage(CompressedPixelStorage) with default-constructed CompressedPixelStorage.

template<UnsignedInt dimensions>
CompressedPixelFormat Magnum::CompressedImage<dimensions>::format() const

Format of compressed pixel data.

Returns either a defined value from the CompressedPixelFormat enum or a wrapped implementation-specific value. Use isCompressedPixelFormatImplementationSpecific() to distinguish the case and compressedPixelFormatUnwrap() to extract an implementation-specific value, if needed.

template<UnsignedInt dimensions>
std::pair<VectorTypeFor<dimensions, std::size_t>, VectorTypeFor<dimensions, std::size_t>> Magnum::CompressedImage<dimensions>::dataProperties() const

Compressed image data properties.

See CompressedPixelStorage::dataProperties() for more information.

template<UnsignedInt dimensions>
Containers::ArrayView<char> Magnum::CompressedImage<dimensions>::data() &

Raw image data.

template<UnsignedInt dimensions>
Containers::ArrayView<const char> Magnum::CompressedImage<dimensions>::data() const &

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

template<UnsignedInt dimensions>
Containers::Array<char> Magnum::CompressedImage<dimensions>::data() && new in 2019.10

Raw image data from a r-value.

Unlike data(), which returns a view, this is equivalent to release() to avoid a dangling view when the temporary instance goes out of scope.

template<UnsignedInt dimensions>
Containers::Array<char> Magnum::CompressedImage<dimensions>::data() const && deleted new in 2019.10

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

template<UnsignedInt dimensions> template<class T>
T* Magnum::CompressedImage<dimensions>::data()

Image data in a particular type.

template<UnsignedInt dimensions> template<class T>
const T* Magnum::CompressedImage<dimensions>::data() const

Image data in a particular type.

template<UnsignedInt dimensions>
Containers::Array<char> Magnum::CompressedImage<dimensions>::release()

Release data storage.

Releases the ownership of the data array and resets size() to zero. The state afterwards is equivalent to moved-from state.