diff options
| author | Juan Linietsky | 2017-05-17 07:36:47 -0300 |
|---|---|---|
| committer | Juan Linietsky | 2017-05-17 07:37:45 -0300 |
| commit | 98a329670227c726a5d7a196e5cba8dbdd54301b (patch) | |
| tree | 7346f7a3e38eb35b784ac1a68a227d07cc8881b4 /scene/gui/color_picker.cpp | |
| parent | d801ff2b3db2de105c1b36a74ce116e360143d4e (diff) | |
| download | godot-98a329670227c726a5d7a196e5cba8dbdd54301b.tar.gz godot-98a329670227c726a5d7a196e5cba8dbdd54301b.tar.zst godot-98a329670227c726a5d7a196e5cba8dbdd54301b.zip | |
Diffstat (limited to 'scene/gui/color_picker.cpp')
| -rw-r--r-- | scene/gui/color_picker.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index adb5e2f0b..264ee6297 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -178,7 +178,7 @@ void ColorPicker::_update_presets() { } } - Image i(size.x * presets.size(), size.y, false, Image::FORMAT_RGB8, img); + Ref<Image> i = memnew(Image(size.x * presets.size(), size.y, false, Image::FORMAT_RGB8, img)); Ref<ImageTexture> t; t.instance(); @@ -399,16 +399,16 @@ void ColorPicker::_screen_input(const InputEvent &ev) { Viewport *r = get_tree()->get_root(); if (!r->get_visible_rect().has_point(Point2(mev.global_x, mev.global_y))) return; - Image img = r->get_screen_capture(); - if (!img.empty()) { + Ref<Image> img = r->get_screen_capture(); + if (!img.is_null()) { last_capture = img; r->queue_screen_capture(); } - if (!last_capture.empty()) { - int pw = last_capture.get_format() == Image::FORMAT_RGBA8 ? 4 : 3; - int ofs = (mev.global_y * last_capture.get_width() + mev.global_x) * pw; + if (last_capture.is_valid() && !last_capture->empty()) { + int pw = last_capture->get_format() == Image::FORMAT_RGBA8 ? 4 : 3; + int ofs = (mev.global_y * last_capture->get_width() + mev.global_x) * pw; - PoolVector<uint8_t>::Read r = last_capture.get_data().read(); + PoolVector<uint8_t>::Read r = last_capture->get_data().read(); Color c(r[ofs + 0] / 255.0, r[ofs + 1] / 255.0, r[ofs + 2] / 255.0); |
