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 Corrade::Containers::Array, together with storing image size and one of the generic CompressedPixelFormat values:

Containers::Array<char> data;
CompressedImage2D image{CompressedPixelFormat::Bc1RGBUnorm,
    {512, 256}, std::move(data)};

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, {});

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) explicit noexcept
Constructor.
CompressedImage(CompressedPixelFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data) explicit noexcept
Constructor.
template<class T>
CompressedImage(CompressedPixelStorage storage, T format, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data) 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) 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 BasicMutableCompressedImageView<dimensions>()
Conversion to view.
operator BasicCompressedImageView<dimensions>() const

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 storage() const -> CompressedPixelStorage
Storage of compressed pixel data.
auto format() const -> CompressedPixelFormat
Format of compressed pixel data.
auto size() const -> VectorTypeFor<dimensions, Int>
Image size.
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 data.
auto data() const & -> Containers::ArrayView<const char>
auto data() && -> Containers::Array<char>
Raw data from a r-value.
auto data() const && -> Containers::Array<char> deleted
template<class T>
auto data() -> T* deprecated
Image data in a particular type.
template<class T>
auto data() const -> const T* deprecated
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) explicit noexcept

Constructor.

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

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

Constructor.

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

Equivalent to calling CompressedImage(CompressedPixelStorage, CompressedPixelFormat, const VectorTypeFor<dimensions, Int>&, Containers::Array<char>&&) 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) 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

Uses compressedPixelFormatWrap() internally to convert format to CompressedPixelFormat.

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

Construct a compressed image with implementation-specific format.

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

Equivalent to calling CompressedImage(CompressedPixelStorage, T, const VectorTypeFor<dimensions, Int>&, Containers::Array<char>&&) 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 and data is nullptr. 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>
Magnum::CompressedImage<dimensions>::operator BasicCompressedImageView<dimensions>() 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>
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 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() &&

Raw 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

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.