aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/cru/osx/graphics/quartz/Image.h7
-rw-r--r--include/cru/platform/graphics/Image.h15
2 files changed, 21 insertions, 1 deletions
diff --git a/include/cru/osx/graphics/quartz/Image.h b/include/cru/osx/graphics/quartz/Image.h
index 458f5db0..5b3aead9 100644
--- a/include/cru/osx/graphics/quartz/Image.h
+++ b/include/cru/osx/graphics/quartz/Image.h
@@ -9,7 +9,8 @@ namespace cru::platform::graphics::osx::quartz {
class QuartzImage : public OsxQuartzResource, public virtual IImage {
public:
QuartzImage(IGraphicsFactory* graphics_factory, IImageFactory* image_factory,
- CGImageRef image, bool auto_release);
+ CGImageRef image, bool auto_release,
+ unsigned char* buffer = nullptr);
CRU_DELETE_COPY(QuartzImage)
CRU_DELETE_MOVE(QuartzImage)
@@ -22,11 +23,15 @@ class QuartzImage : public OsxQuartzResource, public virtual IImage {
std::unique_ptr<IImage> CreateWithRect(const Rect& rect) override;
+ std::unique_ptr<IPainter> CreatePainter() override;
+
CGImageRef GetCGImage() const { return image_; }
private:
IImageFactory* image_factory_;
CGImageRef image_;
bool auto_release_ = false;
+
+ unsigned char* buffer_;
};
} // namespace cru::platform::graphics::osx::quartz
diff --git a/include/cru/platform/graphics/Image.h b/include/cru/platform/graphics/Image.h
index 51e27678..17d2170e 100644
--- a/include/cru/platform/graphics/Image.h
+++ b/include/cru/platform/graphics/Image.h
@@ -6,5 +6,20 @@ struct CRU_PLATFORM_GRAPHICS_API IImage : public virtual IGraphicsResource {
virtual float GetWidth() = 0;
virtual float GetHeight() = 0;
virtual std::unique_ptr<IImage> CreateWithRect(const Rect& rect) = 0;
+
+ /**
+ * \brief Create a painter for this image.
+ * \remarks Not all image could create a painter. If not this method will
+ * throw. Currently we only ensure images returned by
+ * IImageFactory::CreateBitmap or CloneToBitmap can create a painter.
+ */
+ virtual std::unique_ptr<IPainter> CreatePainter() = 0;
+
+ /**
+ * \brief Create a bitmap image with the same pixels as this image's.
+ * \remarks This method can be used to create a bitmap image, so you can draw
+ * on the new bitmap, if the original image can't be directly painted.
+ */
+ virtual std::unique_ptr<IImage> CloneToBitmap();
};
} // namespace cru::platform::graphics