diff options
author | crupest <crupest@outlook.com> | 2022-05-08 17:41:31 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-05-08 17:41:31 +0800 |
commit | 75c8a508acc3388b2c2f624bdf00fb155cd914f9 (patch) | |
tree | a80885b8242083e4c2bb793784d0c32af5bc6614 /include/cru/platform | |
parent | 2690e9b2ff14a1019ff464e92717a2ca9cbdc056 (diff) | |
download | cru-75c8a508acc3388b2c2f624bdf00fb155cd914f9.tar.gz cru-75c8a508acc3388b2c2f624bdf00fb155cd914f9.tar.bz2 cru-75c8a508acc3388b2c2f624bdf00fb155cd914f9.zip |
...
Diffstat (limited to 'include/cru/platform')
-rw-r--r-- | include/cru/platform/graphics/Image.h | 1 | ||||
-rw-r--r-- | include/cru/platform/graphics/ImageFactory.h | 15 |
2 files changed, 13 insertions, 3 deletions
diff --git a/include/cru/platform/graphics/Image.h b/include/cru/platform/graphics/Image.h index de3b32d5..17d2170e 100644 --- a/include/cru/platform/graphics/Image.h +++ b/include/cru/platform/graphics/Image.h @@ -12,7 +12,6 @@ struct CRU_PLATFORM_GRAPHICS_API IImage : public virtual IGraphicsResource { * \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; diff --git a/include/cru/platform/graphics/ImageFactory.h b/include/cru/platform/graphics/ImageFactory.h index d2c2a468..2339a069 100644 --- a/include/cru/platform/graphics/ImageFactory.h +++ b/include/cru/platform/graphics/ImageFactory.h @@ -1,18 +1,29 @@ #pragma once -#include "Image.h" #include "Resource.h" #include "cru/common/io/Stream.h" namespace cru::platform::graphics { +enum class ImageFormat { Jpeg, Png }; + struct CRU_PLATFORM_GRAPHICS_API IImageFactory : public virtual IGraphicsResource { virtual std::unique_ptr<IImage> DecodeFromStream(io::Stream* stream) = 0; /** + * \brief Encode an image to a stream. + * \param image The image to encode. + * \param stream The stream to write to. + * \param format The format to encode to. + * \param quality The quality to encode to. + * \todo Implement on macOS and Windows. + */ + virtual void EncodeToStream(IImage* image, io::Stream* stream, + ImageFormat format, float quality) = 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; }; |