From 41623c6ad6f42ca5d6e9a38061f809929641e5c6 Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 2 Feb 2022 19:52:24 +0800 Subject: ... --- src/osx/graphics/quartz/Image.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/osx/graphics/quartz/Image.cpp') 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 QuartzImage::CreateWithRect(const Rect& rect) { + auto new_cg_image = CGImageCreateWithImageInRect(image_, Convert(rect)); + + return std::make_unique(GetGraphicsFactory(), image_factory_, + new_cg_image, true); +} } // namespace cru::platform::graphics::osx::quartz -- cgit v1.2.3