aboutsummaryrefslogtreecommitdiff
path: root/src/osx/graphics/quartz/ImageFactory.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-05-08 21:36:57 +0800
committercrupest <crupest@outlook.com>2022-05-08 21:36:57 +0800
commit195007d4f00dd2c04a0f2859a8bfff7632a45530 (patch)
tree2f12a344a5d4fc50f18946dec988cdd50ad88069 /src/osx/graphics/quartz/ImageFactory.cpp
parenta1bbc5da1fb0ae4842a54d89136a784832a76978 (diff)
downloadcru-195007d4f00dd2c04a0f2859a8bfff7632a45530.tar.gz
cru-195007d4f00dd2c04a0f2859a8bfff7632a45530.tar.bz2
cru-195007d4f00dd2c04a0f2859a8bfff7632a45530.zip
...
Diffstat (limited to 'src/osx/graphics/quartz/ImageFactory.cpp')
-rw-r--r--src/osx/graphics/quartz/ImageFactory.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/osx/graphics/quartz/ImageFactory.cpp b/src/osx/graphics/quartz/ImageFactory.cpp
index 2c6d4705..5ff262c3 100644
--- a/src/osx/graphics/quartz/ImageFactory.cpp
+++ b/src/osx/graphics/quartz/ImageFactory.cpp
@@ -87,7 +87,7 @@ std::unique_ptr<IImage> QuartzImageFactory::CreateBitmap(int width,
CGColorSpaceRef color_space = CGColorSpaceCreateDeviceRGB();
const auto buffer_size = width * height * 4;
- auto buffer = new unsigned char[buffer_size];
+ auto buffer = new unsigned char[buffer_size]{0};
auto cg_data_provider = CGDataProviderCreateWithData(
nullptr, buffer, buffer_size,
@@ -95,11 +95,13 @@ std::unique_ptr<IImage> QuartzImageFactory::CreateBitmap(int width,
delete[] static_cast<const unsigned char*>(data);
});
- auto cg_image = CGImageCreate(width, height, 8, 32, 4 * width, color_space,
- kCGImageAlphaLast, nullptr, nullptr, true,
- kCGRenderingIntentDefault);
+ auto cg_image =
+ CGImageCreate(width, height, 8, 32, 4 * width, color_space,
+ kCGImageAlphaPremultipliedLast, cg_data_provider, nullptr,
+ true, kCGRenderingIntentDefault);
CGColorSpaceRelease(color_space);
+ CGDataProviderRelease(cg_data_provider);
return std::unique_ptr<IImage>(
new QuartzImage(GetGraphicsFactory(), this, cg_image, true, buffer));