aboutsummaryrefslogtreecommitdiff
path: root/src/osx/graphics/quartz/Image.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-02-02 19:52:24 +0800
committercrupest <crupest@outlook.com>2022-02-02 19:52:24 +0800
commit41623c6ad6f42ca5d6e9a38061f809929641e5c6 (patch)
tree594df8c4450d42eec9d8ef2daab56e3fe7791276 /src/osx/graphics/quartz/Image.cpp
parentf0beab8e5f84ba2c5367f7edadebff0af95d1626 (diff)
downloadcru-41623c6ad6f42ca5d6e9a38061f809929641e5c6.tar.gz
cru-41623c6ad6f42ca5d6e9a38061f809929641e5c6.tar.bz2
cru-41623c6ad6f42ca5d6e9a38061f809929641e5c6.zip
...
Diffstat (limited to 'src/osx/graphics/quartz/Image.cpp')
-rw-r--r--src/osx/graphics/quartz/Image.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/osx/graphics/quartz/Image.cpp b/src/osx/graphics/quartz/Image.cpp
index 901b3ff4..e2664322 100644
--- a/src/osx/graphics/quartz/Image.cpp
+++ b/src/osx/graphics/quartz/Image.cpp
@@ -1,10 +1,12 @@
#include "cru/osx/graphics/quartz/Image.hpp"
+#include "cru/osx/graphics/quartz/Convert.hpp"
namespace cru::platform::graphics::osx::quartz {
QuartzImage::QuartzImage(IGraphicsFactory* graphics_factory,
IImageFactory* image_factory, CGImageRef image,
bool auto_release)
: OsxQuartzResource(graphics_factory),
+ image_factory_(image_factory),
image_(image),
auto_release_(auto_release) {}
@@ -13,4 +15,15 @@ QuartzImage::~QuartzImage() {
CGImageRelease(image_);
}
}
+
+float QuartzImage::GetWidth() { return CGImageGetWidth(image_); }
+
+float QuartzImage::GetHeight() { return CGImageGetHeight(image_); }
+
+std::unique_ptr<IImage> QuartzImage::CreateWithRect(const Rect& rect) {
+ auto new_cg_image = CGImageCreateWithImageInRect(image_, Convert(rect));
+
+ return std::make_unique<QuartzImage>(GetGraphicsFactory(), image_factory_,
+ new_cg_image, true);
+}
} // namespace cru::platform::graphics::osx::quartz