#pragma once // IMVU's images (Pixmap), through pixmap.dll's exported methods rather than depending on their layout (only their // size, for making our own). #include #include #include #include "t5de/imvu/types.hpp" namespace t5de { struct PixmapPixels { std::uint32_t width; std::uint32_t height; std::uint32_t rowBytes; std::uint32_t* pixels; // 0xAARRGGBB, rows rowBytes apart }; // Null if pixmap.dll's methods can't be found. std::optional pixmap_pixels(const imvu::Pixmap& pixmap); // A Pixmap of our own, made and destroyed by pixmap.dll. class OwnedPixmap { public: // Width by height; invalid if pixmap.dll's methods can't be found. OwnedPixmap(int width, int height); OwnedPixmap(const OwnedPixmap&) = delete; OwnedPixmap& operator=(const OwnedPixmap&) = delete; ~OwnedPixmap(); [[nodiscard]] bool valid() const { return valid_; } [[nodiscard]] const imvu::Pixmap& get() const { return *reinterpret_cast(storage_); } // Constructs a copy in result (raw memory for a Pixmap, as for a Pixmap returned by value); an empty Pixmap if // this one isn't valid. imvu::Pixmap* copyTo(imvu::Pixmap* result) const; private: // sizeof(Pixmap) in pixmap.dll: its constructors set 7 fields. alignas(4) std::byte storage_[28]; bool valid_ = false; }; } // namespace t5de