From 4a8192bf6b614708d8729cb3a87f938860c229b2 Mon Sep 17 00:00:00 2001 From: crupest Date: Tue, 1 Feb 2022 18:53:35 +0800 Subject: ... --- include/cru/osx/graphics/quartz/Painter.hpp | 2 +- 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(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) { -- cgit v1.2.3