From 75c8a508acc3388b2c2f624bdf00fb155cd914f9 Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 8 May 2022 17:41:31 +0800 Subject: ... --- include/cru/platform/graphics/Image.h | 1 - include/cru/platform/graphics/ImageFactory.h | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'include/cru/platform') 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 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 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 CreateBitmap(int width, int height) = 0; }; -- cgit v1.2.3