diff options
Diffstat (limited to 'include/cru/platform')
-rw-r--r-- | include/cru/platform/graphics/Image.h | 16 | ||||
-rw-r--r-- | include/cru/platform/graphics/ImageFactory.h | 8 | ||||
-rw-r--r-- | include/cru/platform/graphics/Painter.h | 4 |
3 files changed, 28 insertions, 0 deletions
diff --git a/include/cru/platform/graphics/Image.h b/include/cru/platform/graphics/Image.h index 51e27678..de3b32d5 100644 --- a/include/cru/platform/graphics/Image.h +++ b/include/cru/platform/graphics/Image.h @@ -6,5 +6,21 @@ 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. + * \todo Implement on Windows. + */ + 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 diff --git a/include/cru/platform/graphics/ImageFactory.h b/include/cru/platform/graphics/ImageFactory.h index 2a7902b2..d2c2a468 100644 --- a/include/cru/platform/graphics/ImageFactory.h +++ b/include/cru/platform/graphics/ImageFactory.h @@ -7,5 +7,13 @@ namespace cru::platform::graphics { struct CRU_PLATFORM_GRAPHICS_API IImageFactory : public virtual IGraphicsResource { virtual std::unique_ptr<IImage> DecodeFromStream(io::Stream* stream) = 0; + + /** + * \brief Create an empty bitmap with given width and height. + * \remarks Implementation should ensure that the bitmap supports alpha + * channel. It had better be in 32-bit rgba format. + * \todo Implement on Windows. + */ + virtual std::unique_ptr<IImage> CreateBitmap(int width, int height) = 0; }; } // namespace cru::platform::graphics diff --git a/include/cru/platform/graphics/Painter.h b/include/cru/platform/graphics/Painter.h index 38ff8849..4268133e 100644 --- a/include/cru/platform/graphics/Painter.h +++ b/include/cru/platform/graphics/Painter.h @@ -3,6 +3,10 @@ namespace cru::platform::graphics { +/** + * \brief Painter is a object to paint on something like window, bitmap and etc. + * \remarks Remember to call EndDraw() when you are done with painting. + */ struct CRU_PLATFORM_GRAPHICS_API IPainter : virtual IPlatformResource { virtual Matrix GetTransform() = 0; virtual void SetTransform(const Matrix& matrix) = 0; |