From 56a8047c4093c928b8551bbacda796382984512e Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 5 May 2022 20:05:35 +0800 Subject: ... --- src/osx/graphics/quartz/ImageFactory.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/osx/graphics/quartz/ImageFactory.cpp') diff --git a/src/osx/graphics/quartz/ImageFactory.cpp b/src/osx/graphics/quartz/ImageFactory.cpp index 95315e1a..a8c17719 100644 --- a/src/osx/graphics/quartz/ImageFactory.cpp +++ b/src/osx/graphics/quartz/ImageFactory.cpp @@ -35,6 +35,15 @@ std::unique_ptr QuartzImageFactory::CreateBitmap(int width, CGColorSpaceRef color_space = CGColorSpaceCreateDeviceRGB(); + const auto buffer_size = width * height * 4; + auto buffer = new unsigned char[buffer_size]; + + auto cg_data_provider = CGDataProviderCreateWithData( + nullptr, buffer, buffer_size, + [](void* info, const void* data, size_t size) { + delete[] static_cast(data); + }); + auto cg_image = CGImageCreate(width, height, 8, 32, 4 * width, color_space, kCGImageAlphaLast, nullptr, nullptr, true, kCGRenderingIntentDefault); @@ -42,6 +51,6 @@ std::unique_ptr QuartzImageFactory::CreateBitmap(int width, CGColorSpaceRelease(color_space); return std::unique_ptr( - new QuartzImage(GetGraphicsFactory(), this, cg_image, true)); + new QuartzImage(GetGraphicsFactory(), this, cg_image, true, buffer)); } } // namespace cru::platform::graphics::osx::quartz -- cgit v1.2.3