diff options
author | crupest <crupest@outlook.com> | 2022-02-02 19:52:24 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-02-02 19:52:24 +0800 |
commit | 41623c6ad6f42ca5d6e9a38061f809929641e5c6 (patch) | |
tree | 594df8c4450d42eec9d8ef2daab56e3fe7791276 /src/osx/graphics/quartz/Image.cpp | |
parent | f0beab8e5f84ba2c5367f7edadebff0af95d1626 (diff) | |
download | cru-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.cpp | 13 |
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 |