diff options
author | crupest <crupest@outlook.com> | 2022-02-01 18:53:35 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-02-01 18:53:35 +0800 |
commit | 4a8192bf6b614708d8729cb3a87f938860c229b2 (patch) | |
tree | 016e80c7d04b486bea81decc7dce50e928d58591 | |
parent | d1c14725443399f7145e314d79597ec35b639eeb (diff) | |
download | cru-4a8192bf6b614708d8729cb3a87f938860c229b2.tar.gz cru-4a8192bf6b614708d8729cb3a87f938860c229b2.tar.bz2 cru-4a8192bf6b614708d8729cb3a87f938860c229b2.zip |
...
-rw-r--r-- | include/cru/osx/graphics/quartz/Painter.hpp | 2 | ||||
-rw-r--r-- | src/osx/graphics/quartz/Painter.cpp | 11 |
2 files changed, 10 insertions, 3 deletions
diff --git a/include/cru/osx/graphics/quartz/Painter.hpp b/include/cru/osx/graphics/quartz/Painter.hpp index c88987a0..e5b8e767 100644 --- a/include/cru/osx/graphics/quartz/Painter.hpp +++ b/include/cru/osx/graphics/quartz/Painter.hpp @@ -48,7 +48,7 @@ class QuartzCGContextPainter : public OsxQuartzResource, void DrawText(const Point& offset, ITextLayout* text_layout, IBrush* brush) override; - void DrawImage(const Rect& rect, IImage* image) override; + void DrawImage(const Point& offset, IImage* image) override; void PushLayer(const Rect& bounds) override; diff --git a/src/osx/graphics/quartz/Painter.cpp b/src/osx/graphics/quartz/Painter.cpp index 3c39ec61..173cf47a 100644 --- a/src/osx/graphics/quartz/Painter.cpp +++ b/src/osx/graphics/quartz/Painter.cpp @@ -174,10 +174,17 @@ void QuartzCGContextPainter::DrawText(const Point& offset, CGContextRestoreGState(cg_context_); } -void QuartzCGContextPainter::DrawImage(const Rect& rect, IImage* image) { +void QuartzCGContextPainter::DrawImage(const Point& offset, IImage* image) { Validate(); auto i = CheckPlatform<QuartzImage>(image, GetPlatformId()); - CGContextDrawImage(cg_context_, Convert(rect), i->GetCGImage()); + + auto cg_image = i->GetCGImage(); + + auto width = CGImageGetWidth(cg_image); + auto height = CGImageGetHeight(cg_image); + + CGContextDrawImage(cg_context_, CGRectMake(offset.x, offset.y, width, height), + cg_image); } void QuartzCGContextPainter::PushLayer(const Rect& bounds) { |