diff options
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); |
