summaryrefslogtreecommitdiff
path: root/platform/osx
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-05-17 07:36:47 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-05-17 07:37:45 -0300
commit98a329670227c726a5d7a196e5cba8dbdd54301b (patch)
tree7346f7a3e38eb35b784ac1a68a227d07cc8881b4 /platform/osx
parentd801ff2b3db2de105c1b36a74ce116e360143d4e (diff)
Removal of Image from Variant, converted to a Resource.
Diffstat (limited to 'platform/osx')
-rw-r--r--platform/osx/os_osx.h2
-rw-r--r--platform/osx/os_osx.mm19
2 files changed, 11 insertions, 10 deletions
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index 2ecc379a7f..ff02bf0794 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -151,7 +151,7 @@ public:
virtual Size2 get_window_size() const;
- virtual void set_icon(const Image &p_icon);
+ virtual void set_icon(const Ref<Image> &p_icon);
virtual MainLoop *get_main_loop() const;
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 7a914a88fb..065506c612 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -1227,26 +1227,27 @@ void OS_OSX::set_window_title(const String &p_title) {
[window_object setTitle:[NSString stringWithUTF8String:p_title.utf8().get_data()]];
}
-void OS_OSX::set_icon(const Image &p_icon) {
+void OS_OSX::set_icon(const Ref<Image> &p_icon) {
- Image img = p_icon;
- img.convert(Image::FORMAT_RGBA8);
+ Ref<Image> img = p_icon;
+ img = img->duplicate();
+ img->convert(Image::FORMAT_RGBA8);
NSBitmapImageRep *imgrep = [[[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL
- pixelsWide:p_icon.get_width()
- pixelsHigh:p_icon.get_height()
+ pixelsWide:img->get_width()
+ pixelsHigh:img->get_height()
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES
isPlanar:NO
colorSpaceName:NSDeviceRGBColorSpace
- bytesPerRow:p_icon.get_width() * 4
+ bytesPerRow:img->get_width() * 4
bitsPerPixel:32] autorelease];
ERR_FAIL_COND(imgrep == nil);
uint8_t *pixels = [imgrep bitmapData];
- int len = img.get_width() * img.get_height();
- PoolVector<uint8_t> data = img.get_data();
+ int len = img->get_width() * img->get_height();
+ PoolVector<uint8_t> data = img->get_data();
PoolVector<uint8_t>::Read r = data.read();
/* Premultiply the alpha channel */
@@ -1258,7 +1259,7 @@ void OS_OSX::set_icon(const Image &p_icon) {
pixels[i * 4 + 3] = alpha;
}
- NSImage *nsimg = [[[NSImage alloc] initWithSize:NSMakeSize(img.get_width(), img.get_height())] autorelease];
+ NSImage *nsimg = [[[NSImage alloc] initWithSize:NSMakeSize(img->get_width(), img->get_height())] autorelease];
ERR_FAIL_COND(nsimg == nil);
[nsimg addRepresentation:imgrep];