aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-05-08 17:41:31 +0800
committercrupest <crupest@outlook.com>2022-05-08 17:41:31 +0800
commit75c8a508acc3388b2c2f624bdf00fb155cd914f9 (patch)
treea80885b8242083e4c2bb793784d0c32af5bc6614 /include
parent2690e9b2ff14a1019ff464e92717a2ca9cbdc056 (diff)
downloadcru-75c8a508acc3388b2c2f624bdf00fb155cd914f9.tar.gz
cru-75c8a508acc3388b2c2f624bdf00fb155cd914f9.tar.bz2
cru-75c8a508acc3388b2c2f624bdf00fb155cd914f9.zip
...
Diffstat (limited to 'include')
-rw-r--r--include/cru/platform/graphics/Image.h1
-rw-r--r--include/cru/platform/graphics/ImageFactory.h15
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;
};