18#include <AUI/Image/AImageView.h>
25class API_AUI_IMAGE AImage :
public AImageView {
28 friend class ::Cache<AImage, Cache, AUrl>;
29 friend class AImageLoaderRegistry;
30 friend class AImageView;
32 void setPixelAt(std::uint32_t index, glm::ivec4 color);
37 explicit AImage(AImageView imageView) : AImage(imageView.
buffer(), imageView.
size(), imageView.
format()) {}
56 template <AImageVisitor Visitor>
57 auto visit(Visitor&& visitor);
59 void set(glm::uvec2 position, Color c)
noexcept;
61 void insert(glm::uvec2 position, AImageView image);
63 void fill(Color color);
65 void mirrorVertically();
90class AFormattedImage :
public AImage {
92 using Color = AFormattedColor<f>;
93 static constexpr auto FORMAT = f;
95 AFormattedImage() { mFormat = f; }
98 AFormattedImage(glm::uvec2
size) : AImage(
size, f) {}
100 constexpr int format()
const noexcept {
return f; }
103 const Color& get(glm::uvec2 position)
const noexcept {
104 return reinterpret_cast<const Color&
>(
rawDataAt(position));
107 void set(glm::uvec2 position, Color color)
noexcept {
const_cast<Color&
>(get(position)) = color; }
109 void setWithPositionCheck(glm::uvec2 position, Color color)
noexcept {
110 if (glm::any(glm::greaterThanEqual(position,
size()))) {
113 const_cast<Color&
>(get(position)) = color;
117 const Color* begin()
const noexcept {
122 const Color* end()
const noexcept {
127 Color* begin()
noexcept {
128 return reinterpret_cast<Color*
>(AImage::modifiableBuffer().begin());
132 Color* end()
noexcept {
133 return reinterpret_cast<Color*
>(AImage::modifiableBuffer().end());
136 void fill(Color color) { std::fill(begin(), end(), color); }
139 Color averageColor()
const noexcept {
141 aui::zero(accumulator);
143 for (
auto i = begin(); i != end(); ++i) {
151template <AImageVisitor Visitor>
152auto AImage::visit(Visitor&& visitor) {
153 return AImageView::visit([&](
const auto& image) {
154 static constexpr int format = std::decay_t<
decltype(image)>::FORMAT;
Acts like std::string_view but for AByteBuffer.
Definition AByteBufferView.h:24
std::vector-like growing array for byte storage.
Definition AByteBuffer.h:31
void resize(size_t s)
Definition AByteBuffer.h:185
unsigned width() const noexcept
Definition AImageView.h:87
unsigned height() const noexcept
Definition AImageView.h:95
std::uint8_t bytesPerPixel() const noexcept
Definition AImageView.h:111
const char & rawDataAt(glm::uvec2 position) const noexcept
Retrieves reference to raw data at specified position.
Definition AImageView.h:151
AByteBufferView buffer() const noexcept
Definition AImageView.h:71
glm::uvec2 size() const noexcept
Definition AImageView.h:79
const char * data() const noexcept
Shortcut to buffer().data().
Definition AImageView.h:172
APixelFormat format() const noexcept
Definition AImageView.h:103
An add-on to AString with functions for working with the path.
Definition APath.h:128
Uniform Resource Locator implementation.
Definition AUrl.h:31
An std::weak_ptr with AUI extensions.
Definition SharedPtrTypes.h:179