diff options
131 files changed, 422 insertions, 421 deletions
diff --git a/Tests/LibGfx/BenchmarkGfxPainter.cpp b/Tests/LibGfx/BenchmarkGfxPainter.cpp index 5e763403ed..20bf2d4252 100644 --- a/Tests/LibGfx/BenchmarkGfxPainter.cpp +++ b/Tests/LibGfx/BenchmarkGfxPainter.cpp @@ -25,7 +25,7 @@ BENCHMARK_CASE(diagonal_lines) const int run_count = 50; const int bitmap_size = 2000; - auto bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { bitmap_size, bitmap_size }); + auto bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, { bitmap_size, bitmap_size }); Gfx::Painter painter(*bitmap); for (int run = 0; run < run_count; run++) { @@ -41,7 +41,7 @@ BENCHMARK_CASE(fill) const int run_count = 1000; const int bitmap_size = 2000; - auto bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { bitmap_size, bitmap_size }); + auto bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, { bitmap_size, bitmap_size }); Gfx::Painter painter(*bitmap); for (int run = 0; run < run_count; run++) { @@ -54,7 +54,7 @@ BENCHMARK_CASE(fill_with_gradient) const int run_count = 50; const int bitmap_size = 2000; - auto bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { bitmap_size, bitmap_size }); + auto bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, { bitmap_size, bitmap_size }); Gfx::Painter painter(*bitmap); for (int run = 0; run < run_count; run++) { diff --git a/Userland/Applets/Audio/main.cpp b/Userland/Applets/Audio/main.cpp index a39651c651..83e3a5a540 100644 --- a/Userland/Applets/Audio/main.cpp +++ b/Userland/Applets/Audio/main.cpp @@ -39,11 +39,11 @@ public: update(); }; - m_volume_level_bitmaps.append({ 66, Gfx::Bitmap::load_from_file("/res/icons/16x16/audio-volume-high.png") }); - m_volume_level_bitmaps.append({ 33, Gfx::Bitmap::load_from_file("/res/icons/16x16/audio-volume-medium.png") }); - m_volume_level_bitmaps.append({ 1, Gfx::Bitmap::load_from_file("/res/icons/16x16/audio-volume-low.png") }); - m_volume_level_bitmaps.append({ 0, Gfx::Bitmap::load_from_file("/res/icons/16x16/audio-volume-zero.png") }); - m_volume_level_bitmaps.append({ 0, Gfx::Bitmap::load_from_file("/res/icons/16x16/audio-volume-muted.png") }); + m_volume_level_bitmaps.append({ 66, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-high.png") }); + m_volume_level_bitmaps.append({ 33, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-medium.png") }); + m_volume_level_bitmaps.append({ 1, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-low.png") }); + m_volume_level_bitmaps.append({ 0, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-zero.png") }); + m_volume_level_bitmaps.append({ 0, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-muted.png") }); m_slider_window = add<GUI::Window>(window()); m_slider_window->set_frameless(true); diff --git a/Userland/Applets/Network/main.cpp b/Userland/Applets/Network/main.cpp index be371597bd..d54cf953ae 100644 --- a/Userland/Applets/Network/main.cpp +++ b/Userland/Applets/Network/main.cpp @@ -143,8 +143,8 @@ private: String m_adapter_info; bool m_connected = false; bool m_notifications = true; - RefPtr<Gfx::Bitmap> m_connected_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/network.png"); - RefPtr<Gfx::Bitmap> m_disconnected_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/network-disconnected.png"); + RefPtr<Gfx::Bitmap> m_connected_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/network.png"); + RefPtr<Gfx::Bitmap> m_disconnected_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/network-disconnected.png"); }; int main(int argc, char* argv[]) diff --git a/Userland/Applications/3DFileViewer/main.cpp b/Userland/Applications/3DFileViewer/main.cpp index 95b3f1a7e0..27a1fe34bb 100644 --- a/Userland/Applications/3DFileViewer/main.cpp +++ b/Userland/Applications/3DFileViewer/main.cpp @@ -42,7 +42,7 @@ private: GLContextWidget() : m_mesh_loader(adopt_own(*new WavefrontOBJLoader())) { - m_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { RENDER_WIDTH, RENDER_HEIGHT }); + m_bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, { RENDER_WIDTH, RENDER_HEIGHT }); m_context = GL::create_context(*m_bitmap); start_timer(20); @@ -169,7 +169,7 @@ bool GLContextWidget::load(const String& filename) builder.append(".bmp"); // Attempt to open the texture file from disk - auto texture_image = Gfx::Bitmap::load_from_file(builder.string_view()); + auto texture_image = Gfx::Bitmap::try_load_from_file(builder.string_view()); GLuint tex; glGenTextures(1, &tex); diff --git a/Userland/Applications/Browser/BookmarksBarWidget.cpp b/Userland/Applications/Browser/BookmarksBarWidget.cpp index e8b809b8f8..d6e96595e6 100644 --- a/Userland/Applications/Browser/BookmarksBarWidget.cpp +++ b/Userland/Applications/Browser/BookmarksBarWidget.cpp @@ -190,7 +190,7 @@ void BookmarksBarWidget::model_did_update(unsigned) button.set_button_style(Gfx::ButtonStyle::Coolbar); button.set_text(title); - button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-html.png")); + button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-html.png")); button.set_fixed_size(font().width(title) + 32, 20); button.set_relative_rect(rect); button.set_focus_policy(GUI::FocusPolicy::TabFocus); @@ -242,7 +242,7 @@ void BookmarksBarWidget::update_content_size() auto& bookmark = m_bookmarks.at(i); bookmark.set_visible(false); m_additional_menu->add_action(GUI::Action::create(bookmark.text(), - Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-html.png"), + Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-html.png"), [&](auto&) { bookmark.on_click(0); })); diff --git a/Userland/Applications/Browser/BrowserWindow.cpp b/Userland/Applications/Browser/BrowserWindow.cpp index 5838fd4265..01f0594d1b 100644 --- a/Userland/Applications/Browser/BrowserWindow.cpp +++ b/Userland/Applications/Browser/BrowserWindow.cpp @@ -129,7 +129,7 @@ void BrowserWindow::build_menus() file_menu.add_action(WindowActions::the().create_new_tab_action()); auto close_tab_action = GUI::Action::create( - "&Close Tab", { Mod_Ctrl, Key_W }, Gfx::Bitmap::load_from_file("/res/icons/16x16/close-tab.png"), [this](auto&) { + "&Close Tab", { Mod_Ctrl, Key_W }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/close-tab.png"), [this](auto&) { active_tab().on_tab_close_request(active_tab()); }, this); @@ -221,7 +221,7 @@ void BrowserWindow::build_menus() tab.m_dom_inspector_window = GUI::Window::construct(this); tab.m_dom_inspector_window->resize(300, 500); tab.m_dom_inspector_window->set_title("DOM inspector"); - tab.m_dom_inspector_window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/inspector-object.png")); + tab.m_dom_inspector_window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png")); tab.m_dom_inspector_window->set_main_widget<InspectorWidget>(); } auto* inspector_widget = static_cast<InspectorWidget*>(tab.m_dom_inspector_window->main_widget()); @@ -247,7 +247,7 @@ void BrowserWindow::build_menus() tab.m_console_window = GUI::Window::construct(this); tab.m_console_window->resize(500, 300); tab.m_console_window->set_title("JS Console"); - tab.m_console_window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-javascript.png")); + tab.m_console_window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-javascript.png")); tab.m_console_window->set_main_widget<ConsoleWidget>(); } auto* console_widget = static_cast<ConsoleWidget*>(tab.m_console_window->main_widget()); @@ -259,7 +259,7 @@ void BrowserWindow::build_menus() tab.m_console_window = GUI::Window::construct(this); tab.m_console_window->resize(500, 300); tab.m_console_window->set_title("JS Console"); - tab.m_console_window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-javascript.png")); + tab.m_console_window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-javascript.png")); tab.m_console_window->set_main_widget<ConsoleWidget>(); } auto* console_widget = static_cast<ConsoleWidget*>(tab.m_console_window->main_widget()); @@ -520,7 +520,7 @@ void BrowserWindow::create_new_tab(URL url, bool activate) m_tab_widget->set_bar_visible(!is_fullscreen() && m_tab_widget->children().size() > 1); - auto default_favicon = Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-html.png"); + auto default_favicon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-html.png"); VERIFY(default_favicon); m_tab_widget->set_tab_icon(new_tab, default_favicon); diff --git a/Userland/Applications/Browser/ConsoleWidget.cpp b/Userland/Applications/Browser/ConsoleWidget.cpp index 1b69c858f5..3e5856a6de 100644 --- a/Userland/Applications/Browser/ConsoleWidget.cpp +++ b/Userland/Applications/Browser/ConsoleWidget.cpp @@ -105,7 +105,7 @@ ConsoleWidget::ConsoleWidget() auto& clear_button = bottom_container.add<GUI::Button>(); clear_button.set_fixed_size(22, 22); - clear_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/delete.png")); + clear_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png")); clear_button.set_tooltip("Clear the console output"); clear_button.on_click = [this](auto) { clear_output(); diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp index 9a67166838..aea0f68700 100644 --- a/Userland/Applications/Browser/Tab.cpp +++ b/Userland/Applications/Browser/Tab.cpp @@ -75,7 +75,7 @@ void Tab::view_source(const URL& url, const String& source) editor.set_ruler_visible(true); window->resize(640, 480); window->set_title(url.to_string()); - window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-text.png")); + window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-text.png")); window->show(); } @@ -84,7 +84,7 @@ void Tab::view_dom_tree(const String& dom_tree) auto window = GUI::Window::construct(&this->window()); window->resize(300, 500); window->set_title("DOM inspector"); - window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/inspector-object.png")); + window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png")); window->set_main_widget<InspectorWidget>(); auto* inspector_widget = static_cast<InspectorWidget*>(window->main_widget()); @@ -117,7 +117,7 @@ Tab::Tab(BrowserWindow& window, Type type) for (auto& url : m_history.get_back_title_history()) { i++; m_go_back_context_menu->add_action(GUI::Action::create(url.to_string(), - Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-html.png"), + Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-html.png"), [this, i](auto&) { go_back(i); })); } m_go_back_context_menu->popup(context_menu_event.screen_position()); @@ -132,7 +132,7 @@ Tab::Tab(BrowserWindow& window, Type type) for (auto& url : m_history.get_forward_title_history()) { i++; m_go_forward_context_menu->add_action(GUI::Action::create(url.to_string(), - Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-html.png"), + Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-html.png"), [this, i](auto&) { go_forward(i); })); } m_go_forward_context_menu->popup(context_menu_event.screen_position()); @@ -158,7 +158,7 @@ Tab::Tab(BrowserWindow& window, Type type) m_bookmark_button = toolbar.add<GUI::Button>(); m_bookmark_button->set_button_style(Gfx::ButtonStyle::Coolbar); m_bookmark_button->set_focus_policy(GUI::FocusPolicy::TabFocus); - m_bookmark_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/bookmark-contour.png")); + m_bookmark_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bookmark-contour.png")); m_bookmark_button->set_fixed_size(22, 22); m_bookmark_button->on_click = [this](auto) { @@ -394,10 +394,10 @@ void Tab::update_actions() void Tab::update_bookmark_button(const String& url) { if (BookmarksBarWidget::the().contains_bookmark(url)) { - m_bookmark_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/bookmark-filled.png")); + m_bookmark_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bookmark-filled.png")); m_bookmark_button->set_tooltip("Remove Bookmark"); } else { - m_bookmark_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/bookmark-contour.png")); + m_bookmark_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bookmark-contour.png")); m_bookmark_button->set_tooltip("Add Bookmark"); } } diff --git a/Userland/Applications/Browser/WindowActions.cpp b/Userland/Applications/Browser/WindowActions.cpp index 84a3b952e6..294f0c6950 100644 --- a/Userland/Applications/Browser/WindowActions.cpp +++ b/Userland/Applications/Browser/WindowActions.cpp @@ -24,7 +24,7 @@ WindowActions::WindowActions(GUI::Window& window) VERIFY(!s_the); s_the = this; m_create_new_tab_action = GUI::Action::create( - "&New Tab", { Mod_Ctrl, Key_T }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new-tab.png"), [this](auto&) { + "&New Tab", { Mod_Ctrl, Key_T }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-tab.png"), [this](auto&) { if (on_create_new_tab) on_create_new_tab(); }, diff --git a/Userland/Applications/Calendar/main.cpp b/Userland/Applications/Calendar/main.cpp index 3d0a2885b1..f12bf47690 100644 --- a/Userland/Applications/Calendar/main.cpp +++ b/Userland/Applications/Calendar/main.cpp @@ -54,7 +54,7 @@ int main(int argc, char** argv) auto toolbar = main_widget.find_descendant_of_type_named<GUI::Toolbar>("toolbar"); auto calendar = main_widget.find_descendant_of_type_named<GUI::Calendar>("calendar"); - auto prev_date_action = GUI::Action::create({}, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-back.png"), [&](const GUI::Action&) { + auto prev_date_action = GUI::Action::create({}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"), [&](const GUI::Action&) { unsigned view_month = calendar->view_month(); unsigned view_year = calendar->view_year(); if (calendar->mode() == GUI::Calendar::Month) { @@ -69,7 +69,7 @@ int main(int argc, char** argv) calendar->update_tiles(view_year, view_month); }); - auto next_date_action = GUI::Action::create({}, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"), [&](const GUI::Action&) { + auto next_date_action = GUI::Action::create({}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"), [&](const GUI::Action&) { unsigned view_month = calendar->view_month(); unsigned view_year = calendar->view_year(); if (calendar->mode() == GUI::Calendar::Month) { @@ -84,22 +84,22 @@ int main(int argc, char** argv) calendar->update_tiles(view_year, view_month); }); - auto add_event_action = GUI::Action::create("&Add Event", {}, Gfx::Bitmap::load_from_file("/res/icons/16x16/add-event.png"), [&](const GUI::Action&) { + auto add_event_action = GUI::Action::create("&Add Event", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/add-event.png"), [&](const GUI::Action&) { AddEventDialog::show(calendar->selected_date(), window); }); - auto jump_to_action = GUI::Action::create("Jump to &Today", {}, Gfx::Bitmap::load_from_file("/res/icons/16x16/calendar-date.png"), [&](const GUI::Action&) { + auto jump_to_action = GUI::Action::create("Jump to &Today", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/calendar-date.png"), [&](const GUI::Action&) { calendar->set_selected_date(Core::DateTime::now()); calendar->update_tiles(Core::DateTime::now().year(), Core::DateTime::now().month()); }); - auto view_month_action = GUI::Action::create_checkable("&Month View", { Mod_Ctrl, KeyCode::Key_1 }, Gfx::Bitmap::load_from_file("/res/icons/16x16/calendar-month-view.png"), [&](const GUI::Action&) { + auto view_month_action = GUI::Action::create_checkable("&Month View", { Mod_Ctrl, KeyCode::Key_1 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/calendar-month-view.png"), [&](const GUI::Action&) { if (calendar->mode() == GUI::Calendar::Year) calendar->toggle_mode(); }); view_month_action->set_checked(true); - auto view_year_action = GUI::Action::create_checkable("&Year View", { Mod_Ctrl, KeyCode::Key_2 }, Gfx::Bitmap::load_from_file("/res/icons/16x16/icon-view.png"), [&](const GUI::Action&) { + auto view_year_action = GUI::Action::create_checkable("&Year View", { Mod_Ctrl, KeyCode::Key_2 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/icon-view.png"), [&](const GUI::Action&) { if (calendar->mode() == GUI::Calendar::Month) calendar->toggle_mode(); }); @@ -128,7 +128,7 @@ int main(int argc, char** argv) auto menubar = GUI::Menubar::construct(); auto& file_menu = menubar->add_menu("&File"); - file_menu.add_action(GUI::Action::create("&Add Event", { Mod_Ctrl | Mod_Shift, Key_E }, Gfx::Bitmap::load_from_file("/res/icons/16x16/add-event.png"), + file_menu.add_action(GUI::Action::create("&Add Event", { Mod_Ctrl | Mod_Shift, Key_E }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/add-event.png"), [&](const GUI::Action&) { AddEventDialog::show(calendar->selected_date(), window); })); diff --git a/Userland/Applications/DisplaySettings/DesktopSettingsWidget.cpp b/Userland/Applications/DisplaySettings/DesktopSettingsWidget.cpp index 122852e4bb..1619268e4f 100644 --- a/Userland/Applications/DisplaySettings/DesktopSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/DesktopSettingsWidget.cpp @@ -32,7 +32,7 @@ void DesktopSettingsWidget::create_frame() load_from_gml(desktop_settings_gml); auto& light_bulb_label = *find_descendant_of_type_named<GUI::Label>("light_bulb_label"); - light_bulb_label.set_icon(Gfx::Bitmap::load_from_file("/res/icons/32x32/app-welcome.png")); + light_bulb_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-welcome.png")); m_virtual_desktop_rows_spinbox = *find_descendant_of_type_named<GUI::SpinBox>("virtual_desktop_rows_spinbox"); m_virtual_desktop_columns_spinbox = *find_descendant_of_type_named<GUI::SpinBox>("virtual_desktop_columns_spinbox"); diff --git a/Userland/Applications/DisplaySettings/MonitorWidget.cpp b/Userland/Applications/DisplaySettings/MonitorWidget.cpp index dfbfcb6e84..db25078f95 100644 --- a/Userland/Applications/DisplaySettings/MonitorWidget.cpp +++ b/Userland/Applications/DisplaySettings/MonitorWidget.cpp @@ -18,8 +18,8 @@ namespace DisplaySettings { MonitorWidget::MonitorWidget() { m_desktop_resolution = GUI::Desktop::the().rect().size(); - m_monitor_bitmap = Gfx::Bitmap::load_from_file("/res/graphics/monitor.png"); - m_desktop_bitmap = Gfx::Bitmap::create(m_monitor_bitmap->format(), { 280, 158 }); + m_monitor_bitmap = Gfx::Bitmap::try_load_from_file("/res/graphics/monitor.png"); + m_desktop_bitmap = Gfx::Bitmap::try_create(m_monitor_bitmap->format(), { 280, 158 }); m_monitor_rect = { { 12, 13 }, m_desktop_bitmap->size() }; set_fixed_size(304, 201); } @@ -37,7 +37,7 @@ bool MonitorWidget::set_wallpaper(String path) return false; } - auto bitmap = Gfx::Bitmap::load_from_file(path); + auto bitmap = Gfx::Bitmap::try_load_from_file(path); if (bitmap) m_wallpaper_bitmap = move(bitmap); m_desktop_wallpaper_path = move(path); @@ -142,7 +142,7 @@ void MonitorWidget::paint_event(GUI::PaintEvent& event) // Render text label scaled with scale factor to hint at its effect. // FIXME: Once bitmaps have intrinsic scale factors, we could create a bitmap with an intrinsic scale factor of m_desktop_scale_factor // and that should give us the same effect with less code. - auto text_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, Gfx::IntSize { painter.font().width(displayed_resolution_string) + 1, painter.font().glyph_height() + 1 }); + auto text_bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, Gfx::IntSize { painter.font().width(displayed_resolution_string) + 1, painter.font().glyph_height() + 1 }); GUI::Painter text_painter(*text_bitmap); text_painter.set_font(painter.font()); diff --git a/Userland/Applications/FileManager/DirectoryView.cpp b/Userland/Applications/FileManager/DirectoryView.cpp index 6b72bc7bfb..e824d7642c 100644 --- a/Userland/Applications/FileManager/DirectoryView.cpp +++ b/Userland/Applications/FileManager/DirectoryView.cpp @@ -553,7 +553,7 @@ void DirectoryView::handle_selection_change() void DirectoryView::setup_actions() { - m_mkdir_action = GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"), [&](const GUI::Action&) { + m_mkdir_action = GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png"), [&](const GUI::Action&) { String value; if (GUI::InputBox::show(window(), value, "Enter name:", "New directory") == GUI::InputBox::ExecOK && !value.is_empty()) { auto new_dir_path = LexicalPath::canonicalized_path(String::formatted("{}/{}", path(), value)); @@ -565,7 +565,7 @@ void DirectoryView::setup_actions() } }); - m_touch_action = GUI::Action::create("New &File...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"), [&](const GUI::Action&) { + m_touch_action = GUI::Action::create("New &File...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"), [&](const GUI::Action&) { String value; if (GUI::InputBox::show(window(), value, "Enter name:", "New file") == GUI::InputBox::ExecOK && !value.is_empty()) { auto new_file_path = LexicalPath::canonicalized_path(String::formatted("{}/{}", path(), value)); @@ -591,7 +591,7 @@ void DirectoryView::setup_actions() } }); - m_open_terminal_action = GUI::Action::create("Open &Terminal Here", Gfx::Bitmap::load_from_file("/res/icons/16x16/app-terminal.png"), [&](auto&) { + m_open_terminal_action = GUI::Action::create("Open &Terminal Here", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png"), [&](auto&) { spawn_terminal(path()); }); diff --git a/Userland/Applications/FileManager/PropertiesWindow.cpp b/Userland/Applications/FileManager/PropertiesWindow.cpp index 3d2d4cf784..4a3570b10d 100644 --- a/Userland/Applications/FileManager/PropertiesWindow.cpp +++ b/Userland/Applications/FileManager/PropertiesWindow.cpp @@ -39,7 +39,7 @@ PropertiesWindow::PropertiesWindow(const String& path, bool disable_rename, Wind set_rect({ 0, 0, 360, 420 }); set_resizable(false); - set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/properties.png")); + set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/properties.png")); auto& tab_widget = main_widget.add<GUI::TabWidget>(); diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp index 4b30104909..c30e66f62e 100644 --- a/Userland/Applications/FileManager/main.cpp +++ b/Userland/Applications/FileManager/main.cpp @@ -353,11 +353,11 @@ int run_in_desktop_mode([[maybe_unused]] RefPtr<Core::ConfigFile> config) auto desktop_view_context_menu = GUI::Menu::construct("Directory View"); - auto file_manager_action = GUI::Action::create("Show in File &Manager", {}, Gfx::Bitmap::load_from_file("/res/icons/16x16/app-file-manager.png"), [&](const GUI::Action&) { + auto file_manager_action = GUI::Action::create("Show in File &Manager", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png"), [&](const GUI::Action&) { Desktop::Launcher::open(URL::create_with_file_protocol(directory_view.path())); }); - auto display_properties_action = GUI::Action::create("&Display Settings", {}, Gfx::Bitmap::load_from_file("/res/icons/16x16/app-display-settings.png"), [&](const GUI::Action&) { + auto display_properties_action = GUI::Action::create("&Display Settings", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-display-settings.png"), [&](const GUI::Action&) { Desktop::Launcher::open(URL::create_with_file_protocol("/bin/DisplaySettings")); }); @@ -527,7 +527,7 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio auto tree_view_directory_context_menu = GUI::Menu::construct("Tree View Directory"); auto tree_view_context_menu = GUI::Menu::construct("Tree View"); - auto open_parent_directory_action = GUI::Action::create("Open &Parent Directory", { Mod_Alt, Key_Up }, Gfx::Bitmap::load_from_file("/res/icons/16x16/open-parent-directory.png"), [&](const GUI::Action&) { + auto open_parent_directory_action = GUI::Action::create("Open &Parent Directory", { Mod_Alt, Key_Up }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open-parent-directory.png"), [&](const GUI::Action&) { directory_view.open_parent_directory(); }); @@ -608,7 +608,7 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio RefPtr<GUI::Action> view_as_columns_action; view_as_icons_action = GUI::Action::create_checkable( - "View as &Icons", { Mod_Ctrl, KeyCode::Key_1 }, Gfx::Bitmap::load_from_file("/res/icons/16x16/icon-view.png"), [&](const GUI::Action&) { + "View as &Icons", { Mod_Ctrl, KeyCode::Key_1 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/icon-view.png"), [&](const GUI::Action&) { directory_view.set_view_mode(DirectoryView::ViewMode::Icon); config->write_entry("DirectoryView", "ViewMode", "Icon"); config->sync(); @@ -616,7 +616,7 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio window); view_as_table_action = GUI::Action::create_checkable( - "View as &Table", { Mod_Ctrl, KeyCode::Key_2 }, Gfx::Bitmap::load_from_file("/res/icons/16x16/table-view.png"), [&](const GUI::Action&) { + "View as &Table", { Mod_Ctrl, KeyCode::Key_2 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/table-view.png"), [&](const GUI::Action&) { directory_view.set_view_mode(DirectoryView::ViewMode::Table); config->write_entry("DirectoryView", "ViewMode", "Table"); config->sync(); @@ -624,7 +624,7 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio window); view_as_columns_action = GUI::Action::create_checkable( - "View as &Columns", { Mod_Ctrl, KeyCode::Key_3 }, Gfx::Bitmap::load_from_file("/res/icons/16x16/columns-view.png"), [&](const GUI::Action&) { + "View as &Columns", { Mod_Ctrl, KeyCode::Key_3 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/columns-view.png"), [&](const GUI::Action&) { directory_view.set_view_mode(DirectoryView::ViewMode::Columns); config->write_entry("DirectoryView", "ViewMode", "Columns"); config->sync(); @@ -686,7 +686,7 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio = GUI::Action::create( "Open in New &Window", {}, - Gfx::Bitmap::load_from_file("/res/icons/16x16/app-file-manager.png"), + Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png"), [&](GUI::Action const& action) { Vector<String> paths; if (action.activator() == tree_view_directory_context_menu) @@ -705,7 +705,7 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio = GUI::Action::create( "Open in &Terminal", {}, - Gfx::Bitmap::load_from_file("/res/icons/16x16/app-terminal.png"), + Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png"), [&](GUI::Action const& action) { Vector<String> paths; if (action.activator() == tree_view_directory_context_menu) @@ -725,7 +725,7 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio = GUI::Action::create( "Create Desktop &Shortcut", {}, - Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-symlink.png"), + Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-symlink.png"), [&](const GUI::Action&) { auto paths = directory_view.selected_file_paths(); if (paths.is_empty()) { @@ -832,12 +832,12 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio }); focus_dependent_delete_action->set_enabled(false); - auto mkdir_action = GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"), [&](const GUI::Action&) { + auto mkdir_action = GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png"), [&](const GUI::Action&) { directory_view.mkdir_action().activate(); refresh_tree_view(); }); - auto touch_action = GUI::Action::create("New &File...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"), [&](const GUI::Action&) { + auto touch_action = GUI::Action::create("New &File...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"), [&](const GUI::Action&) { directory_view.touch_action().activate(); refresh_tree_view(); }); diff --git a/Userland/Applications/FontEditor/FontEditor.cpp b/Userland/Applications/FontEditor/FontEditor.cpp index f66c58c59b..0120a0c810 100644 --- a/Userland/Applications/FontEditor/FontEditor.cpp +++ b/Userland/Applications/FontEditor/FontEditor.cpp @@ -90,7 +90,7 @@ static RefPtr<GUI::Window> create_font_preview_window(FontEditorWidget& editor) }; auto& reload_button = textbox_button_container.add<GUI::Button>(); - reload_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png")); + reload_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png")); reload_button.set_fixed_width(22); reload_button.on_click = [&](auto) { static int i = 1; @@ -155,7 +155,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::BitmapFont>&& m_font_preview_window->update(); }; - m_new_action = GUI::Action::create("&New Font...", { Mod_Ctrl, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-font.png"), [&](auto&) { + m_new_action = GUI::Action::create("&New Font...", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-font.png"), [&](auto&) { if (m_font_modified) { auto result = GUI::MessageBox::show(window(), "Save changes to the current font?", "Unsaved changes", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel); if (result == GUI::Dialog::ExecResult::ExecYes) { @@ -271,7 +271,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::BitmapFont>&& redo(); }); m_redo_action->set_enabled(false); - m_open_preview_action = GUI::Action::create("&Preview Font", { Mod_Ctrl, Key_P }, Gfx::Bitmap::load_from_file("/res/icons/16x16/find.png"), [&](auto&) { + m_open_preview_action = GUI::Action::create("&Preview Font", { Mod_Ctrl, Key_P }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"), [&](auto&) { if (!m_font_preview_window) m_font_preview_window = create_font_preview_window(*this); m_font_preview_window->show(); @@ -333,7 +333,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::BitmapFont>&& m_glyph_editor_widget->set_mode(GlyphEditorWidget::Paint); }; move_glyph_button.set_checkable(true); - move_glyph_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/selection-move.png")); + move_glyph_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/selection-move.png")); GUI::Clipboard::the().on_change = [&](const String& data_type) { m_paste_action->set_enabled(data_type == "glyph/x-fonteditor"); diff --git a/Userland/Applications/Help/ManualModel.cpp b/Userland/Applications/Help/ManualModel.cpp index b365dda2c5..9d2c04a2fc 100644 --- a/Userland/Applications/Help/ManualModel.cpp +++ b/Userland/Applications/Help/ManualModel.cpp @@ -25,9 +25,9 @@ static ManualSectionNode s_sections[] = { ManualModel::ManualModel() { - m_section_open_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/book-open.png")); - m_section_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/book.png")); - m_page_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-unknown.png")); + m_section_open_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book-open.png")); + m_section_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book.png")); + m_page_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-unknown.png")); } Optional<GUI::ModelIndex> ManualModel::index_from_path(const StringView& path) const diff --git a/Userland/Applications/HexEditor/HexEditorWidget.cpp b/Userland/Applications/HexEditor/HexEditorWidget.cpp index 87b62384a5..9dcfe2fb58 100644 --- a/Userland/Applications/HexEditor/HexEditorWidget.cpp +++ b/Userland/Applications/HexEditor/HexEditorWidget.cpp @@ -71,7 +71,7 @@ HexEditorWidget::HexEditorWidget() m_editor->update(); }; - m_new_action = GUI::Action::create("New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"), [this](const GUI::Action&) { + m_new_action = GUI::Action::create("New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"), [this](const GUI::Action&) { String value; if (request_close() && GUI::InputBox::show(window(), value, "Enter new file size:", "New file size") == GUI::InputBox::ExecOK && !value.is_empty()) { auto file_size = value.to_int(); @@ -134,7 +134,7 @@ HexEditorWidget::HexEditorWidget() dbgln("Wrote document to {}", save_path.value()); }); - m_find_action = GUI::Action::create("&Find", { Mod_Ctrl, Key_F }, Gfx::Bitmap::load_from_file("/res/icons/16x16/find.png"), [&](const GUI::Action&) { + m_find_action = GUI::Action::create("&Find", { Mod_Ctrl, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"), [&](const GUI::Action&) { auto old_buffer = m_search_buffer; bool find_all = false; if (FindDialog::show(window(), m_search_text, m_search_buffer, find_all) == GUI::InputBox::ExecOK) { @@ -171,7 +171,7 @@ HexEditorWidget::HexEditorWidget() } }); - m_goto_offset_action = GUI::Action::create("&Go to Offset ...", { Mod_Ctrl, Key_G }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-to.png"), [this](const GUI::Action&) { + m_goto_offset_action = GUI::Action::create("&Go to Offset ...", { Mod_Ctrl, Key_G }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png"), [this](const GUI::Action&) { int new_offset; auto result = GoToOffsetDialog::show( window(), @@ -239,7 +239,7 @@ void HexEditorWidget::initialize_menubar(GUI::Menubar& menubar) edit_menu.add_action(GUI::Action::create("Copy &Hex", { Mod_Ctrl, Key_C }, [&](const GUI::Action&) { m_editor->copy_selected_hex_to_clipboard(); })); - edit_menu.add_action(GUI::Action::create("Copy &Text", { Mod_Ctrl | Mod_Shift, Key_C }, Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-copy.png"), [&](const GUI::Action&) { + edit_menu.add_action(GUI::Action::create("Copy &Text", { Mod_Ctrl | Mod_Shift, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png"), [&](const GUI::Action&) { m_editor->copy_selected_text_to_clipboard(); })); edit_menu.add_action(GUI::Action::create("Copy as &C Code", { Mod_Alt | Mod_Shift, Key_C }, [&](const GUI::Action&) { @@ -247,7 +247,7 @@ void HexEditorWidget::initialize_menubar(GUI::Menubar& menubar) })); edit_menu.add_separator(); edit_menu.add_action(*m_find_action); - edit_menu.add_action(GUI::Action::create("Find &Next", { Mod_None, Key_F3 }, Gfx::Bitmap::load_from_file("/res/icons/16x16/find-next.png"), [&](const GUI::Action&) { + edit_menu.add_action(GUI::Action::create("Find &Next", { Mod_None, Key_F3 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-next.png"), [&](const GUI::Action&) { if (m_search_text.is_empty() || m_search_buffer.is_empty()) { GUI::MessageBox::show(window(), "Nothing to search for", "Not found", GUI::MessageBox::Type::Warning); return; @@ -262,7 +262,7 @@ void HexEditorWidget::initialize_menubar(GUI::Menubar& menubar) m_last_found_index = result; })); - edit_menu.add_action(GUI::Action::create("Find All &Strings", { Mod_Ctrl | Mod_Shift, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/16x16/find.png"), [&](const GUI::Action&) { + edit_menu.add_action(GUI::Action::create("Find All &Strings", { Mod_Ctrl | Mod_Shift, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"), [&](const GUI::Action&) { int min_length = 4; auto matches = m_editor->find_all_strings(min_length); m_search_results->set_model(*new SearchResultsModel(move(matches))); diff --git a/Userland/Applications/IRCClient/IRCAppWindow.cpp b/Userland/Applications/IRCClient/IRCAppWindow.cpp index c769299db0..8a800d7e58 100644 --- a/Userland/Applications/IRCClient/IRCAppWindow.cpp +++ b/Userland/Applications/IRCClient/IRCAppWindow.cpp @@ -33,7 +33,7 @@ IRCAppWindow::IRCAppWindow(String server, int port) VERIFY(!s_the); s_the = this; - set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-irc-client.png")); + set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-irc-client.png")); update_title(); resize(600, 400); @@ -85,17 +85,17 @@ void IRCAppWindow::setup_client() void IRCAppWindow::setup_actions() { - m_join_action = GUI::Action::create("&Join Channel...", { Mod_Ctrl, Key_J }, Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-join.png"), [&](auto&) { + m_join_action = GUI::Action::create("&Join Channel...", { Mod_Ctrl, Key_J }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/irc-join.png"), [&](auto&) { String value; if (GUI::InputBox::show(this, value, "Enter channel name:", "Join Channel") == GUI::InputBox::ExecOK && !value.is_empty()) m_client->handle_join_action(value); }); - m_list_channels_action = GUI::Action::create("&List Channels", Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-list.png"), [&](auto&) { + m_list_channels_action = GUI::Action::create("&List Channels", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/irc-list.png"), [&](auto&) { m_client->handle_list_channels_action(); }); - m_part_action = GUI::Action::create("&Part from Channel", { Mod_Ctrl, Key_P }, Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-part.png"), [this](auto&) { + m_part_action = GUI::Action::create("&Part from Channel", { Mod_Ctrl, Key_P }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/irc-part.png"), [this](auto&) { auto* window = m_client->current_window(); if (!window || window->type() != IRCWindow::Type::Channel) { return; @@ -103,29 +103,29 @@ void IRCAppWindow::setup_actions() m_client->handle_part_action(window->channel().name()); }); - m_whois_action = GUI::Action::create("&Whois User...", Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-whois.png"), [&](auto&) { + m_whois_action = GUI::Action::create("&Whois User...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/irc-whois.png"), [&](auto&) { String value; if (GUI::InputBox::show(this, value, "Enter nickname:", "Whois User") == GUI::InputBox::ExecOK && !value.is_empty()) m_client->handle_whois_action(value); }); - m_open_query_action = GUI::Action::create("Open &Query...", { Mod_Ctrl, Key_O }, Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-open-query.png"), [&](auto&) { + m_open_query_action = GUI::Action::create("Open &Query...", { Mod_Ctrl, Key_O }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/irc-open-query.png"), [&](auto&) { String value; if (GUI::InputBox::show(this, value, "Enter nickname:", "Open Query") == GUI::InputBox::ExecOK && !value.is_empty()) m_client->handle_open_query_action(value); }); - m_close_query_action = GUI::Action::create("&Close Query", { Mod_Ctrl, Key_D }, Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-close-query.png"), [](auto&) { + m_close_query_action = GUI::Action::create("&Close Query", { Mod_Ctrl, Key_D }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/irc-close-query.png"), [](auto&) { outln("FIXME: Implement close-query action"); }); - m_change_nick_action = GUI::Action::create("Change &Nickname...", Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-nick.png"), [this](auto&) { + m_change_nick_action = GUI::Action::create("Change &Nickname...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/irc-nick.png"), [this](auto&) { String value; if (GUI::InputBox::show(this, value, "Enter nickname:", "Change Nickname") == GUI::InputBox::ExecOK && !value.is_empty()) m_client->handle_change_nick_action(value); }); - m_change_topic_action = GUI::Action::create("Change &Topic...", Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-topic.png"), [this](auto&) { + m_change_topic_action = GUI::Action::create("Change &Topic...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/irc-topic.png"), [this](auto&) { auto* window = m_client->current_window(); if (!window || window->type() != IRCWindow::Type::Channel) { return; @@ -135,7 +135,7 @@ void IRCAppWindow::setup_actions() m_client->handle_change_topic_action(window->channel().name(), value); }); - m_invite_user_action = GUI::Action::create("&Invite User...", Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-invite.png"), [this](auto&) { + m_invite_user_action = GUI::Action::create("&Invite User...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/irc-invite.png"), [this](auto&) { auto* window = m_client->current_window(); if (!window || window->type() != IRCWindow::Type::Channel) { return; diff --git a/Userland/Applications/IRCClient/IRCWindow.cpp b/Userland/Applications/IRCClient/IRCWindow.cpp index 03345b53aa..de822d6f8d 100644 --- a/Userland/Applications/IRCClient/IRCWindow.cpp +++ b/Userland/Applications/IRCClient/IRCWindow.cpp @@ -55,14 +55,14 @@ IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& na m_context_menu = GUI::Menu::construct(); - m_context_menu->add_action(GUI::Action::create("Open &Query", Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-open-query.png"), [&](const GUI::Action&) { + m_context_menu->add_action(GUI::Action::create("Open &Query", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/irc-open-query.png"), [&](const GUI::Action&) { auto nick = channel().member_model()->nick_at(member_view.selection().first()); if (nick.is_empty()) return; m_client->handle_open_query_action(m_client->nick_without_prefix(nick.characters())); })); - m_context_menu->add_action(GUI::Action::create("Whois", Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-whois.png"), [&](const GUI::Action&) { + m_context_menu->add_action(GUI::Action::create("Whois", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/irc-whois.png"), [&](const GUI::Action&) { auto nick = channel().member_model()->nick_at(member_view.selection().first()); if (nick.is_empty()) return; @@ -227,7 +227,7 @@ void IRCWindow::post_notification_if_needed(const String& name, const String& me notification->set_title(name); } - notification->set_icon(Gfx::Bitmap::load_from_file("/res/icons/32x32/app-irc-client.png")); + notification->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-irc-client.png")); notification->set_text(message); notification->show(); } diff --git a/Userland/Applications/ImageViewer/main.cpp b/Userland/Applications/ImageViewer/main.cpp index cbd3cf5804..602628bc4c 100644 --- a/Userland/Applications/ImageViewer/main.cpp +++ b/Userland/Applications/ImageViewer/main.cpp @@ -179,22 +179,22 @@ int main(int argc, char** argv) GUI::Desktop::the().set_wallpaper(widget.path()); }); - auto go_first_action = GUI::Action::create("&Go to First", { Mod_None, Key_Home }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-first.png"), + auto go_first_action = GUI::Action::create("&Go to First", { Mod_None, Key_Home }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-first.png"), [&](auto&) { widget.navigate(ViewWidget::Directions::First); }); - auto go_back_action = GUI::Action::create("Go &Back", { Mod_None, Key_Left }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-back.png"), + auto go_back_action = GUI::Action::create("Go &Back", { Mod_None, Key_Left }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"), [&](auto&) { widget.navigate(ViewWidget::Directions::Back); }); - auto go_forward_action = GUI::Action::create("Go &Forward", { Mod_None, Key_Right }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"), + auto go_forward_action = GUI::Action::create("Go &Forward", { Mod_None, Key_Right }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"), [&](auto&) { widget.navigate(ViewWidget::Directions::Forward); }); - auto go_last_action = GUI::Action::create("Go to &Last", { Mod_None, Key_End }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-last.png"), + auto go_last_action = GUI::Action::create("Go to &Last", { Mod_None, Key_End }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-last.png"), [&](auto&) { widget.navigate(ViewWidget::Directions::Last); }); diff --git a/Userland/Applications/MouseSettings/DoubleClickArrowWidget.cpp b/Userland/Applications/MouseSettings/DoubleClickArrowWidget.cpp index 5f5c508f5b..a71b774ea8 100644 --- a/Userland/Applications/MouseSettings/DoubleClickArrowWidget.cpp +++ b/Userland/Applications/MouseSettings/DoubleClickArrowWidget.cpp @@ -27,7 +27,7 @@ void DoubleClickArrowWidget::set_double_click_speed(int speed) DoubleClickArrowWidget::DoubleClickArrowWidget() { - m_arrow_bitmap = Gfx::Bitmap::load_from_file("/res/graphics/double-click-down-arrow.png"); + m_arrow_bitmap = Gfx::Bitmap::try_load_from_file("/res/graphics/double-click-down-arrow.png"); } void DoubleClickArrowWidget::paint_event(GUI::PaintEvent& event) diff --git a/Userland/Applications/MouseSettings/MouseSettingsWindow.cpp b/Userland/Applications/MouseSettings/MouseSettingsWindow.cpp index 63ffe80762..64feb353f8 100644 --- a/Userland/Applications/MouseSettings/MouseSettingsWindow.cpp +++ b/Userland/Applications/MouseSettings/MouseSettingsWindow.cpp @@ -63,10 +63,10 @@ MouseSettingsWindow::MouseSettingsWindow() m_speed_slider->set_value(slider_value); auto& cursor_speed_image_label = *main_widget.find_descendant_of_type_named<GUI::Label>("cursor_speed_image_label"); - cursor_speed_image_label.set_icon(Gfx::Bitmap::load_from_file("/res/graphics/mouse-cursor-speed.png")); + cursor_speed_image_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/graphics/mouse-cursor-speed.png")); auto& scroll_step_size_image_label = *main_widget.find_descendant_of_type_named<GUI::Label>("scroll_step_size_image_label"); - scroll_step_size_image_label.set_icon(Gfx::Bitmap::load_from_file("/res/graphics/scroll-wheel-step-size.png")); + scroll_step_size_image_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/graphics/scroll-wheel-step-size.png")); m_scroll_length_spinbox = *main_widget.find_descendant_of_type_named<GUI::SpinBox>("scroll_length_spinbox"); m_scroll_length_spinbox->set_min(WindowServer::scroll_step_size_min); diff --git a/Userland/Applications/PDFViewer/OutlineModel.cpp b/Userland/Applications/PDFViewer/OutlineModel.cpp index b72c9b9c20..290b8194a7 100644 --- a/Userland/Applications/PDFViewer/OutlineModel.cpp +++ b/Userland/Applications/PDFViewer/OutlineModel.cpp @@ -15,8 +15,8 @@ NonnullRefPtr<OutlineModel> OutlineModel::create(const NonnullRefPtr<PDF::Outlin OutlineModel::OutlineModel(const NonnullRefPtr<PDF::OutlineDict>& outline) : m_outline(outline) { - m_closed_item_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/book.png")); - m_open_item_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/book-open.png")); + m_closed_item_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book.png")); + m_open_item_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book-open.png")); } void OutlineModel::set_index_open_state(const GUI::ModelIndex& index, bool is_open) diff --git a/Userland/Applications/PDFViewer/PDFViewer.cpp b/Userland/Applications/PDFViewer/PDFViewer.cpp index de59df46aa..b41b857299 100644 --- a/Userland/Applications/PDFViewer/PDFViewer.cpp +++ b/Userland/Applications/PDFViewer/PDFViewer.cpp @@ -145,7 +145,7 @@ RefPtr<Gfx::Bitmap> PDFViewer::render_page(const PDF::Page& page) auto height = static_cast<float>(this->height() - 2 * frame_thickness() - PAGE_PADDING * 2) * zoom_scale_factor; auto width = height / page_scale_factor; - auto bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, { width, height }); + auto bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, { width, height }); PDF::Renderer::render(*m_document, page, bitmap); diff --git a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp index 0ed29cdc68..b818f97b59 100644 --- a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp +++ b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp @@ -58,7 +58,7 @@ void PDFViewerWidget::create_toolbar() auto& toolbar = toolbar_container.add<GUI::Toolbar>(); auto open_outline_action = GUI::Action::create( - "Open &Sidebar", { Mod_Ctrl, Key_O }, Gfx::Bitmap::load_from_file("/res/icons/16x16/sidebar.png"), [&](auto& action) { + "Open &Sidebar", { Mod_Ctrl, Key_O }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/sidebar.png"), [&](auto& action) { m_sidebar_open = !m_sidebar_open; m_sidebar->set_fixed_width(m_sidebar_open ? 0 : 200); action.set_text(m_sidebar_open ? "Open &Sidebar" : "Close &Sidebar"); @@ -70,13 +70,13 @@ void PDFViewerWidget::create_toolbar() toolbar.add_action(*open_outline_action); toolbar.add_separator(); - m_go_to_prev_page_action = GUI::Action::create("Go to &Previous Page", Gfx::Bitmap::load_from_file("/res/icons/16x16/go-up.png"), [&](auto&) { + m_go_to_prev_page_action = GUI::Action::create("Go to &Previous Page", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-up.png"), [&](auto&) { VERIFY(m_viewer->current_page() > 0); m_page_text_box->set_current_number(m_viewer->current_page()); }); m_go_to_prev_page_action->set_enabled(false); - m_go_to_next_page_action = GUI::Action::create("Go to &Next Page", Gfx::Bitmap::load_from_file("/res/icons/16x16/go-down.png"), [&](auto&) { + m_go_to_next_page_action = GUI::Action::create("Go to &Next Page", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-down.png"), [&](auto&) { VERIFY(m_viewer->current_page() < m_viewer->document()->get_page_count() - 1); m_page_text_box->set_current_number(m_viewer->current_page() + 2); }); diff --git a/Userland/Applications/Piano/PlayerWidget.cpp b/Userland/Applications/Piano/PlayerWidget.cpp index 3faab0f7cd..4a52bee5b5 100644 --- a/Userland/Applications/Piano/PlayerWidget.cpp +++ b/Userland/Applications/Piano/PlayerWidget.cpp @@ -19,10 +19,10 @@ PlayerWidget::PlayerWidget(TrackManager& manager, AudioPlayerLoop& loop) set_layout<GUI::HorizontalBoxLayout>(); set_fill_with_background_color(true); - m_play_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/play.png"); - m_pause_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/pause.png"); - m_back_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/go-back.png"); // Go back a note - m_next_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"); // Advance a note + m_play_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/play.png"); + m_pause_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/pause.png"); + m_back_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"); // Go back a note + m_next_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"); // Advance a note m_play_button = add<GUI::Button>(); m_play_button->set_icon(*m_pause_icon); diff --git a/Userland/Applications/Piano/RollWidget.cpp b/Userland/Applications/Piano/RollWidget.cpp index 5c4e68efa6..3886337302 100644 --- a/Userland/Applications/Piano/RollWidget.cpp +++ b/Userland/Applications/Piano/RollWidget.cpp @@ -72,7 +72,7 @@ void RollWidget::paint_event(GUI::PaintEvent& event) // Draw the background, if necessary. if (viewport_changed() || paint_area != m_background->height()) { - m_background = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, Gfx::IntSize(m_roll_width, paint_area)); + m_background = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, Gfx::IntSize(m_roll_width, paint_area)); Gfx::Painter background_painter(*m_background); background_painter.translate(frame_thickness(), frame_thickness()); diff --git a/Userland/Applications/Piano/SamplerWidget.cpp b/Userland/Applications/Piano/SamplerWidget.cpp index e6ee863a0b..c9215ec08a 100644 --- a/Userland/Applications/Piano/SamplerWidget.cpp +++ b/Userland/Applications/Piano/SamplerWidget.cpp @@ -84,7 +84,7 @@ SamplerWidget::SamplerWidget(TrackManager& track_manager) m_open_button = m_open_button_and_recorded_sample_name_container->add<GUI::Button>(); m_open_button->set_fixed_size(24, 24); m_open_button->set_focus_policy(GUI::FocusPolicy::TabFocus); - m_open_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png")); + m_open_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png")); m_open_button->on_click = [this](auto) { Optional<String> open_path = GUI::FilePicker::get_open_filepath(window()); if (!open_path.has_value()) diff --git a/Userland/Applications/PixelPaint/Image.cpp b/Userland/Applications/PixelPaint/Image.cpp index 0e01f45b3b..f1443cb4bb 100644 --- a/Userland/Applications/PixelPaint/Image.cpp +++ b/Userland/Applications/PixelPaint/Image.cpp @@ -194,7 +194,7 @@ Result<void, String> Image::write_to_file(const String& file_path) const RefPtr<Gfx::Bitmap> Image::try_compose_bitmap(Gfx::BitmapFormat format) const { - auto bitmap = Gfx::Bitmap::create(format, m_size); + auto bitmap = Gfx::Bitmap::try_create(format, m_size); if (!bitmap) return nullptr; GUI::Painter painter(*bitmap); diff --git a/Userland/Applications/PixelPaint/Layer.cpp b/Userland/Applications/PixelPaint/Layer.cpp index 29f5332bce..c0be453314 100644 --- a/Userland/Applications/PixelPaint/Layer.cpp +++ b/Userland/Applications/PixelPaint/Layer.cpp @@ -19,7 +19,7 @@ RefPtr<Layer> Layer::try_create_with_size(Image& image, Gfx::IntSize const& size if (size.width() > 16384 || size.height() > 16384) return nullptr; - auto bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, size); + auto bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, size); if (!bitmap) return nullptr; @@ -97,7 +97,7 @@ RefPtr<Gfx::Bitmap> Layer::try_copy_bitmap(Selection const& selection) const } auto selection_rect = selection.bounding_rect(); - auto result = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, selection_rect.size()); + auto result = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, selection_rect.size()); VERIFY(result->has_alpha_channel()); for (int y = selection_rect.top(); y <= selection_rect.bottom(); y++) { diff --git a/Userland/Applications/PixelPaint/MoveTool.cpp b/Userland/Applications/PixelPaint/MoveTool.cpp index dc6748c0f5..b93e02cfcd 100644 --- a/Userland/Applications/PixelPaint/MoveTool.cpp +++ b/Userland/Applications/PixelPaint/MoveTool.cpp @@ -103,7 +103,7 @@ void MoveTool::on_context_menu(Layer& layer, GUI::ContextMenuEvent& event) m_editor)); m_context_menu->add_separator(); m_context_menu->add_action(GUI::Action::create( - "&Delete Layer", Gfx::Bitmap::load_from_file("/res/icons/16x16/delete.png"), [this](auto&) { + "&Delete Layer", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png"), [this](auto&) { m_editor->image().remove_layer(*m_context_menu_layer); // FIXME: This should not be done imperatively here. Perhaps a Image::Client interface that ImageEditor can implement? if (m_editor->active_layer() == m_context_menu_layer) diff --git a/Userland/Applications/PixelPaint/ToolboxWidget.cpp b/Userland/Applications/PixelPaint/ToolboxWidget.cpp index c12c1870ab..17eabaa19c 100644 --- a/Userland/Applications/PixelPaint/ToolboxWidget.cpp +++ b/Userland/Applications/PixelPaint/ToolboxWidget.cpp @@ -50,7 +50,7 @@ ToolboxWidget::~ToolboxWidget() void ToolboxWidget::setup_tools() { auto add_tool = [&](String name, StringView const& icon_name, GUI::Shortcut const& shortcut, NonnullOwnPtr<Tool> tool) { - auto action = GUI::Action::create_checkable(move(name), shortcut, Gfx::Bitmap::load_from_file(String::formatted("/res/icons/pixelpaint/{}.png", icon_name)), + auto action = GUI::Action::create_checkable(move(name), shortcut, Gfx::Bitmap::try_load_from_file(String::formatted("/res/icons/pixelpaint/{}.png", icon_name)), [this, tool = tool.ptr()](auto& action) { if (action.is_checked()) on_tool_selection(tool); diff --git a/Userland/Applications/PixelPaint/main.cpp b/Userland/Applications/PixelPaint/main.cpp index 212e3c8c23..57f4f4ef45 100644 --- a/Userland/Applications/PixelPaint/main.cpp +++ b/Userland/Applications/PixelPaint/main.cpp @@ -90,7 +90,7 @@ int main(int argc, char** argv) }; auto new_image_action = GUI::Action::create( - "&New Image...", { Mod_Ctrl, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"), [&](auto&) { + "&New Image...", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"), [&](auto&) { auto dialog = PixelPaint::CreateNewImageDialog::construct(window); if (dialog->exec() == GUI::Dialog::ExecOK) { auto image = PixelPaint::Image::try_create_with_size(dialog->image_size()); diff --git a/Userland/Applications/SoundPlayer/NoVisualizationWidget.cpp b/Userland/Applications/SoundPlayer/NoVisualizationWidget.cpp index 3251953e67..04326d0e73 100644 --- a/Userland/Applications/SoundPlayer/NoVisualizationWidget.cpp +++ b/Userland/Applications/SoundPlayer/NoVisualizationWidget.cpp @@ -21,7 +21,7 @@ void NoVisualizationWidget::paint_event(GUI::PaintEvent& event) GUI::Painter painter(*this); if (m_serenity_bg.is_null()) { - m_serenity_bg = Gfx::Bitmap::load_from_file("/res/wallpapers/sunset-retro.png"); + m_serenity_bg = Gfx::Bitmap::try_load_from_file("/res/wallpapers/sunset-retro.png"); } painter.draw_scaled_bitmap(frame_inner_rect(), *m_serenity_bg, m_serenity_bg->rect(), 1.0f); return; diff --git a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp index c2b8ceb2cf..63ebdda6ef 100644 --- a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp +++ b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp @@ -39,11 +39,11 @@ SoundPlayerWidgetAdvancedView::SoundPlayerWidgetAdvancedView(GUI::Window& window m_player_view->set_layout<GUI::VerticalBoxLayout>(); - m_play_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/play.png"); - m_pause_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/pause.png"); - m_stop_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/stop.png"); - m_back_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/go-back.png"); - m_next_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"); + m_play_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/play.png"); + m_pause_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/pause.png"); + m_stop_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/stop.png"); + m_back_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"); + m_next_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"); m_visualization = m_player_view->add<BarsVisualizationWidget>(); diff --git a/Userland/Applications/SpaceAnalyzer/main.cpp b/Userland/Applications/SpaceAnalyzer/main.cpp index 73e8226e6a..052502d6fb 100644 --- a/Userland/Applications/SpaceAnalyzer/main.cpp +++ b/Userland/Applications/SpaceAnalyzer/main.cpp @@ -288,14 +288,14 @@ int main(int argc, char* argv[]) window->set_menubar(move(menubar)); // Configure the nodes context menu. - auto open_folder_action = GUI::Action::create("Open Folder", { Mod_Ctrl, Key_O }, Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"), [&](auto&) { + auto open_folder_action = GUI::Action::create("Open Folder", { Mod_Ctrl, Key_O }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png"), [&](auto&) { Desktop::Launcher::open(URL::create_with_file_protocol(get_absolute_path_to_selected_node(treemapwidget))); }); - auto open_containing_folder_action = GUI::Action::create("Open Containing Folder", { Mod_Ctrl, Key_O }, Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"), [&](auto&) { + auto open_containing_folder_action = GUI::Action::create("Open Containing Folder", { Mod_Ctrl, Key_O }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png"), [&](auto&) { LexicalPath path { get_absolute_path_to_selected_node(treemapwidget) }; Desktop::Launcher::open(URL::create_with_file_protocol(path.dirname(), path.basename())); }); - auto copy_path_action = GUI::Action::create("Copy Path to Clipboard", { Mod_Ctrl, Key_C }, Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-copy.png"), [&](auto&) { + auto copy_path_action = GUI::Action::create("Copy Path to Clipboard", { Mod_Ctrl, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png"), [&](auto&) { GUI::Clipboard::the().set_plain_text(get_absolute_path_to_selected_node(treemapwidget)); }); auto delete_action = GUI::CommonActions::make_delete_action([&](auto&) { diff --git a/Userland/Applications/Spreadsheet/HelpWindow.cpp b/Userland/Applications/Spreadsheet/HelpWindow.cpp index e331054669..f3f07f222c 100644 --- a/Userland/Applications/Spreadsheet/HelpWindow.cpp +++ b/Userland/Applications/Spreadsheet/HelpWindow.cpp @@ -64,7 +64,7 @@ HelpWindow::HelpWindow(GUI::Window* parent) { resize(530, 365); set_title("Spreadsheet Functions Help"); - set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-help.png")); + set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png")); auto& widget = set_main_widget<GUI::Widget>(); widget.set_layout<GUI::VerticalBoxLayout>(); diff --git a/Userland/Applications/Spreadsheet/main.cpp b/Userland/Applications/Spreadsheet/main.cpp index 495c8a52f7..305d6a862a 100644 --- a/Userland/Applications/Spreadsheet/main.cpp +++ b/Userland/Applications/Spreadsheet/main.cpp @@ -88,7 +88,7 @@ int main(int argc, char* argv[]) auto menubar = GUI::Menubar::construct(); auto& file_menu = menubar->add_menu("&File"); - file_menu.add_action(GUI::Action::create("Add New Sheet", Gfx::Bitmap::load_from_file("/res/icons/16x16/new-tab.png"), [&](auto&) { + file_menu.add_action(GUI::Action::create("Add New Sheet", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-tab.png"), [&](auto&) { spreadsheet_widget.add_sheet(); })); file_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) { diff --git a/Userland/Applications/SystemMonitor/main.cpp b/Userland/Applications/SystemMonitor/main.cpp index a8c5dbf909..91a253ff24 100644 --- a/Userland/Applications/SystemMonitor/main.cpp +++ b/Userland/Applications/SystemMonitor/main.cpp @@ -243,7 +243,7 @@ int main(int argc, char** argv) }; auto kill_action = GUI::Action::create( - "&Kill Process", { Mod_Ctrl, Key_K }, Gfx::Bitmap::load_from_file("/res/icons/16x16/kill.png"), [&](const GUI::Action&) { + "&Kill Process", { Mod_Ctrl, Key_K }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/kill.png"), [&](const GUI::Action&) { pid_t pid = selected_id(ProcessModel::Column::PID); if (pid != -1) kill(pid, SIGKILL); @@ -251,7 +251,7 @@ int main(int argc, char** argv) &process_table_view); auto stop_action = GUI::Action::create( - "&Stop Process", { Mod_Ctrl, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/16x16/stop-hand.png"), [&](const GUI::Action&) { + "&Stop Process", { Mod_Ctrl, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/stop-hand.png"), [&](const GUI::Action&) { pid_t pid = selected_id(ProcessModel::Column::PID); if (pid != -1) kill(pid, SIGSTOP); @@ -259,7 +259,7 @@ int main(int argc, char** argv) &process_table_view); auto continue_action = GUI::Action::create( - "&Continue Process", { Mod_Ctrl, Key_C }, Gfx::Bitmap::load_from_file("/res/icons/16x16/continue.png"), [&](const GUI::Action&) { + "&Continue Process", { Mod_Ctrl, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/continue.png"), [&](const GUI::Action&) { pid_t pid = selected_id(ProcessModel::Column::PID); if (pid != -1) kill(pid, SIGCONT); @@ -268,7 +268,7 @@ int main(int argc, char** argv) auto profile_action = GUI::Action::create( "&Profile Process", { Mod_Ctrl, Key_P }, - Gfx::Bitmap::load_from_file("/res/icons/16x16/app-profiler.png"), [&](auto&) { + Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-profiler.png"), [&](auto&) { pid_t pid = selected_id(ProcessModel::Column::PID); if (pid != -1) { auto pid_string = String::number(pid); diff --git a/Userland/Applications/Terminal/main.cpp b/Userland/Applications/Terminal/main.cpp index abfe71bdfa..d4cd02deff 100644 --- a/Userland/Applications/Terminal/main.cpp +++ b/Userland/Applications/Terminal/main.cpp @@ -208,10 +208,10 @@ static RefPtr<GUI::Window> create_find_window(VT::TerminalWidget& terminal) } auto& find_backwards = find.add<GUI::Button>(); find_backwards.set_fixed_width(25); - find_backwards.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/upward-triangle.png")); + find_backwards.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/upward-triangle.png")); auto& find_forwards = find.add<GUI::Button>(); find_forwards.set_fixed_width(25); - find_forwards.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/downward-triangle.png")); + find_forwards.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/downward-triangle.png")); find_textbox.on_return_pressed = [&]() { find_backwards.click(); @@ -352,7 +352,7 @@ int main(int argc, char** argv) auto new_scrollback_size = config->read_num_entry("Terminal", "MaxHistorySize", terminal.max_history_size()); terminal.set_max_history_size(new_scrollback_size); - auto open_settings_action = GUI::Action::create("&Settings", Gfx::Bitmap::load_from_file("/res/icons/16x16/settings.png"), + auto open_settings_action = GUI::Action::create("&Settings", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/settings.png"), [&](const GUI::Action&) { if (!settings_window) settings_window = create_settings_window(terminal); @@ -361,7 +361,7 @@ int main(int argc, char** argv) }); terminal.context_menu().add_separator(); - auto pick_font_action = GUI::Action::create("&Terminal Font...", Gfx::Bitmap::load_from_file("/res/icons/16x16/app-font-editor.png"), + auto pick_font_action = GUI::Action::create("&Terminal Font...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png"), [&](auto&) { auto picker = GUI::FontPicker::construct(window, &terminal.font(), true); if (picker->exec() == GUI::Dialog::ExecOK) { @@ -380,7 +380,7 @@ int main(int argc, char** argv) auto menubar = GUI::Menubar::construct(); auto& file_menu = menubar->add_menu("&File"); - file_menu.add_action(GUI::Action::create("Open New &Terminal", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/app-terminal.png"), [&](auto&) { + file_menu.add_action(GUI::Action::create("Open New &Terminal", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png"), [&](auto&) { pid_t child; const char* argv[] = { "Terminal", nullptr }; if ((errno = posix_spawn(&child, "/bin/Terminal", nullptr, nullptr, const_cast<char**>(argv), environ))) { @@ -402,7 +402,7 @@ int main(int argc, char** argv) edit_menu.add_action(terminal.copy_action()); edit_menu.add_action(terminal.paste_action()); edit_menu.add_separator(); - edit_menu.add_action(GUI::Action::create("&Find...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::load_from_file("/res/icons/16x16/find.png"), + edit_menu.add_action(GUI::Action::create("&Find...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"), [&](auto&) { if (!find_window) find_window = create_find_window(terminal); diff --git a/Userland/Applications/TextEditor/MainWidget.cpp b/Userland/Applications/TextEditor/MainWidget.cpp index bcf4a06b40..f21c1cfc66 100644 --- a/Userland/Applications/TextEditor/MainWidget.cpp +++ b/Userland/Applications/TextEditor/MainWidget.cpp @@ -93,7 +93,7 @@ MainWidget::MainWidget() }; m_wrap_around_checkbox->set_checked(true); - m_find_next_action = GUI::Action::create("Find &Next", { Mod_Ctrl, Key_G }, Gfx::Bitmap::load_from_file("/res/icons/16x16/find-next.png"), [&](auto&) { + m_find_next_action = GUI::Action::create("Find &Next", { Mod_Ctrl, Key_G }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-next.png"), [&](auto&) { auto needle = m_find_textbox->text(); if (needle.is_empty()) return; @@ -112,7 +112,7 @@ MainWidget::MainWidget() } }); - m_find_previous_action = GUI::Action::create("Find Pr&evious", { Mod_Ctrl | Mod_Shift, Key_G }, Gfx::Bitmap::load_from_file("/res/icons/16x16/find-previous.png"), [&](auto&) { + m_find_previous_action = GUI::Action::create("Find Pr&evious", { Mod_Ctrl | Mod_Shift, Key_G }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-previous.png"), [&](auto&) { auto needle = m_find_textbox->text(); if (needle.is_empty()) return; @@ -173,11 +173,11 @@ MainWidget::MainWidget() m_find_previous_button = *find_descendant_of_type_named<GUI::Button>("find_previous_button"); m_find_previous_button->set_action(*m_find_previous_action); - m_find_previous_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/find-previous.png")); + m_find_previous_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-previous.png")); m_find_next_button = *find_descendant_of_type_named<GUI::Button>("find_next_button"); m_find_next_button->set_action(*m_find_next_action); - m_find_next_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/find-next.png")); + m_find_next_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-next.png")); m_find_textbox->on_return_pressed = [this] { m_find_next_button->click(); @@ -211,7 +211,7 @@ MainWidget::MainWidget() }); m_vim_emulation_setting_action->set_checked(false); - m_find_replace_action = GUI::Action::create("&Find/Replace...", { Mod_Ctrl, Key_F }, Gfx::Bitmap::load_from_file("/res/icons/16x16/find.png"), [this](auto&) { + m_find_replace_action = GUI::Action::create("&Find/Replace...", { Mod_Ctrl, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"), [this](auto&) { m_find_replace_widget->set_visible(true); m_find_widget->set_visible(true); m_replace_widget->set_visible(true); @@ -244,7 +244,7 @@ MainWidget::MainWidget() m_editor->on_cursor_change = [this] { update_statusbar(); }; m_editor->on_selection_change = [this] { update_statusbar(); }; - m_new_action = GUI::Action::create("&New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"), [this](GUI::Action const&) { + m_new_action = GUI::Action::create("&New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"), [this](GUI::Action const&) { if (editor().document().is_modified()) { auto save_document_first_result = GUI::MessageBox::show(window(), "Save changes to current document first?", "Warning", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel); if (save_document_first_result == GUI::Dialog::ExecResult::ExecYes) @@ -457,7 +457,7 @@ void MainWidget::initialize_menubar(GUI::Menubar& menubar) view_menu.add_separator(); - view_menu.add_action(GUI::Action::create("Editor &Font...", Gfx::Bitmap::load_from_file("/res/icons/16x16/app-font-editor.png"), + view_menu.add_action(GUI::Action::create("Editor &Font...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png"), [&](auto&) { auto picker = GUI::FontPicker::construct(window(), &m_editor->font(), false); if (picker->exec() == GUI::Dialog::ExecOK) { diff --git a/Userland/Applications/ThemeEditor/PreviewWidget.cpp b/Userland/Applications/ThemeEditor/PreviewWidget.cpp index d47a7e8c20..2825895848 100644 --- a/Userland/Applications/ThemeEditor/PreviewWidget.cpp +++ b/Userland/Applications/ThemeEditor/PreviewWidget.cpp @@ -75,12 +75,12 @@ private: PreviewWidget::PreviewWidget(const Gfx::Palette& preview_palette) : m_preview_palette(preview_palette) { - m_active_window_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/window.png"); - m_inactive_window_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/window.png"); + m_active_window_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png"); + m_inactive_window_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png"); - m_close_bitmap = Gfx::Bitmap::load_from_file("/res/icons/16x16/window-close.png"); - m_maximize_bitmap = Gfx::Bitmap::load_from_file("/res/icons/16x16/upward-triangle.png"); - m_minimize_bitmap = Gfx::Bitmap::load_from_file("/res/icons/16x16/downward-triangle.png"); + m_close_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window-close.png"); + m_maximize_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/upward-triangle.png"); + m_minimize_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/downward-triangle.png"); m_gallery = add<MiniWidgetGallery>(); set_greedy_for_hits(true); diff --git a/Userland/Applications/VideoPlayer/main.cpp b/Userland/Applications/VideoPlayer/main.cpp index 7b1db1db61..c9f9eb5b99 100644 --- a/Userland/Applications/VideoPlayer/main.cpp +++ b/Userland/Applications/VideoPlayer/main.cpp @@ -26,7 +26,7 @@ int main(int argc, char** argv) auto const& track = optional_track.value(); auto const video_track = track.video_track().value(); - auto image = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, Gfx::IntSize(video_track.pixel_height, video_track.pixel_width)); + auto image = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, Gfx::IntSize(video_track.pixel_height, video_track.pixel_width)); auto& main_widget = window->set_main_widget<GUI::Widget>(); main_widget.set_fill_with_background_color(true); main_widget.set_layout<GUI::VerticalBoxLayout>(); diff --git a/Userland/Applications/Welcome/WelcomeWidget.cpp b/Userland/Applications/Welcome/WelcomeWidget.cpp index 0caf473d4d..623cdb65b1 100644 --- a/Userland/Applications/Welcome/WelcomeWidget.cpp +++ b/Userland/Applications/Welcome/WelcomeWidget.cpp @@ -28,14 +28,14 @@ WelcomeWidget::WelcomeWidget() tip_frame.set_fill_with_background_color(true); auto& light_bulb_label = *find_descendant_of_type_named<GUI::Label>("light_bulb_label"); - light_bulb_label.set_icon(Gfx::Bitmap::load_from_file("/res/icons/32x32/app-welcome.png")); + light_bulb_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-welcome.png")); m_web_view = *find_descendant_of_type_named<Web::OutOfProcessWebView>("web_view"); m_tip_label = *find_descendant_of_type_named<GUI::Label>("tip_label"); m_next_button = *find_descendant_of_type_named<GUI::Button>("next_button"); - m_next_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png")); + m_next_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png")); m_next_button->on_click = [&](auto) { if (!tip_frame.is_visible()) { m_web_view->set_visible(false); @@ -50,7 +50,7 @@ WelcomeWidget::WelcomeWidget() }; m_help_button = *find_descendant_of_type_named<GUI::Button>("help_button"); - m_help_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/book-open.png")); + m_help_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book-open.png")); m_help_button->on_click = [](auto) { pid_t pid; const char* argv[] = { "Help", nullptr }; diff --git a/Userland/Demos/CatDog/CatDog.h b/Userland/Demos/CatDog/CatDog.h index 6c730df0a8..bde31f3d6d 100644 --- a/Userland/Demos/CatDog/CatDog.h +++ b/Userland/Demos/CatDog/CatDog.h @@ -48,26 +48,26 @@ private: bool m_up, m_down, m_left, m_right, m_sleeping = false; bool m_roaming { true }; - AK::NonnullRefPtr<Gfx::Bitmap> m_alert = *Gfx::Bitmap::load_from_file("/res/icons/catdog/alert.png"); - AK::NonnullRefPtr<Gfx::Bitmap> m_erun1 = *Gfx::Bitmap::load_from_file("/res/icons/catdog/erun1.png"); - AK::NonnullRefPtr<Gfx::Bitmap> m_erun2 = *Gfx::Bitmap::load_from_file("/res/icons/catdog/erun2.png"); - AK::NonnullRefPtr<Gfx::Bitmap> m_nerun1 = *Gfx::Bitmap::load_from_file("/res/icons/catdog/nerun1.png"); - AK::NonnullRefPtr<Gfx::Bitmap> m_nerun2 = *Gfx::Bitmap::load_from_file("/res/icons/catdog/nerun2.png"); - AK::NonnullRefPtr<Gfx::Bitmap> m_nrun1 = *Gfx::Bitmap::load_from_file("/res/icons/catdog/nrun1.png"); - AK::NonnullRefPtr<Gfx::Bitmap> m_nrun2 = *Gfx::Bitmap::load_from_file("/res/icons/catdog/nrun2.png"); - AK::NonnullRefPtr<Gfx::Bitmap> m_nwrun1 = *Gfx::Bitmap::load_from_file("/res/icons/catdog/nwrun1.png"); - AK::NonnullRefPtr<Gfx::Bitmap> m_nwrun2 = *Gfx::Bitmap::load_from_file("/res/icons/catdog/nwrun2.png"); - AK::NonnullRefPtr<Gfx::Bitmap> m_serun1 = *Gfx::Bitmap::load_from_file("/res/icons/catdog/serun1.png"); - AK::NonnullRefPtr<Gfx::Bitmap> m_serun2 = *Gfx::Bitmap::load_from_file("/res/icons/catdog/serun2.png"); - AK::NonnullRefPtr<Gfx::Bitmap> m_sleep1 = *Gfx::Bitmap::load_from_file("/res/icons/catdog/sleep1.png"); - AK::NonnullRefPtr<Gfx::Bitmap> m_sleep2 = *Gfx::Bitmap::load_from_file("/res/icons/catdog/sleep2.png"); - AK::NonnullRefPtr<Gfx::Bitmap> m_srun1 = *Gfx::Bitmap::load_from_file("/res/icons/catdog/srun1.png"); - AK::NonnullRefPtr<Gfx::Bitmap> m_srun2 = *Gfx::Bitmap::load_from_file("/res/icons/catdog/srun2.png"); - AK::NonnullRefPtr<Gfx::Bitmap> m_still = *Gfx::Bitmap::load_from_file("/res/icons/catdog/still.png"); - AK::NonnullRefPtr<Gfx::Bitmap> m_swrun1 = *Gfx::Bitmap::load_from_file("/res/icons/catdog/swrun1.png"); - AK::NonnullRefPtr<Gfx::Bitmap> m_swrun2 = *Gfx::Bitmap::load_from_file("/res/icons/catdog/swrun2.png"); - AK::NonnullRefPtr<Gfx::Bitmap> m_wrun1 = *Gfx::Bitmap::load_from_file("/res/icons/catdog/wrun1.png"); - AK::NonnullRefPtr<Gfx::Bitmap> m_wrun2 = *Gfx::Bitmap::load_from_file("/res/icons/catdog/wrun2.png"); + AK::NonnullRefPtr<Gfx::Bitmap> m_alert = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/alert.png"); + AK::NonnullRefPtr<Gfx::Bitmap> m_erun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/erun1.png"); + AK::NonnullRefPtr<Gfx::Bitmap> m_erun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/erun2.png"); + AK::NonnullRefPtr<Gfx::Bitmap> m_nerun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nerun1.png"); + AK::NonnullRefPtr<Gfx::Bitmap> m_nerun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nerun2.png"); + AK::NonnullRefPtr<Gfx::Bitmap> m_nrun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nrun1.png"); + AK::NonnullRefPtr<Gfx::Bitmap> m_nrun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nrun2.png"); + AK::NonnullRefPtr<Gfx::Bitmap> m_nwrun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nwrun1.png"); + AK::NonnullRefPtr<Gfx::Bitmap> m_nwrun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nwrun2.png"); + AK::NonnullRefPtr<Gfx::Bitmap> m_serun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/serun1.png"); + AK::NonnullRefPtr<Gfx::Bitmap> m_serun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/serun2.png"); + AK::NonnullRefPtr<Gfx::Bitmap> m_sleep1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/sleep1.png"); + AK::NonnullRefPtr<Gfx::Bitmap> m_sleep2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/sleep2.png"); + AK::NonnullRefPtr<Gfx::Bitmap> m_srun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/srun1.png"); + AK::NonnullRefPtr<Gfx::Bitmap> m_srun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/srun2.png"); + AK::NonnullRefPtr<Gfx::Bitmap> m_still = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/still.png"); + AK::NonnullRefPtr<Gfx::Bitmap> m_swrun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/swrun1.png"); + AK::NonnullRefPtr<Gfx::Bitmap> m_swrun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/swrun2.png"); + AK::NonnullRefPtr<Gfx::Bitmap> m_wrun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/wrun1.png"); + AK::NonnullRefPtr<Gfx::Bitmap> m_wrun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/wrun2.png"); AK::NonnullRefPtr<Gfx::Bitmap> m_curr_bmp = m_alert; CatDog() diff --git a/Userland/Demos/Cube/Cube.cpp b/Userland/Demos/Cube/Cube.cpp index 3dfd33d3e0..84cad9d5a7 100644 --- a/Userland/Demos/Cube/Cube.cpp +++ b/Userland/Demos/Cube/Cube.cpp @@ -60,7 +60,7 @@ private: Cube::Cube() { - m_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { WIDTH, HEIGHT }); + m_bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, { WIDTH, HEIGHT }); m_accumulated_time = 0; m_cycles = 0; diff --git a/Userland/Demos/Fire/Fire.cpp b/Userland/Demos/Fire/Fire.cpp index 6dd10a463e..835379688e 100644 --- a/Userland/Demos/Fire/Fire.cpp +++ b/Userland/Demos/Fire/Fire.cpp @@ -81,7 +81,7 @@ private: Fire::Fire() { - bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::Indexed8, { FIRE_WIDTH, FIRE_HEIGHT }); + bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::Indexed8, { FIRE_WIDTH, FIRE_HEIGHT }); /* Initialize fire palette */ for (int i = 0; i < 30; i++) diff --git a/Userland/Demos/LibGfxDemo/main.cpp b/Userland/Demos/LibGfxDemo/main.cpp index 992906b9e4..c18b1b5246 100644 --- a/Userland/Demos/LibGfxDemo/main.cpp +++ b/Userland/Demos/LibGfxDemo/main.cpp @@ -36,7 +36,7 @@ private: Canvas::Canvas() { - m_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { WIDTH, HEIGHT }); + m_bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, { WIDTH, HEIGHT }); draw(); } @@ -108,7 +108,7 @@ void Canvas::draw() painter.draw_line({ 740, 140 }, { 640, 240 }, Color::Red, 5, Gfx::Painter::LineStyle::Solid); painter.draw_line({ 690, 140 }, { 640, 240 }, Color::Blue, 10, Gfx::Painter::LineStyle::Solid); - auto bg = Gfx::Bitmap::load_from_file("/res/html/misc/90s-bg.png"); + auto bg = Gfx::Bitmap::try_load_from_file("/res/html/misc/90s-bg.png"); painter.draw_tiled_bitmap({ 20, 260, 480, 320 }, *bg); painter.draw_line({ 40, 480 }, { 20, 260 }, Color::Red); @@ -129,7 +129,7 @@ void Canvas::draw() path.close(); painter.fill_path(path, Color::Yellow, Gfx::Painter::WindingRule::EvenOdd); - auto buggie = Gfx::Bitmap::load_from_file("/res/graphics/buggie.png"); + auto buggie = Gfx::Bitmap::try_load_from_file("/res/graphics/buggie.png"); painter.blit({ 280, 280 }, *buggie, buggie->rect(), 0.5); painter.draw_scaled_bitmap({ 360, 280, buggie->rect().width() * 2, buggie->rect().height() * 2 }, *buggie, buggie->rect()); diff --git a/Userland/Demos/LibGfxScaleDemo/main.cpp b/Userland/Demos/LibGfxScaleDemo/main.cpp index 11aa014aed..c9b41de234 100644 --- a/Userland/Demos/LibGfxScaleDemo/main.cpp +++ b/Userland/Demos/LibGfxScaleDemo/main.cpp @@ -41,15 +41,15 @@ private: Canvas::Canvas() { - m_bitmap_1x = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { WIDTH, HEIGHT }, 1); - m_bitmap_2x = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { WIDTH, HEIGHT }, 2); + m_bitmap_1x = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, { WIDTH, HEIGHT }, 1); + m_bitmap_2x = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, { WIDTH, HEIGHT }, 2); // m_bitmap_1x and m_bitmap_2x have the same logical size, so LibGfx will try to draw them at the same physical size: // When drawing on a 2x backing store it'd scale m_bitmap_1x up 2x and paint m_bitmap_2x at its physical size. // When drawing on a 1x backing store it'd draw m_bitmap_1x at its physical size, and it would have to scale down m_bitmap_2x to 0.5x its size. // But the system can't current scale down, and we want to draw the 2x bitmap at twice the size of the 1x bitmap in this particular application, // so make a 1x alias of the 2x bitmap to make LibGfx paint it without any scaling at paint time, mapping once pixel to one pixel. - m_bitmap_2x_as_1x = Gfx::Bitmap::create_wrapper(Gfx::BitmapFormat::BGRx8888, m_bitmap_2x->physical_size(), 1, m_bitmap_2x->pitch(), m_bitmap_2x->scanline(0)); + m_bitmap_2x_as_1x = Gfx::Bitmap::try_create_wrapper(Gfx::BitmapFormat::BGRx8888, m_bitmap_2x->physical_size(), 1, m_bitmap_2x->pitch(), m_bitmap_2x->scanline(0)); Gfx::Painter painter_1x(*m_bitmap_1x); draw(painter_1x); @@ -75,14 +75,14 @@ void Canvas::paint_event(GUI::PaintEvent& event) void Canvas::draw(Gfx::Painter& painter) { - auto active_window_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/window.png"); + auto active_window_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png"); Gfx::WindowTheme::current().paint_normal_frame(painter, Gfx::WindowTheme::WindowState::Active, { 4, 18, WIDTH - 8, HEIGHT - 29 }, "Well hello friends 🐞", *active_window_icon, palette(), { WIDTH - 20, 6, 16, 16 }, 0, false); painter.draw_rect({ 20, 34, WIDTH - 40, HEIGHT - 45 }, palette().color(Gfx::ColorRole::Selection), true); painter.draw_rect({ 24, 38, WIDTH - 48, HEIGHT - 53 }, palette().color(Gfx::ColorRole::Selection)); // buggie.png has an alpha channel. - auto buggie = Gfx::Bitmap::load_from_file("/res/graphics/buggie.png"); + auto buggie = Gfx::Bitmap::try_load_from_file("/res/graphics/buggie.png"); painter.blit({ 25, 39 }, *buggie, { 2, 30, 62, 20 }); painter.draw_scaled_bitmap({ 88, 39, 62 * 2, 20 * 2 }, *buggie, Gfx::IntRect { 2, 30, 62, 20 }); painter.draw_scaled_bitmap({ 202, 39, 80, 40 }, *buggie, Gfx::IntRect { 2, 30, 62, 20 }); @@ -92,7 +92,7 @@ void Canvas::draw(Gfx::Painter& painter) painter.blit({ 25, 101 }, *buggie, { 2, 30, 3 * buggie->width(), 20 }); // grid does not have an alpha channel. - auto grid = Gfx::Bitmap::load_from_file("/res/wallpapers/grid.png"); + auto grid = Gfx::Bitmap::try_load_from_file("/res/wallpapers/grid.png"); VERIFY(!grid->has_alpha_channel()); painter.fill_rect({ 25, 122, 62, 20 }, Color::Green); painter.blit({ 25, 122 }, *grid, { (grid->width() - 62) / 2, (grid->height() - 20) / 2 + 40, 62, 20 }, 0.9); diff --git a/Userland/Demos/Mandelbrot/Mandelbrot.cpp b/Userland/Demos/Mandelbrot/Mandelbrot.cpp index d481e827f2..a230f1b1b9 100644 --- a/Userland/Demos/Mandelbrot/Mandelbrot.cpp +++ b/Userland/Demos/Mandelbrot/Mandelbrot.cpp @@ -35,7 +35,7 @@ public: void resize(Gfx::IntSize const& size) { - m_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, size); + m_bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, size); correct_aspect(); calculate(); } @@ -264,7 +264,7 @@ int main(int argc, char** argv) auto menubar = GUI::Menubar::construct(); auto& file_menu = menubar->add_menu("&File"); - file_menu.add_action(GUI::Action::create("&Export...", { Mod_Ctrl | Mod_Shift, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png"), + file_menu.add_action(GUI::Action::create("&Export...", { Mod_Ctrl | Mod_Shift, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/save.png"), [&](GUI::Action&) { Optional<String> export_path = GUI::FilePicker::get_save_filepath(window, "untitled", "png"); if (!export_path.has_value()) diff --git a/Userland/Demos/Screensaver/Screensaver.cpp b/Userland/Demos/Screensaver/Screensaver.cpp index 71744c972e..1ee8e3e31f 100644 --- a/Userland/Demos/Screensaver/Screensaver.cpp +++ b/Userland/Demos/Screensaver/Screensaver.cpp @@ -35,7 +35,7 @@ private: Screensaver::Screensaver(int width, int height, int interval) { - m_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { width, height }); + m_bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, { width, height }); srand(time(nullptr)); stop_timer(); start_timer(interval); diff --git a/Userland/Demos/Starfield/Starfield.cpp b/Userland/Demos/Starfield/Starfield.cpp index 88e250e665..d71833610b 100644 --- a/Userland/Demos/Starfield/Starfield.cpp +++ b/Userland/Demos/Starfield/Starfield.cpp @@ -59,7 +59,7 @@ Starfield::Starfield(int interval) void Starfield::create_stars(int width, int height, int stars) { - m_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { width, height }); + m_bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, { width, height }); m_stars.grow_capacity(stars); for (int i = 0; i < stars; i++) { diff --git a/Userland/Demos/WidgetGallery/GalleryModels.h b/Userland/Demos/WidgetGallery/GalleryModels.h index f00992f07f..038a26b9cb 100644 --- a/Userland/Demos/WidgetGallery/GalleryModels.h +++ b/Userland/Demos/WidgetGallery/GalleryModels.h @@ -63,7 +63,7 @@ public: continue; Cursor cursor; cursor.path = move(path); - cursor.bitmap = Gfx::Bitmap::load_from_file(cursor.path); + cursor.bitmap = Gfx::Bitmap::try_load_from_file(cursor.path); auto filename_split = cursor.path.split('/'); cursor.name = filename_split[2]; m_cursors.append(move(cursor)); @@ -142,7 +142,7 @@ public: if (!path.contains("filetype-") && !path.contains("app-")) continue; IconSet icon_set; - icon_set.big_icon = Gfx::Bitmap::load_from_file(path); + icon_set.big_icon = Gfx::Bitmap::try_load_from_file(path); auto filename_split = path.split('/'); icon_set.name = filename_split[3]; m_icon_sets.append(move(icon_set)); @@ -157,7 +157,7 @@ public: if (!path.contains("filetype-") && !path.contains("app-")) continue; IconSet icon_set; - icon_set.little_icon = Gfx::Bitmap::load_from_file(path); + icon_set.little_icon = Gfx::Bitmap::try_load_from_file(path); auto filename_split = path.split('/'); icon_set.name = filename_split[3]; for (size_t i = 0; i < big_icons_found; i++) { diff --git a/Userland/Demos/WidgetGallery/GalleryWidget.cpp b/Userland/Demos/WidgetGallery/GalleryWidget.cpp index 7a2eb65cc8..f6d96a9400 100644 --- a/Userland/Demos/WidgetGallery/GalleryWidget.cpp +++ b/Userland/Demos/WidgetGallery/GalleryWidget.cpp @@ -71,9 +71,9 @@ GalleryWidget::GalleryWidget() m_label_frame->set_frame_thickness(value); }; - m_button_icons.append(Gfx::Bitmap::load_from_file("/res/icons/16x16/book-open.png")); - m_button_icons.append(Gfx::Bitmap::load_from_file("/res/icons/16x16/inspector-object.png")); - m_button_icons.append(Gfx::Bitmap::load_from_file("/res/icons/16x16/ladybug.png")); + m_button_icons.append(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book-open.png")); + m_button_icons.append(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png")); + m_button_icons.append(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/ladybug.png")); m_icon_button = basics_tab.find_descendant_of_type_named<GUI::Button>("icon_button"); m_icon_button->set_icon(*m_button_icons[2]); @@ -93,7 +93,7 @@ GalleryWidget::GalleryWidget() m_text_editor = basics_tab.find_descendant_of_type_named<GUI::TextEditor>("text_editor"); m_font_button = basics_tab.find_descendant_of_type_named<GUI::Button>("font_button"); - m_font_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-font-editor.png")); + m_font_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png")); m_font_button->on_click = [&](auto) { auto picker = GUI::FontPicker::construct(window(), &m_text_editor->font(), false); @@ -103,7 +103,7 @@ GalleryWidget::GalleryWidget() }; m_file_button = basics_tab.find_descendant_of_type_named<GUI::Button>("file_button"); - m_file_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png")); + m_file_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png")); m_file_button->on_click = [&](auto) { Optional<String> open_path = GUI::FilePicker::get_open_filepath(window()); @@ -113,7 +113,7 @@ GalleryWidget::GalleryWidget() }; m_input_button = basics_tab.find_descendant_of_type_named<GUI::Button>("input_button"); - m_input_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/properties.png")); + m_input_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/properties.png")); m_input_button->on_click = [&](auto) { String value; @@ -131,7 +131,7 @@ GalleryWidget::GalleryWidget() }; m_msgbox_button = basics_tab.find_descendant_of_type_named<GUI::Button>("msgbox_button"); - m_msgbox_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-irc-client.png")); + m_msgbox_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-irc-client.png")); m_msgbox_type = GUI::MessageBox::Type::None; m_msgbox_input_type = GUI::MessageBox::InputType::OK; diff --git a/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp b/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp index f1842d7894..46684dfc2c 100644 --- a/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp +++ b/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp @@ -25,19 +25,19 @@ namespace HackStudio { void DebugInfoWidget::init_toolbar() { - m_continue_action = GUI::Action::create("Continue", Gfx::Bitmap::load_from_file("/res/icons/16x16/debug-continue.png"), [](auto&) { + m_continue_action = GUI::Action::create("Continue", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-continue.png"), [](auto&) { Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::Continue); }); - m_singlestep_action = GUI::Action::create("Step Over", { Mod_None, Key_F10 }, Gfx::Bitmap::load_from_file("/res/icons/16x16/debug-step-over.png"), [](auto&) { + m_singlestep_action = GUI::Action::create("Step Over", { Mod_None, Key_F10 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-over.png"), [](auto&) { Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::SourceStepOver); }); - m_step_in_action = GUI::Action::create("Step In", { Mod_None, Key_F11 }, Gfx::Bitmap::load_from_file("/res/icons/16x16/debug-step-in.png"), [](auto&) { + m_step_in_action = GUI::Action::create("Step In", { Mod_None, Key_F11 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-in.png"), [](auto&) { Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::SourceSingleStep); }); - m_step_out_action = GUI::Action::create("Step Out", { Mod_Shift, Key_F11 }, Gfx::Bitmap::load_from_file("/res/icons/16x16/debug-step-out.png"), [](auto&) { + m_step_out_action = GUI::Action::create("Step Out", { Mod_Shift, Key_F11 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-out.png"), [](auto&) { Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::SourceStepOut); }); diff --git a/Userland/DevTools/HackStudio/Debugger/VariablesModel.h b/Userland/DevTools/HackStudio/Debugger/VariablesModel.h index d7de4dedf2..5b028f910b 100644 --- a/Userland/DevTools/HackStudio/Debugger/VariablesModel.h +++ b/Userland/DevTools/HackStudio/Debugger/VariablesModel.h @@ -32,7 +32,7 @@ private: : m_variables(move(variables)) , m_regs(regs) { - m_variable_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/inspector-object.png")); + m_variable_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png")); } NonnullOwnPtrVector<Debug::DebugInfo::VariableInfo> m_variables; PtraceRegisters m_regs; diff --git a/Userland/DevTools/HackStudio/Editor.cpp b/Userland/DevTools/HackStudio/Editor.cpp index 7be4263737..869f07066e 100644 --- a/Userland/DevTools/HackStudio/Editor.cpp +++ b/Userland/DevTools/HackStudio/Editor.cpp @@ -429,13 +429,13 @@ void Editor::clear_execution_position() const Gfx::Bitmap& Editor::breakpoint_icon_bitmap() { - static auto bitmap = Gfx::Bitmap::load_from_file("/res/icons/16x16/breakpoint.png"); + static auto bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/breakpoint.png"); return *bitmap; } const Gfx::Bitmap& Editor::current_position_icon_bitmap() { - static auto bitmap = Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"); + static auto bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"); return *bitmap; } diff --git a/Userland/DevTools/HackStudio/Git/GitWidget.cpp b/Userland/DevTools/HackStudio/Git/GitWidget.cpp index 39fb4a87f3..95d03c0c91 100644 --- a/Userland/DevTools/HackStudio/Git/GitWidget.cpp +++ b/Userland/DevTools/HackStudio/Git/GitWidget.cpp @@ -32,7 +32,7 @@ GitWidget::GitWidget(const LexicalPath& repo_root) unstaged_header.set_layout<GUI::HorizontalBoxLayout>(); auto& refresh_button = unstaged_header.add<GUI::Button>(); - refresh_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png")); + refresh_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png")); refresh_button.set_fixed_size(16, 16); refresh_button.set_tooltip("refresh"); refresh_button.on_click = [this](int) { refresh(); }; @@ -43,7 +43,7 @@ GitWidget::GitWidget(const LexicalPath& repo_root) unstaged_header.set_fixed_height(20); m_unstaged_files = unstaged.add<GitFilesView>( [this](const auto& file) { stage_file(file); }, - Gfx::Bitmap::load_from_file("/res/icons/16x16/plus.png").release_nonnull()); + Gfx::Bitmap::try_load_from_file("/res/icons/16x16/plus.png").release_nonnull()); m_unstaged_files->on_selection_change = [this] { const auto& index = m_unstaged_files->selection().first(); const auto& selected = index.data().as_string(); @@ -57,7 +57,7 @@ GitWidget::GitWidget(const LexicalPath& repo_root) staged_header.set_layout<GUI::HorizontalBoxLayout>(); auto& commit_button = staged_header.add<GUI::Button>(); - commit_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/commit.png")); + commit_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/commit.png")); commit_button.set_fixed_size(16, 16); commit_button.set_tooltip("commit"); commit_button.on_click = [this](int) { commit(); }; @@ -68,7 +68,7 @@ GitWidget::GitWidget(const LexicalPath& repo_root) staged_header.set_fixed_height(20); m_staged_files = staged.add<GitFilesView>( [this](const auto& file) { unstage_file(file); }, - Gfx::Bitmap::load_from_file("/res/icons/16x16/minus.png").release_nonnull()); + Gfx::Bitmap::try_load_from_file("/res/icons/16x16/minus.png").release_nonnull()); } bool GitWidget::initialize() diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index 36413e3827..0563708625 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -331,7 +331,7 @@ NonnullRefPtr<GUI::Menu> HackStudioWidget::create_project_tree_view_context_menu NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_file_action() { - return GUI::Action::create("New &File...", { Mod_Ctrl, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"), [this](const GUI::Action&) { + return GUI::Action::create("New &File...", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"), [this](const GUI::Action&) { String filename; if (GUI::InputBox::show(window(), filename, "Enter name of new file:", "Add new file to project") != GUI::InputBox::ExecOK) return; @@ -368,7 +368,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_file_action() NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_directory_action() { - return GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"), [this](const GUI::Action&) { + return GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png"), [this](const GUI::Action&) { String directory_name; if (GUI::InputBox::show(window(), directory_name, "Enter name of new directory:", "Add new folder to project") != GUI::InputBox::ExecOK) return; @@ -478,7 +478,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_delete_action() NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_project_action() { - return GUI::Action::create("&New Project...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/hackstudio-project.png"), [this](const GUI::Action&) { + return GUI::Action::create("&New Project...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/hackstudio-project.png"), [this](const GUI::Action&) { auto dialog = NewProjectDialog::construct(window()); dialog->set_icon(window()->icon()); auto result = dialog->exec(); @@ -560,7 +560,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_remove_current_editor_action NonnullRefPtr<GUI::Action> HackStudioWidget::create_open_action() { - return GUI::Action::create("&Open Project...", { Mod_Ctrl | Mod_Shift, Key_O }, Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"), [this](auto&) { + return GUI::Action::create("&Open Project...", { Mod_Ctrl | Mod_Shift, Key_O }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png"), [this](auto&) { auto open_path = GUI::FilePicker::get_open_filepath(window(), "Open project", Core::StandardPaths::home_directory(), true); if (!open_path.has_value()) return; @@ -601,7 +601,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_remove_current_terminal_acti NonnullRefPtr<GUI::Action> HackStudioWidget::create_add_editor_action() { return GUI::Action::create("Add New &Editor", { Mod_Ctrl | Mod_Alt, Key_E }, - Gfx::Bitmap::load_from_file("/res/icons/16x16/app-text-editor.png"), + Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-text-editor.png"), [this](auto&) { add_new_editor(*m_editors_splitter); update_actions(); @@ -611,7 +611,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_add_editor_action() NonnullRefPtr<GUI::Action> HackStudioWidget::create_add_terminal_action() { return GUI::Action::create("Add New &Terminal", { Mod_Ctrl | Mod_Alt, Key_T }, - Gfx::Bitmap::load_from_file("/res/icons/16x16/app-terminal.png"), + Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png"), [this](auto&) { auto& terminal_wrapper = m_action_tab_widget->add_tab<TerminalWrapper>("Terminal"); reveal_action_tab(terminal_wrapper); @@ -629,7 +629,7 @@ void HackStudioWidget::reveal_action_tab(GUI::Widget& widget) NonnullRefPtr<GUI::Action> HackStudioWidget::create_debug_action() { - return GUI::Action::create("&Debug", Gfx::Bitmap::load_from_file("/res/icons/16x16/debug-run.png"), [this](auto&) { + return GUI::Action::create("&Debug", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-run.png"), [this](auto&) { if (!Core::File::exists(get_project_executable_path())) { GUI::MessageBox::show(window(), String::formatted("Could not find file: {}. (did you build the project?)", get_project_executable_path()), "Error", GUI::MessageBox::Type::Error); return; @@ -850,7 +850,7 @@ void HackStudioWidget::create_toolbar(GUI::Widget& parent) NonnullRefPtr<GUI::Action> HackStudioWidget::create_build_action() { - return GUI::Action::create("&Build", { Mod_Ctrl, Key_B }, Gfx::Bitmap::load_from_file("/res/icons/16x16/build.png"), [this](auto&) { + return GUI::Action::create("&Build", { Mod_Ctrl, Key_B }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/build.png"), [this](auto&) { if (warn_unsaved_changes("There are unsaved changes, do you want to save before building?") == ContinueDecision::No) return; @@ -862,7 +862,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_build_action() NonnullRefPtr<GUI::Action> HackStudioWidget::create_run_action() { - return GUI::Action::create("&Run", { Mod_Ctrl, Key_R }, Gfx::Bitmap::load_from_file("/res/icons/16x16/program-run.png"), [this](auto&) { + return GUI::Action::create("&Run", { Mod_Ctrl, Key_R }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/program-run.png"), [this](auto&) { reveal_action_tab(*m_terminal_wrapper); run(*m_terminal_wrapper); m_stop_action->set_enabled(true); @@ -944,7 +944,7 @@ void HackStudioWidget::create_project_menubar(GUI::Menubar& menubar) void HackStudioWidget::create_edit_menubar(GUI::Menubar& menubar) { auto& edit_menu = menubar.add_menu("&Edit"); - edit_menu.add_action(GUI::Action::create("&Find in Files...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::load_from_file("/res/icons/16x16/find.png"), [this](auto&) { + edit_menu.add_action(GUI::Action::create("&Find in Files...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"), [this](auto&) { reveal_action_tab(*m_find_in_files_widget); m_find_in_files_widget->focus_textbox_and_select_all(); })); @@ -1026,7 +1026,7 @@ void HackStudioWidget::create_help_menubar(GUI::Menubar& menubar) NonnullRefPtr<GUI::Action> HackStudioWidget::create_stop_action() { - auto action = GUI::Action::create("&Stop", Gfx::Bitmap::load_from_file("/res/icons/16x16/program-stop.png"), [this](auto&) { + auto action = GUI::Action::create("&Stop", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/program-stop.png"), [this](auto&) { if (!Debugger::the().session()) { m_terminal_wrapper->kill_running_command(); return; diff --git a/Userland/DevTools/HackStudio/LanguageClient.cpp b/Userland/DevTools/HackStudio/LanguageClient.cpp index 745950170a..69c104b951 100644 --- a/Userland/DevTools/HackStudio/LanguageClient.cpp +++ b/Userland/DevTools/HackStudio/LanguageClient.cpp @@ -186,7 +186,7 @@ void ServerConnectionWrapper::on_crash() void ServerConnectionWrapper::show_frequenct_crashes_notification() const { auto notification = GUI::Notification::construct(); - notification->set_icon(Gfx::Bitmap::load_from_file("/res/icons/32x32/app-hack-studio.png")); + notification->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-hack-studio.png")); notification->set_title("LanguageServer Crashes too much!"); notification->set_text("LanguageServer aided features will not be available in this session"); notification->show(); @@ -194,7 +194,7 @@ void ServerConnectionWrapper::show_frequenct_crashes_notification() const void ServerConnectionWrapper::show_crash_notification() const { auto notification = GUI::Notification::construct(); - notification->set_icon(Gfx::Bitmap::load_from_file("/res/icons/32x32/app-hack-studio.png")); + notification->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-hack-studio.png")); notification->set_title("Oops!"); notification->set_text(String::formatted("LanguageServer has crashed")); notification->show(); diff --git a/Userland/DevTools/HackStudio/ProjectDeclarations.cpp b/Userland/DevTools/HackStudio/ProjectDeclarations.cpp index a70fa40647..76091d44ae 100644 --- a/Userland/DevTools/HackStudio/ProjectDeclarations.cpp +++ b/Userland/DevTools/HackStudio/ProjectDeclarations.cpp @@ -20,13 +20,13 @@ void HackStudio::ProjectDeclarations::set_declared_symbols(const String& filenam Optional<GUI::Icon> HackStudio::ProjectDeclarations::get_icon_for(GUI::AutocompleteProvider::DeclarationType type) { - static GUI::Icon struct_icon(Gfx::Bitmap::load_from_file("/res/icons/hackstudio/Struct.png")); - static GUI::Icon class_icon(Gfx::Bitmap::load_from_file("/res/icons/hackstudio/Class.png")); - static GUI::Icon function_icon(Gfx::Bitmap::load_from_file("/res/icons/hackstudio/Function.png")); - static GUI::Icon variable_icon(Gfx::Bitmap::load_from_file("/res/icons/hackstudio/Variable.png")); - static GUI::Icon preprocessor_icon(Gfx::Bitmap::load_from_file("/res/icons/hackstudio/Preprocessor.png")); - static GUI::Icon member_icon(Gfx::Bitmap::load_from_file("/res/icons/hackstudio/Member.png")); - static GUI::Icon namespace_icon(Gfx::Bitmap::load_from_file("/res/icons/hackstudio/Namespace.png")); + static GUI::Icon struct_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Struct.png")); + static GUI::Icon class_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Class.png")); + static GUI::Icon function_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Function.png")); + static GUI::Icon variable_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Variable.png")); + static GUI::Icon preprocessor_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Preprocessor.png")); + static GUI::Icon member_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Member.png")); + static GUI::Icon namespace_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Namespace.png")); switch (type) { case GUI::AutocompleteProvider::DeclarationType::Struct: return struct_icon; diff --git a/Userland/DevTools/HackStudio/ProjectTemplate.cpp b/Userland/DevTools/HackStudio/ProjectTemplate.cpp index 12ca28d24f..9cb202087e 100644 --- a/Userland/DevTools/HackStudio/ProjectTemplate.cpp +++ b/Userland/DevTools/HackStudio/ProjectTemplate.cpp @@ -50,7 +50,7 @@ RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(const String& manife auto bitmap_path_32 = String::formatted("/res/icons/hackstudio/templates-32x32/{}.png", config->read_entry("HackStudioTemplate", "IconName32x")); if (Core::File::exists(bitmap_path_32)) { - auto bitmap32 = Gfx::Bitmap::load_from_file(bitmap_path_32); + auto bitmap32 = Gfx::Bitmap::try_load_from_file(bitmap_path_32); icon = GUI::Icon(move(bitmap32)); } diff --git a/Userland/DevTools/HackStudio/main.cpp b/Userland/DevTools/HackStudio/main.cpp index 7b5b41cb62..e851d00cb5 100644 --- a/Userland/DevTools/HackStudio/main.cpp +++ b/Userland/DevTools/HackStudio/main.cpp @@ -43,7 +43,7 @@ int main(int argc, char** argv) s_window = GUI::Window::construct(); s_window->resize(840, 600); - s_window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-hack-studio.png")); + s_window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-hack-studio.png")); update_path_environment_variable(); @@ -105,7 +105,7 @@ static bool make_is_available() static void notify_make_not_available() { auto notification = GUI::Notification::construct(); - notification->set_icon(Gfx::Bitmap::load_from_file("/res/icons/32x32/app-hack-studio.png")); + notification->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-hack-studio.png")); notification->set_title("'make' Not Available"); notification->set_text("You probably want to install the binutils, gcc, and make ports from the root of the Serenity repository"); notification->show(); diff --git a/Userland/DevTools/Inspector/RemoteObjectGraphModel.cpp b/Userland/DevTools/Inspector/RemoteObjectGraphModel.cpp index 35c8136d3c..e9d8cb238d 100644 --- a/Userland/DevTools/Inspector/RemoteObjectGraphModel.cpp +++ b/Userland/DevTools/Inspector/RemoteObjectGraphModel.cpp @@ -17,10 +17,10 @@ namespace Inspector { RemoteObjectGraphModel::RemoteObjectGraphModel(RemoteProcess& process) : m_process(process) { - m_object_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/inspector-object.png")); - m_window_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/window.png")); - m_layout_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/layout.png")); - m_timer_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/timer.png")); + m_object_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png")); + m_window_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png")); + m_layout_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/layout.png")); + m_timer_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/timer.png")); } RemoteObjectGraphModel::~RemoteObjectGraphModel() diff --git a/Userland/DevTools/Inspector/main.cpp b/Userland/DevTools/Inspector/main.cpp index 5da17cec5e..496b14f10f 100644 --- a/Userland/DevTools/Inspector/main.cpp +++ b/Userland/DevTools/Inspector/main.cpp @@ -155,7 +155,7 @@ int main(int argc, char** argv) auto properties_tree_view_context_menu = GUI::Menu::construct("Properties Tree View"); - auto copy_bitmap = Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-copy.png"); + auto copy_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png"); auto copy_property_name_action = GUI::Action::create("Copy Property Name", copy_bitmap, [&](auto&) { GUI::Clipboard::the().set_plain_text(properties_tree_view.selection().first().data().to_string()); }); diff --git a/Userland/DevTools/Profiler/DisassemblyModel.cpp b/Userland/DevTools/Profiler/DisassemblyModel.cpp index 20dc66237e..fdbdf1656a 100644 --- a/Userland/DevTools/Profiler/DisassemblyModel.cpp +++ b/Userland/DevTools/Profiler/DisassemblyModel.cpp @@ -20,7 +20,7 @@ static const Gfx::Bitmap& heat_gradient() { static RefPtr<Gfx::Bitmap> bitmap; if (!bitmap) { - bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { 101, 1 }); + bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, { 101, 1 }); GUI::Painter painter(*bitmap); painter.fill_rect_with_gradient(Orientation::Horizontal, bitmap->rect(), Color::from_rgb(0xffc080), Color::from_rgb(0xff3000)); } diff --git a/Userland/DevTools/Profiler/ProfileModel.cpp b/Userland/DevTools/Profiler/ProfileModel.cpp index abd791f4a9..eb0d311d75 100644 --- a/Userland/DevTools/Profiler/ProfileModel.cpp +++ b/Userland/DevTools/Profiler/ProfileModel.cpp @@ -16,8 +16,8 @@ namespace Profiler { ProfileModel::ProfileModel(Profile& profile) : m_profile(profile) { - m_user_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/inspector-object.png")); - m_kernel_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/inspector-object-red.png")); + m_user_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png")); + m_kernel_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object-red.png")); } ProfileModel::~ProfileModel() diff --git a/Userland/DevTools/Profiler/SamplesModel.cpp b/Userland/DevTools/Profiler/SamplesModel.cpp index dddb54b22c..57e0410667 100644 --- a/Userland/DevTools/Profiler/SamplesModel.cpp +++ b/Userland/DevTools/Profiler/SamplesModel.cpp @@ -14,8 +14,8 @@ namespace Profiler { SamplesModel::SamplesModel(Profile& profile) : m_profile(profile) { - m_user_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/inspector-object.png")); - m_kernel_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/inspector-object-red.png")); + m_user_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png")); + m_kernel_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object-red.png")); } SamplesModel::~SamplesModel() diff --git a/Userland/DevTools/Profiler/main.cpp b/Userland/DevTools/Profiler/main.cpp index 65e1cf877b..219e2532d8 100644 --- a/Userland/DevTools/Profiler/main.cpp +++ b/Userland/DevTools/Profiler/main.cpp @@ -149,7 +149,7 @@ int main(int argc, char** argv) disassembly_view.set_model(profile->disassembly_model()); }; - auto disassembly_action = GUI::Action::create_checkable("Show &Disassembly", { Mod_Ctrl, Key_D }, Gfx::Bitmap::load_from_file("/res/icons/16x16/x86.png"), [&](auto& action) { + auto disassembly_action = GUI::Action::create_checkable("Show &Disassembly", { Mod_Ctrl, Key_D }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/x86.png"), [&](auto& action) { disassembly_view.set_visible(action.is_checked()); }); @@ -235,7 +235,7 @@ static bool prompt_to_stop_profiling(pid_t pid, const String& process_name) auto window = GUI::Window::construct(); window->set_title(String::formatted("Profiling {}({})", process_name, pid)); window->resize(240, 100); - window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-profiler.png")); + window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-profiler.png")); window->center_on_screen(); auto& widget = window->set_main_widget<GUI::Widget>(); @@ -263,7 +263,7 @@ static bool prompt_to_stop_profiling(pid_t pid, const String& process_name) bool generate_profile(pid_t& pid) { if (!pid) { - auto process_chooser = GUI::ProcessChooser::construct("Profiler", "Profile", Gfx::Bitmap::load_from_file("/res/icons/16x16/app-profiler.png")); + auto process_chooser = GUI::ProcessChooser::construct("Profiler", "Profile", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-profiler.png")); if (process_chooser->exec() == GUI::Dialog::ExecCancel) return false; pid = process_chooser->pid(); diff --git a/Userland/Games/Chess/ChessWidget.cpp b/Userland/Games/Chess/ChessWidget.cpp index 6bb132e0ab..34c13b56b8 100644 --- a/Userland/Games/Chess/ChessWidget.cpp +++ b/Userland/Games/Chess/ChessWidget.cpp @@ -373,7 +373,7 @@ static RefPtr<Gfx::Bitmap> get_piece(const StringView& set, const StringView& im builder.append(set); builder.append('/'); builder.append(image); - return Gfx::Bitmap::load_from_file(builder.build()); + return Gfx::Bitmap::try_load_from_file(builder.build()); } void ChessWidget::set_piece_set(const StringView& set) diff --git a/Userland/Games/Chess/main.cpp b/Userland/Games/Chess/main.cpp index 301c9308d4..c72ca51a03 100644 --- a/Userland/Games/Chess/main.cpp +++ b/Userland/Games/Chess/main.cpp @@ -156,7 +156,7 @@ int main(int argc, char** argv) GUI::ActionGroup board_theme_action_group; board_theme_action_group.set_exclusive(true); auto& board_theme_menu = style_menu.add_submenu("Board Theme"); - board_theme_menu.set_icon(Gfx::Bitmap::load_from_file("/res/icons/chess/mini-board.png")); + board_theme_menu.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/chess/mini-board.png")); for (auto& theme : Vector({ "Beige", "Green", "Blue" })) { auto action = GUI::Action::create_checkable(theme, [&](auto& action) { diff --git a/Userland/Games/FlappyBug/Game.h b/Userland/Games/FlappyBug/Game.h index 0b285462f1..0bffc2d18e 100644 --- a/Userland/Games/FlappyBug/Game.h +++ b/Userland/Games/FlappyBug/Game.h @@ -43,8 +43,8 @@ private: const float x { 50 }; const float radius { 16 }; const float starting_y { 200 }; - const RefPtr<Gfx::Bitmap> falling_bitmap { Gfx::Bitmap::load_from_file("/res/icons/flappybug/falling.png") }; - const RefPtr<Gfx::Bitmap> flapping_bitmap { Gfx::Bitmap::load_from_file("/res/icons/flappybug/flapping.png") }; + const RefPtr<Gfx::Bitmap> falling_bitmap { Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/falling.png") }; + const RefPtr<Gfx::Bitmap> flapping_bitmap { Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/flapping.png") }; float y {}; float velocity {}; @@ -107,9 +107,9 @@ private: struct Cloud { const Vector<RefPtr<Gfx::Bitmap>> cloud_bitmaps { - Gfx::Bitmap::load_from_file("/res/icons/flappybug/cloud_0.png"), - Gfx::Bitmap::load_from_file("/res/icons/flappybug/cloud_1.png"), - Gfx::Bitmap::load_from_file("/res/icons/flappybug/cloud_2.png"), + Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/cloud_0.png"), + Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/cloud_1.png"), + Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/cloud_2.png"), }; float x {}; float y {}; @@ -147,7 +147,7 @@ private: float m_last_score {}; float m_difficulty {}; float m_restart_cooldown {}; - const RefPtr<Gfx::Bitmap> m_background_bitmap { Gfx::Bitmap::load_from_file("/res/icons/flappybug/background.png") }; + const RefPtr<Gfx::Bitmap> m_background_bitmap { Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/background.png") }; const Gfx::IntRect m_score_rect { 10, 10, 20, 20 }; const Gfx::IntRect m_text_rect { game_width / 2 - 80, game_height / 2 - 40, 160, 80 }; }; diff --git a/Userland/Games/GameOfLife/main.cpp b/Userland/Games/GameOfLife/main.cpp index 538b2c67f4..4041ab1967 100644 --- a/Userland/Games/GameOfLife/main.cpp +++ b/Userland/Games/GameOfLife/main.cpp @@ -74,8 +74,8 @@ int main(int argc, char** argv) interval_spinbox.set_value(150); - auto paused_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/pause.png"); - auto play_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/play.png"); + auto paused_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/pause.png"); + auto play_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/play.png"); auto toggle_running_action = GUI::Action::create("&Toggle Running", { Mod_None, Key_Return }, *play_icon, [&](GUI::Action&) { board_widget.set_running(!board_widget.is_running()); @@ -84,27 +84,27 @@ int main(int argc, char** argv) toggle_running_action->set_checkable(true); auto& toggle_running_toolbar_button = main_toolbar.add_action(toggle_running_action); - auto run_one_generation_action = GUI::Action::create("Run &Next Generation", { Mod_Ctrl, Key_Equal }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"), [&](const GUI::Action&) { + auto run_one_generation_action = GUI::Action::create("Run &Next Generation", { Mod_Ctrl, Key_Equal }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"), [&](const GUI::Action&) { statusbar.set_text(click_tip); board_widget.run_generation(); }); main_toolbar.add_action(run_one_generation_action); - auto clear_board_action = GUI::Action::create("&Clear board", { Mod_Ctrl, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/delete.png"), [&](auto&) { + auto clear_board_action = GUI::Action::create("&Clear board", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png"), [&](auto&) { statusbar.set_text(click_tip); board_widget.clear_cells(); board_widget.update(); }); main_toolbar.add_action(clear_board_action); - auto randomize_cells_action = GUI::Action::create("&Randomize board", { Mod_Ctrl, Key_R }, Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"), [&](auto&) { + auto randomize_cells_action = GUI::Action::create("&Randomize board", { Mod_Ctrl, Key_R }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png"), [&](auto&) { statusbar.set_text(click_tip); board_widget.randomize_cells(); board_widget.update(); }); main_toolbar.add_action(randomize_cells_action); - auto rotate_pattern_action = GUI::Action::create("&Rotate pattern", { 0, Key_R }, Gfx::Bitmap::load_from_file("/res/icons/16x16/redo.png"), [&](auto&) { + auto rotate_pattern_action = GUI::Action::create("&Rotate pattern", { 0, Key_R }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/redo.png"), [&](auto&) { if (board_widget.selected_pattern() != nullptr) board_widget.selected_pattern()->rotate_clockwise(); }); diff --git a/Userland/Games/Minesweeper/Field.cpp b/Userland/Games/Minesweeper/Field.cpp index 10daf91006..26c563745d 100644 --- a/Userland/Games/Minesweeper/Field.cpp +++ b/Userland/Games/Minesweeper/Field.cpp @@ -118,15 +118,15 @@ Field::Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_b m_time_label.set_text(String::formatted("{}.{}", m_time_elapsed / 10, m_time_elapsed % 10)); }; m_timer->set_interval(100); - m_mine_bitmap = Gfx::Bitmap::load_from_file("/res/icons/minesweeper/mine.png"); - m_flag_bitmap = Gfx::Bitmap::load_from_file("/res/icons/minesweeper/flag.png"); - m_badflag_bitmap = Gfx::Bitmap::load_from_file("/res/icons/minesweeper/badflag.png"); - m_consider_bitmap = Gfx::Bitmap::load_from_file("/res/icons/minesweeper/consider.png"); - m_default_face_bitmap = Gfx::Bitmap::load_from_file("/res/icons/minesweeper/face-default.png"); - m_good_face_bitmap = Gfx::Bitmap::load_from_file("/res/icons/minesweeper/face-good.png"); - m_bad_face_bitmap = Gfx::Bitmap::load_from_file("/res/icons/minesweeper/face-bad.png"); + m_mine_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/mine.png"); + m_flag_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/flag.png"); + m_badflag_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/badflag.png"); + m_consider_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/consider.png"); + m_default_face_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/face-default.png"); + m_good_face_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/face-good.png"); + m_bad_face_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/face-bad.png"); for (int i = 0; i < 8; ++i) - m_number_bitmap[i] = Gfx::Bitmap::load_from_file(String::formatted("/res/icons/minesweeper/{}.png", i + 1)); + m_number_bitmap[i] = Gfx::Bitmap::try_load_from_file(String::formatted("/res/icons/minesweeper/{}.png", i + 1)); // Square with mine will be filled with background color later, i.e. red m_mine_palette.set_color(Gfx::ColorRole::Base, Color::from_rgb(0xff4040)); diff --git a/Userland/Games/Minesweeper/main.cpp b/Userland/Games/Minesweeper/main.cpp index dafe9f8323..9a4a70c4e2 100644 --- a/Userland/Games/Minesweeper/main.cpp +++ b/Userland/Games/Minesweeper/main.cpp @@ -72,7 +72,7 @@ int main(int argc, char** argv) container.layout()->add_spacer(); auto& flag_image = container.add<GUI::Label>(); - flag_image.set_icon(Gfx::Bitmap::load_from_file("/res/icons/minesweeper/flag.png")); + flag_image.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/flag.png")); flag_image.set_fixed_width(16); auto& flag_label = container.add<GUI::Label>(); @@ -90,7 +90,7 @@ int main(int argc, char** argv) auto& time_image = container.add<GUI::Label>(); time_image.set_fixed_width(16); - time_image.set_icon(Gfx::Bitmap::load_from_file("/res/icons/minesweeper/timer.png")); + time_image.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/timer.png")); auto& time_label = container.add<GUI::Label>(); time_label.set_autosize(true); diff --git a/Userland/Games/Snake/SnakeGame.cpp b/Userland/Games/Snake/SnakeGame.cpp index 5a63aa5e37..328a0ae255 100644 --- a/Userland/Games/Snake/SnakeGame.cpp +++ b/Userland/Games/Snake/SnakeGame.cpp @@ -16,10 +16,10 @@ SnakeGame::SnakeGame() { set_font(Gfx::FontDatabase::default_fixed_width_font().bold_variant()); - m_fruit_bitmaps.append(*Gfx::Bitmap::load_from_file("/res/icons/snake/paprika.png")); - m_fruit_bitmaps.append(*Gfx::Bitmap::load_from_file("/res/icons/snake/eggplant.png")); - m_fruit_bitmaps.append(*Gfx::Bitmap::load_from_file("/res/icons/snake/cauliflower.png")); - m_fruit_bitmaps.append(*Gfx::Bitmap::load_from_file("/res/icons/snake/tomato.png")); + m_fruit_bitmaps.append(*Gfx::Bitmap::try_load_from_file("/res/icons/snake/paprika.png")); + m_fruit_bitmaps.append(*Gfx::Bitmap::try_load_from_file("/res/icons/snake/eggplant.png")); + m_fruit_bitmaps.append(*Gfx::Bitmap::try_load_from_file("/res/icons/snake/cauliflower.png")); + m_fruit_bitmaps.append(*Gfx::Bitmap::try_load_from_file("/res/icons/snake/tomato.png")); srand(time(nullptr)); reset(); diff --git a/Userland/Libraries/LibCards/Card.cpp b/Userland/Libraries/LibCards/Card.cpp index 2a88e45e82..2c27912d86 100644 --- a/Userland/Libraries/LibCards/Card.cpp +++ b/Userland/Libraries/LibCards/Card.cpp @@ -64,7 +64,7 @@ static RefPtr<Gfx::Bitmap> s_background_inverted; Card::Card(Type type, uint8_t value) : m_rect(Gfx::IntRect({}, { width, height })) - , m_front(*Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, { width, height })) + , m_front(*Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, { width, height })) , m_type(type) , m_value(value) { @@ -72,10 +72,10 @@ Card::Card(Type type, uint8_t value) Gfx::IntRect paint_rect({ 0, 0 }, { width, height }); if (s_background.is_null()) { - s_background = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, { width, height }); + s_background = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, { width, height }); Gfx::Painter bg_painter(*s_background); - auto image = Gfx::Bitmap::load_from_file("/res/icons/cards/buggie-deck.png"); + auto image = Gfx::Bitmap::try_load_from_file("/res/icons/cards/buggie-deck.png"); VERIFY(!image.is_null()); float aspect_ratio = image->width() / static_cast<float>(image->height()); diff --git a/Userland/Libraries/LibGL/SoftwareRasterizer.cpp b/Userland/Libraries/LibGL/SoftwareRasterizer.cpp index 41f4a48b1b..8ef38b1a24 100644 --- a/Userland/Libraries/LibGL/SoftwareRasterizer.cpp +++ b/Userland/Libraries/LibGL/SoftwareRasterizer.cpp @@ -409,7 +409,7 @@ static Gfx::IntSize closest_multiple(const Gfx::IntSize& min_size, size_t step) } SoftwareRasterizer::SoftwareRasterizer(const Gfx::IntSize& min_size) - : m_render_target { Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, closest_multiple(min_size, RASTERIZER_BLOCK_SIZE)) } + : m_render_target { Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, closest_multiple(min_size, RASTERIZER_BLOCK_SIZE)) } , m_depth_buffer { adopt_own(*new DepthBuffer(closest_multiple(min_size, RASTERIZER_BLOCK_SIZE))) } { } @@ -446,7 +446,7 @@ void SoftwareRasterizer::resize(const Gfx::IntSize& min_size) { wait_for_all_threads(); - m_render_target = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, closest_multiple(min_size, RASTERIZER_BLOCK_SIZE)); + m_render_target = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, closest_multiple(min_size, RASTERIZER_BLOCK_SIZE)); m_depth_buffer = adopt_own(*new DepthBuffer(m_render_target->size())); } diff --git a/Userland/Libraries/LibGUI/Action.cpp b/Userland/Libraries/LibGUI/Action.cpp index 98abcaa415..53da395f4d 100644 --- a/Userland/Libraries/LibGUI/Action.cpp +++ b/Userland/Libraries/LibGUI/Action.cpp @@ -30,71 +30,71 @@ NonnullRefPtr<Action> make_about_action(const String& app_name, const Icon& app_ NonnullRefPtr<Action> make_open_action(Function<void(Action&)> callback, Core::Object* parent) { - auto action = Action::create("&Open...", { Mod_Ctrl, Key_O }, Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"), move(callback), parent); + auto action = Action::create("&Open...", { Mod_Ctrl, Key_O }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png"), move(callback), parent); action->set_status_tip("Open an existing file"); return action; } NonnullRefPtr<Action> make_save_action(Function<void(Action&)> callback, Core::Object* parent) { - auto action = Action::create("&Save", { Mod_Ctrl, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png"), move(callback), parent); + auto action = Action::create("&Save", { Mod_Ctrl, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/save.png"), move(callback), parent); action->set_status_tip("Save the current file"); return action; } NonnullRefPtr<Action> make_save_as_action(Function<void(Action&)> callback, Core::Object* parent) { - auto action = Action::create("Save &As...", { Mod_Ctrl | Mod_Shift, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png"), move(callback), parent); + auto action = Action::create("Save &As...", { Mod_Ctrl | Mod_Shift, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/save.png"), move(callback), parent); action->set_status_tip("Save the current file with a new name"); return action; } NonnullRefPtr<Action> make_move_to_front_action(Function<void(Action&)> callback, Core::Object* parent) { - auto action = Action::create("Move to &Front", { Mod_Ctrl | Mod_Shift, Key_Up }, Gfx::Bitmap::load_from_file("/res/icons/16x16/move-to-front.png"), move(callback), parent); + auto action = Action::create("Move to &Front", { Mod_Ctrl | Mod_Shift, Key_Up }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/move-to-front.png"), move(callback), parent); action->set_status_tip("Move to the top of the stack"); return action; } NonnullRefPtr<Action> make_move_to_back_action(Function<void(Action&)> callback, Core::Object* parent) { - auto action = Action::create("Move to &Back", { Mod_Ctrl | Mod_Shift, Key_Down }, Gfx::Bitmap::load_from_file("/res/icons/16x16/move-to-back.png"), move(callback), parent); + auto action = Action::create("Move to &Back", { Mod_Ctrl | Mod_Shift, Key_Down }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/move-to-back.png"), move(callback), parent); action->set_status_tip("Move to the bottom of the stack"); return action; } NonnullRefPtr<Action> make_undo_action(Function<void(Action&)> callback, Core::Object* parent) { - return Action::create("&Undo", { Mod_Ctrl, Key_Z }, Gfx::Bitmap::load_from_file("/res/icons/16x16/undo.png"), move(callback), parent); + return Action::create("&Undo", { Mod_Ctrl, Key_Z }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/undo.png"), move(callback), parent); } NonnullRefPtr<Action> make_redo_action(Function<void(Action&)> callback, Core::Object* parent) { - return Action::create("&Redo", { Mod_Ctrl, Key_Y }, Gfx::Bitmap::load_from_file("/res/icons/16x16/redo.png"), move(callback), parent); + return Action::create("&Redo", { Mod_Ctrl, Key_Y }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/redo.png"), move(callback), parent); } NonnullRefPtr<Action> make_delete_action(Function<void(Action&)> callback, Core::Object* parent) { - return Action::create("&Delete", { Mod_None, Key_Delete }, Gfx::Bitmap::load_from_file("/res/icons/16x16/delete.png"), move(callback), parent); + return Action::create("&Delete", { Mod_None, Key_Delete }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png"), move(callback), parent); } NonnullRefPtr<Action> make_cut_action(Function<void(Action&)> callback, Core::Object* parent) { - auto action = Action::create("Cu&t", { Mod_Ctrl, Key_X }, Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-cut.png"), move(callback), parent); + auto action = Action::create("Cu&t", { Mod_Ctrl, Key_X }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-cut.png"), move(callback), parent); action->set_status_tip("Cut to clipboard"); return action; } NonnullRefPtr<Action> make_copy_action(Function<void(Action&)> callback, Core::Object* parent) { - auto action = Action::create("&Copy", { Mod_Ctrl, Key_C }, Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-copy.png"), move(callback), parent); + auto action = Action::create("&Copy", { Mod_Ctrl, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png"), move(callback), parent); action->set_status_tip("Copy to clipboard"); return action; } NonnullRefPtr<Action> make_paste_action(Function<void(Action&)> callback, Core::Object* parent) { - auto action = Action::create("&Paste", { Mod_Ctrl, Key_V }, Gfx::Bitmap::load_from_file("/res/icons/16x16/paste.png"), move(callback), parent); + auto action = Action::create("&Paste", { Mod_Ctrl, Key_V }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/paste.png"), move(callback), parent); action->set_status_tip("Paste from clipboard"); return action; } @@ -115,63 +115,63 @@ NonnullRefPtr<Action> make_quit_action(Function<void(Action&)> callback) NonnullRefPtr<Action> make_help_action(Function<void(Action&)> callback, Core::Object* parent) { - auto action = Action::create("&Contents", { Mod_None, Key_F1 }, Gfx::Bitmap::load_from_file("/res/icons/16x16/app-help.png"), move(callback), parent); + auto action = Action::create("&Contents", { Mod_None, Key_F1 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png"), move(callback), parent); action->set_status_tip("Show help contents"); return action; } NonnullRefPtr<Action> make_go_back_action(Function<void(Action&)> callback, Core::Object* parent) { - auto action = Action::create("Go &Back", { Mod_Alt, Key_Left }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-back.png"), move(callback), parent); + auto action = Action::create("Go &Back", { Mod_Alt, Key_Left }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"), move(callback), parent); action->set_status_tip("Move one step backward in history"); return action; } NonnullRefPtr<Action> make_go_forward_action(Function<void(Action&)> callback, Core::Object* parent) { - auto action = Action::create("Go &Forward", { Mod_Alt, Key_Right }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"), move(callback), parent); + auto action = Action::create("Go &Forward", { Mod_Alt, Key_Right }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"), move(callback), parent); action->set_status_tip("Move one step forward in history"); return action; } NonnullRefPtr<Action> make_go_home_action(Function<void(Action&)> callback, Core::Object* parent) { - return Action::create("Go &Home", { Mod_Alt, Key_Home }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-home.png"), move(callback), parent); + return Action::create("Go &Home", { Mod_Alt, Key_Home }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-home.png"), move(callback), parent); } NonnullRefPtr<Action> make_reload_action(Function<void(Action&)> callback, Core::Object* parent) { - return Action::create("&Reload", { Mod_Ctrl, Key_R }, Key_F5, Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"), move(callback), parent); + return Action::create("&Reload", { Mod_Ctrl, Key_R }, Key_F5, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png"), move(callback), parent); } NonnullRefPtr<Action> make_select_all_action(Function<void(Action&)> callback, Core::Object* parent) { - return Action::create("Select &All", { Mod_Ctrl, Key_A }, Gfx::Bitmap::load_from_file("/res/icons/16x16/select-all.png"), move(callback), parent); + return Action::create("Select &All", { Mod_Ctrl, Key_A }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/select-all.png"), move(callback), parent); } NonnullRefPtr<Action> make_rename_action(Function<void(Action&)> callback, Core::Object* parent) { - return Action::create("Re&name", Key_F2, Gfx::Bitmap::load_from_file("/res/icons/16x16/rename.png"), move(callback), parent); + return Action::create("Re&name", Key_F2, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/rename.png"), move(callback), parent); } NonnullRefPtr<Action> make_properties_action(Function<void(Action&)> callback, Core::Object* parent) { - return Action::create("P&roperties", { Mod_Alt, Key_Return }, Gfx::Bitmap::load_from_file("/res/icons/16x16/properties.png"), move(callback), parent); + return Action::create("P&roperties", { Mod_Alt, Key_Return }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/properties.png"), move(callback), parent); } NonnullRefPtr<Action> make_zoom_in_action(Function<void(Action&)> callback, Core::Object* parent) { - return GUI::Action::create("Zoom &In", { Mod_Ctrl, Key_Equal }, Gfx::Bitmap::load_from_file("/res/icons/16x16/zoom-in.png"), move(callback), parent); + return GUI::Action::create("Zoom &In", { Mod_Ctrl, Key_Equal }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/zoom-in.png"), move(callback), parent); } NonnullRefPtr<Action> make_reset_zoom_action(Function<void(Action&)> callback, Core::Object* parent) { - return GUI::Action::create("&Reset Zoom", { Mod_Ctrl, Key_0 }, Gfx::Bitmap::load_from_file("/res/icons/16x16/zoom-reset.png"), move(callback), parent); + return GUI::Action::create("&Reset Zoom", { Mod_Ctrl, Key_0 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/zoom-reset.png"), move(callback), parent); } NonnullRefPtr<Action> make_zoom_out_action(Function<void(Action&)> callback, Core::Object* parent) { - return GUI::Action::create("Zoom &Out", { Mod_Ctrl, Key_Minus }, Gfx::Bitmap::load_from_file("/res/icons/16x16/zoom-out.png"), move(callback), parent); + return GUI::Action::create("Zoom &Out", { Mod_Ctrl, Key_Minus }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/zoom-out.png"), move(callback), parent); } } diff --git a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp index c5c129d1a7..63e5ab18d7 100644 --- a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp +++ b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp @@ -47,13 +47,13 @@ public: if (index.column() == Column::Icon) { if (suggestion.language == GUI::AutocompleteProvider::Language::Cpp) { if (!s_cpp_identifier_icon) { - s_cpp_identifier_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/completion/cpp-identifier.png"); + s_cpp_identifier_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/completion/cpp-identifier.png"); } return *s_cpp_identifier_icon; } if (suggestion.language == GUI::AutocompleteProvider::Language::Unspecified) { if (!s_unspecified_identifier_icon) { - s_unspecified_identifier_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/completion/unspecified-identifier.png"); + s_unspecified_identifier_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/completion/unspecified-identifier.png"); } return *s_unspecified_identifier_icon; } diff --git a/Userland/Libraries/LibGUI/Clipboard.cpp b/Userland/Libraries/LibGUI/Clipboard.cpp index 2c7c557744..b41a435d98 100644 --- a/Userland/Libraries/LibGUI/Clipboard.cpp +++ b/Userland/Libraries/LibGUI/Clipboard.cpp @@ -113,8 +113,8 @@ RefPtr<Gfx::Bitmap> Clipboard::bitmap() const if (!format.has_value() || format.value() == 0) return nullptr; - auto clipping_bitmap = Gfx::Bitmap::create_wrapper((Gfx::BitmapFormat)format.value(), { (int)width.value(), (int)height.value() }, scale.value(), pitch.value(), clipping.data.data()); - auto bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, { (int)width.value(), (int)height.value() }, scale.value()); + auto clipping_bitmap = Gfx::Bitmap::try_create_wrapper((Gfx::BitmapFormat)format.value(), { (int)width.value(), (int)height.value() }, scale.value(), pitch.value(), clipping.data.data()); + auto bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, { (int)width.value(), (int)height.value() }, scale.value()); for (int y = 0; y < clipping_bitmap->physical_height(); ++y) { for (int x = 0; x < clipping_bitmap->physical_width(); ++x) { diff --git a/Userland/Libraries/LibGUI/ColorPicker.cpp b/Userland/Libraries/LibGUI/ColorPicker.cpp index 780cdff359..5eba8fdab9 100644 --- a/Userland/Libraries/LibGUI/ColorPicker.cpp +++ b/Userland/Libraries/LibGUI/ColorPicker.cpp @@ -129,7 +129,7 @@ ColorPicker::ColorPicker(Color color, Window* parent_window, String title) : Dialog(parent_window) , m_color(color) { - set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/color-chooser.png")); + set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/color-chooser.png")); set_title(title); set_resizable(false); resize(458, 326); @@ -459,7 +459,7 @@ ColorField::ColorField(Color color) void ColorField::create_color_bitmap() { - m_color_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { 256, 256 }); + m_color_bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, { 256, 256 }); auto painter = Gfx::Painter(*m_color_bitmap); Gfx::HSV hsv; @@ -585,7 +585,7 @@ void ColorField::resize_event(ResizeEvent&) ColorSlider::ColorSlider(double value) : m_value(value) { - m_color_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { 32, 360 }); + m_color_bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, { 32, 360 }); auto painter = Gfx::Painter(*m_color_bitmap); for (int h = 0; h < 360; h++) { diff --git a/Userland/Libraries/LibGUI/ComboBox.cpp b/Userland/Libraries/LibGUI/ComboBox.cpp index bb03e42acb..e759fab601 100644 --- a/Userland/Libraries/LibGUI/ComboBox.cpp +++ b/Userland/Libraries/LibGUI/ComboBox.cpp @@ -75,7 +75,7 @@ ComboBox::ComboBox() }; m_open_button = add<Button>(); - m_open_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/downward-triangle.png")); + m_open_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/downward-triangle.png")); m_open_button->set_focus_policy(GUI::FocusPolicy::NoFocus); m_open_button->on_click = [this](auto) { if (m_list_window->is_visible()) diff --git a/Userland/Libraries/LibGUI/DragOperation.cpp b/Userland/Libraries/LibGUI/DragOperation.cpp index d0aa5c76d6..62157f5b6c 100644 --- a/Userland/Libraries/LibGUI/DragOperation.cpp +++ b/Userland/Libraries/LibGUI/DragOperation.cpp @@ -33,7 +33,7 @@ DragOperation::Outcome DragOperation::exec() Gfx::ShareableBitmap drag_bitmap; if (m_mime_data->has_format("image/x-raw-bitmap")) { auto data = m_mime_data->data("image/x-raw-bitmap"); - auto bitmap = Gfx::Bitmap::create_from_serialized_byte_buffer(move(data)); + auto bitmap = Gfx::Bitmap::try_create_from_serialized_byte_buffer(move(data)); drag_bitmap = bitmap->to_shareable_bitmap(); } diff --git a/Userland/Libraries/LibGUI/FileIconProvider.cpp b/Userland/Libraries/LibGUI/FileIconProvider.cpp index d4209c89d3..d06c8d0a50 100644 --- a/Userland/Libraries/LibGUI/FileIconProvider.cpp +++ b/Userland/Libraries/LibGUI/FileIconProvider.cpp @@ -56,8 +56,8 @@ static void initialize_if_needed() auto config = Core::ConfigFile::open("/etc/FileIconProvider.ini"); - s_symlink_emblem = Gfx::Bitmap::load_from_file("/res/icons/symlink-emblem.png"); - s_symlink_emblem_small = Gfx::Bitmap::load_from_file("/res/icons/symlink-emblem-small.png"); + s_symlink_emblem = Gfx::Bitmap::try_load_from_file("/res/icons/symlink-emblem.png"); + s_symlink_emblem_small = Gfx::Bitmap::try_load_from_file("/res/icons/symlink-emblem-small.png"); s_hard_disk_icon = Icon::default_icon("hard-disk"); s_directory_icon = Icon::default_icon("filetype-folder"); diff --git a/Userland/Libraries/LibGUI/FilePicker.cpp b/Userland/Libraries/LibGUI/FilePicker.cpp index c8cf52bcbe..fee2f76185 100644 --- a/Userland/Libraries/LibGUI/FilePicker.cpp +++ b/Userland/Libraries/LibGUI/FilePicker.cpp @@ -72,11 +72,11 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, const StringView& filen case Mode::OpenMultiple: case Mode::OpenFolder: set_title("Open"); - set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png")); + set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png")); break; case Mode::Save: set_title("Save as"); - set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png")); + set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/save.png")); break; } resize(560, 320); @@ -109,7 +109,7 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, const StringView& filen }; auto open_parent_directory_action = Action::create( - "Open parent directory", { Mod_Alt, Key_Up }, Gfx::Bitmap::load_from_file("/res/icons/16x16/open-parent-directory.png"), [this](const Action&) { + "Open parent directory", { Mod_Alt, Key_Up }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open-parent-directory.png"), [this](const Action&) { set_path(String::formatted("{}/..", m_model->root_path())); }, this); @@ -123,7 +123,7 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, const StringView& filen toolbar.add_separator(); auto mkdir_action = Action::create( - "New directory...", Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"), [this](const Action&) { + "New directory...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png"), [this](const Action&) { String value; if (InputBox::show(this, value, "Enter name:", "New directory") == InputBox::ExecOK && !value.is_empty()) { auto new_dir_path = LexicalPath::canonicalized_path(String::formatted("{}/{}", m_model->root_path(), value)); diff --git a/Userland/Libraries/LibGUI/FileSystemModel.cpp b/Userland/Libraries/LibGUI/FileSystemModel.cpp index 6e0a9530be..dfe7b37185 100644 --- a/Userland/Libraries/LibGUI/FileSystemModel.cpp +++ b/Userland/Libraries/LibGUI/FileSystemModel.cpp @@ -550,13 +550,13 @@ static HashMap<String, RefPtr<Gfx::Bitmap>> s_thumbnail_cache; static RefPtr<Gfx::Bitmap> render_thumbnail(const StringView& path) { - auto png_bitmap = Gfx::Bitmap::load_from_file(path); + auto png_bitmap = Gfx::Bitmap::try_load_from_file(path); if (!png_bitmap) return nullptr; double scale = min(32 / (double)png_bitmap->width(), 32 / (double)png_bitmap->height()); - auto thumbnail = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, { 32, 32 }); + auto thumbnail = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, { 32, 32 }); Gfx::IntRect destination = Gfx::IntRect(0, 0, (int)(png_bitmap->width() * scale), (int)(png_bitmap->height() * scale)); destination.center_within(thumbnail->rect()); diff --git a/Userland/Libraries/LibGUI/FontPicker.cpp b/Userland/Libraries/LibGUI/FontPicker.cpp index a2e0b66709..4dce0fb203 100644 --- a/Userland/Libraries/LibGUI/FontPicker.cpp +++ b/Userland/Libraries/LibGUI/FontPicker.cpp @@ -24,7 +24,7 @@ FontPicker::FontPicker(Window* parent_window, const Gfx::Font* current_font, boo { set_title("Font picker"); resize(430, 280); - set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-font-editor.png")); + set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png")); auto& widget = set_main_widget<GUI::Widget>(); if (!widget.load_from_gml(font_picker_dialog_gml)) diff --git a/Userland/Libraries/LibGUI/Icon.cpp b/Userland/Libraries/LibGUI/Icon.cpp index c31d6d6180..2d686b9f9e 100644 --- a/Userland/Libraries/LibGUI/Icon.cpp +++ b/Userland/Libraries/LibGUI/Icon.cpp @@ -74,8 +74,8 @@ void IconImpl::set_bitmap_for_size(int size, RefPtr<Gfx::Bitmap>&& bitmap) Icon Icon::default_icon(const StringView& name) { - auto bitmap16 = Gfx::Bitmap::load_from_file(String::formatted("/res/icons/16x16/{}.png", name)); - auto bitmap32 = Gfx::Bitmap::load_from_file(String::formatted("/res/icons/32x32/{}.png", name)); + auto bitmap16 = Gfx::Bitmap::try_load_from_file(String::formatted("/res/icons/16x16/{}.png", name)); + auto bitmap32 = Gfx::Bitmap::try_load_from_file(String::formatted("/res/icons/32x32/{}.png", name)); return Icon(move(bitmap16), move(bitmap32)); } diff --git a/Userland/Libraries/LibGUI/LinkLabel.cpp b/Userland/Libraries/LibGUI/LinkLabel.cpp index 06f2e2a489..31706aeefc 100644 --- a/Userland/Libraries/LibGUI/LinkLabel.cpp +++ b/Userland/Libraries/LibGUI/LinkLabel.cpp @@ -29,7 +29,7 @@ LinkLabel::LinkLabel(String text) void LinkLabel::setup_actions() { - m_open_action = GUI::Action::create("Show in File Manager", {}, Gfx::Bitmap::load_from_file("/res/icons/16x16/app-file-manager.png"), [&](const GUI::Action&) { + m_open_action = GUI::Action::create("Show in File Manager", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png"), [&](const GUI::Action&) { if (on_click) on_click(); }); diff --git a/Userland/Libraries/LibGUI/MessageBox.cpp b/Userland/Libraries/LibGUI/MessageBox.cpp index 3d366abbcb..2b0a59a5e0 100644 --- a/Userland/Libraries/LibGUI/MessageBox.cpp +++ b/Userland/Libraries/LibGUI/MessageBox.cpp @@ -45,13 +45,13 @@ RefPtr<Gfx::Bitmap> MessageBox::icon() const { switch (m_type) { case Type::Information: - return Gfx::Bitmap::load_from_file("/res/icons/32x32/msgbox-information.png"); + return Gfx::Bitmap::try_load_from_file("/res/icons/32x32/msgbox-information.png"); case Type::Warning: - return Gfx::Bitmap::load_from_file("/res/icons/32x32/msgbox-warning.png"); + return Gfx::Bitmap::try_load_from_file("/res/icons/32x32/msgbox-warning.png"); case Type::Error: - return Gfx::Bitmap::load_from_file("/res/icons/32x32/msgbox-error.png"); + return Gfx::Bitmap::try_load_from_file("/res/icons/32x32/msgbox-error.png"); case Type::Question: - return Gfx::Bitmap::load_from_file("/res/icons/32x32/msgbox-question.png"); + return Gfx::Bitmap::try_load_from_file("/res/icons/32x32/msgbox-question.png"); default: return nullptr; } diff --git a/Userland/Libraries/LibGUI/MultiView.cpp b/Userland/Libraries/LibGUI/MultiView.cpp index ffa03c25a3..c44854ce85 100644 --- a/Userland/Libraries/LibGUI/MultiView.cpp +++ b/Userland/Libraries/LibGUI/MultiView.cpp @@ -104,17 +104,17 @@ void MultiView::set_column_visible(int column_index, bool visible) void MultiView::build_actions() { m_view_as_table_action = Action::create_checkable( - "Table view", Gfx::Bitmap::load_from_file("/res/icons/16x16/table-view.png"), [this](auto&) { + "Table view", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/table-view.png"), [this](auto&) { set_view_mode(ViewMode::Table); }); m_view_as_icons_action = Action::create_checkable( - "Icon view", Gfx::Bitmap::load_from_file("/res/icons/16x16/icon-view.png"), [this](auto&) { + "Icon view", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/icon-view.png"), [this](auto&) { set_view_mode(ViewMode::Icon); }); m_view_as_columns_action = Action::create_checkable( - "Columns view", Gfx::Bitmap::load_from_file("/res/icons/16x16/columns-view.png"), [this](auto&) { + "Columns view", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/columns-view.png"), [this](auto&) { set_view_mode(ViewMode::Columns); }); diff --git a/Userland/Libraries/LibGUI/SpinBox.cpp b/Userland/Libraries/LibGUI/SpinBox.cpp index 71590307b6..59a5647398 100644 --- a/Userland/Libraries/LibGUI/SpinBox.cpp +++ b/Userland/Libraries/LibGUI/SpinBox.cpp @@ -33,12 +33,12 @@ SpinBox::SpinBox() }; m_increment_button = add<Button>(); - m_increment_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/upward-triangle.png")); + m_increment_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/upward-triangle.png")); m_increment_button->set_focus_policy(GUI::FocusPolicy::NoFocus); m_increment_button->on_click = [this](auto) { set_value(m_value + 1); }; m_increment_button->set_auto_repeat_interval(150); m_decrement_button = add<Button>(); - m_decrement_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/downward-triangle.png")); + m_decrement_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/downward-triangle.png")); m_decrement_button->set_focus_policy(GUI::FocusPolicy::NoFocus); m_decrement_button->on_click = [this](auto) { set_value(m_value - 1); }; m_decrement_button->set_auto_repeat_interval(150); diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp index eeafb357bf..65891732ea 100644 --- a/Userland/Libraries/LibGUI/TextEditor.cpp +++ b/Userland/Libraries/LibGUI/TextEditor.cpp @@ -86,7 +86,7 @@ void TextEditor::create_actions() m_delete_action = CommonActions::make_delete_action([&](auto&) { do_delete(); }, this); if (is_multi_line()) { m_go_to_line_action = Action::create( - "Go to line...", { Mod_Ctrl, Key_L }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"), [this](auto&) { + "Go to line...", { Mod_Ctrl, Key_L }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"), [this](auto&) { String value; if (InputBox::show(window(), value, "Line:", "Go to line") == InputBox::ExecOK) { auto line_target = value.to_uint(); diff --git a/Userland/Libraries/LibGUI/TreeView.cpp b/Userland/Libraries/LibGUI/TreeView.cpp index 0d2929373a..21ab9dd632 100644 --- a/Userland/Libraries/LibGUI/TreeView.cpp +++ b/Userland/Libraries/LibGUI/TreeView.cpp @@ -39,8 +39,8 @@ TreeView::TreeView() set_background_role(ColorRole::Base); set_foreground_role(ColorRole::BaseText); set_column_headers_visible(false); - m_expand_bitmap = Gfx::Bitmap::load_from_file("/res/icons/serenity/treeview-expand.png"); - m_collapse_bitmap = Gfx::Bitmap::load_from_file("/res/icons/serenity/treeview-collapse.png"); + m_expand_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/serenity/treeview-expand.png"); + m_collapse_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/serenity/treeview-collapse.png"); } TreeView::~TreeView() diff --git a/Userland/Libraries/LibGUI/Window.cpp b/Userland/Libraries/LibGUI/Window.cpp index d021eafc0b..083a36e2e8 100644 --- a/Userland/Libraries/LibGUI/Window.cpp +++ b/Userland/Libraries/LibGUI/Window.cpp @@ -826,7 +826,7 @@ OwnPtr<WindowBackingStore> Window::create_backing_store(const Gfx::IntSize& size } // FIXME: Plumb scale factor here eventually. - auto bitmap = Gfx::Bitmap::create_with_anonymous_buffer(format, move(buffer), size, 1, {}); + auto bitmap = Gfx::Bitmap::try_create_with_anonymous_buffer(format, move(buffer), size, 1, {}); if (!bitmap) { VERIFY(size.width() <= INT16_MAX); VERIFY(size.height() <= INT16_MAX); @@ -856,7 +856,7 @@ void Window::set_icon(const Gfx::Bitmap* icon) Gfx::IntSize icon_size = icon ? icon->size() : Gfx::IntSize(16, 16); - m_icon = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, icon_size); + m_icon = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, icon_size); VERIFY(m_icon); if (icon) { Painter painter(*m_icon); diff --git a/Userland/Libraries/LibGfx/BMPLoader.cpp b/Userland/Libraries/LibGfx/BMPLoader.cpp index 059ebd246d..9e13aad455 100644 --- a/Userland/Libraries/LibGfx/BMPLoader.cpp +++ b/Userland/Libraries/LibGfx/BMPLoader.cpp @@ -1185,7 +1185,7 @@ static bool decode_bmp_pixel_data(BMPLoadingContext& context) const u32 width = abs(context.dib.core.width); const u32 height = abs(context.dib.core.height); - context.bitmap = Bitmap::create_purgeable(format, { static_cast<int>(width), static_cast<int>(height) }); + context.bitmap = Bitmap::try_create_purgeable(format, { static_cast<int>(width), static_cast<int>(height) }); if (!context.bitmap) { dbgln("BMP appears to have overly large dimensions"); return false; diff --git a/Userland/Libraries/LibGfx/Bitmap.cpp b/Userland/Libraries/LibGfx/Bitmap.cpp index 52d3b30900..a9c43dfed9 100644 --- a/Userland/Libraries/LibGfx/Bitmap.cpp +++ b/Userland/Libraries/LibGfx/Bitmap.cpp @@ -65,7 +65,7 @@ static bool size_would_overflow(BitmapFormat format, const IntSize& size, int sc return Checked<size_t>::multiplication_would_overflow(pitch, size.height() * scale_factor); } -RefPtr<Bitmap> Bitmap::create(BitmapFormat format, const IntSize& size, int scale_factor) +RefPtr<Bitmap> Bitmap::try_create(BitmapFormat format, const IntSize& size, int scale_factor) { auto backing_store = Bitmap::allocate_backing_store(format, size, scale_factor, Purgeable::No); if (!backing_store.has_value()) @@ -73,7 +73,7 @@ RefPtr<Bitmap> Bitmap::create(BitmapFormat format, const IntSize& size, int scal return adopt_ref(*new Bitmap(format, size, scale_factor, Purgeable::No, backing_store.value())); } -RefPtr<Bitmap> Bitmap::create_purgeable(BitmapFormat format, const IntSize& size, int scale_factor) +RefPtr<Bitmap> Bitmap::try_create_purgeable(BitmapFormat format, const IntSize& size, int scale_factor) { auto backing_store = Bitmap::allocate_backing_store(format, size, scale_factor, Purgeable::Yes); if (!backing_store.has_value()) @@ -81,7 +81,7 @@ RefPtr<Bitmap> Bitmap::create_purgeable(BitmapFormat format, const IntSize& size return adopt_ref(*new Bitmap(format, size, scale_factor, Purgeable::Yes, backing_store.value())); } -RefPtr<Bitmap> Bitmap::create_shareable(BitmapFormat format, const IntSize& size, int scale_factor) +RefPtr<Bitmap> Bitmap::try_create_shareable(BitmapFormat format, const IntSize& size, int scale_factor) { if (size_would_overflow(format, size, scale_factor)) return nullptr; @@ -92,7 +92,7 @@ RefPtr<Bitmap> Bitmap::create_shareable(BitmapFormat format, const IntSize& size auto buffer = Core::AnonymousBuffer::create_with_size(round_up_to_power_of_two(data_size, PAGE_SIZE)); if (!buffer.is_valid()) return nullptr; - return Bitmap::create_with_anonymous_buffer(format, buffer, size, scale_factor, {}); + return Bitmap::try_create_with_anonymous_buffer(format, buffer, size, scale_factor, {}); } Bitmap::Bitmap(BitmapFormat format, const IntSize& size, int scale_factor, Purgeable purgeable, const BackingStore& backing_store) @@ -111,14 +111,14 @@ Bitmap::Bitmap(BitmapFormat format, const IntSize& size, int scale_factor, Purge m_needs_munmap = true; } -RefPtr<Bitmap> Bitmap::create_wrapper(BitmapFormat format, const IntSize& size, int scale_factor, size_t pitch, void* data) +RefPtr<Bitmap> Bitmap::try_create_wrapper(BitmapFormat format, const IntSize& size, int scale_factor, size_t pitch, void* data) { if (size_would_overflow(format, size, scale_factor)) return nullptr; return adopt_ref(*new Bitmap(format, size, scale_factor, pitch, data)); } -RefPtr<Bitmap> Bitmap::load_from_file(String const& path, int scale_factor) +RefPtr<Bitmap> Bitmap::try_load_from_file(String const& path, int scale_factor) { if (scale_factor > 1 && path.starts_with("/res/")) { LexicalPath lexical_path { path }; @@ -188,7 +188,7 @@ static bool check_size(const IntSize& size, int scale_factor, BitmapFormat forma return true; } -RefPtr<Bitmap> Bitmap::create_with_anonymous_buffer(BitmapFormat format, Core::AnonymousBuffer buffer, const IntSize& size, int scale_factor, const Vector<RGBA32>& palette) +RefPtr<Bitmap> Bitmap::try_create_with_anonymous_buffer(BitmapFormat format, Core::AnonymousBuffer buffer, const IntSize& size, int scale_factor, const Vector<RGBA32>& palette) { if (size_would_overflow(format, size, scale_factor)) return nullptr; @@ -205,7 +205,7 @@ RefPtr<Bitmap> Bitmap::create_with_anonymous_buffer(BitmapFormat format, Core::A /// - palette count /// - palette data (= palette count * BGRA8888) /// - image data (= actual size * u8) -RefPtr<Bitmap> Bitmap::create_from_serialized_byte_buffer(ByteBuffer&& buffer) +RefPtr<Bitmap> Bitmap::try_create_from_serialized_byte_buffer(ByteBuffer&& buffer) { InputMemoryStream stream { buffer }; unsigned actual_size; @@ -242,7 +242,7 @@ RefPtr<Bitmap> Bitmap::create_from_serialized_byte_buffer(ByteBuffer&& buffer) auto data = stream.bytes().slice(stream.offset(), actual_size); - auto bitmap = Bitmap::create(format, { width, height }, scale_factor); + auto bitmap = Bitmap::try_create(format, { width, height }, scale_factor); if (!bitmap) return {}; @@ -303,9 +303,9 @@ RefPtr<Gfx::Bitmap> Bitmap::clone() const { RefPtr<Gfx::Bitmap> new_bitmap {}; if (m_purgeable) { - new_bitmap = Bitmap::create_purgeable(format(), size(), scale()); + new_bitmap = Bitmap::try_create_purgeable(format(), size(), scale()); } else { - new_bitmap = Bitmap::create(format(), size(), scale()); + new_bitmap = Bitmap::try_create(format(), size(), scale()); } if (!new_bitmap) { @@ -320,7 +320,7 @@ RefPtr<Gfx::Bitmap> Bitmap::clone() const RefPtr<Gfx::Bitmap> Bitmap::rotated(Gfx::RotationDirection rotation_direction) const { - auto new_bitmap = Gfx::Bitmap::create(this->format(), { height(), width() }, scale()); + auto new_bitmap = Gfx::Bitmap::try_create(this->format(), { height(), width() }, scale()); if (!new_bitmap) return nullptr; @@ -343,7 +343,7 @@ RefPtr<Gfx::Bitmap> Bitmap::rotated(Gfx::RotationDirection rotation_direction) c RefPtr<Gfx::Bitmap> Bitmap::flipped(Gfx::Orientation orientation) const { - auto new_bitmap = Gfx::Bitmap::create(this->format(), { width(), height() }, scale()); + auto new_bitmap = Gfx::Bitmap::try_create(this->format(), { width(), height() }, scale()); if (!new_bitmap) return nullptr; @@ -368,7 +368,7 @@ RefPtr<Gfx::Bitmap> Bitmap::scaled(int sx, int sy) const if (sx == 1 && sy == 1) return this; - auto new_bitmap = Gfx::Bitmap::create(format(), { width() * sx, height() * sy }, scale()); + auto new_bitmap = Gfx::Bitmap::try_create(format(), { width() * sx, height() * sy }, scale()); if (!new_bitmap) return nullptr; @@ -402,7 +402,7 @@ RefPtr<Gfx::Bitmap> Bitmap::scaled(float sx, float sy) const int scaled_width = (int)ceilf(sx * (float)width()); int scaled_height = (int)ceilf(sy * (float)height()); - auto new_bitmap = Gfx::Bitmap::create(format(), { scaled_width, scaled_height }, scale()); + auto new_bitmap = Gfx::Bitmap::try_create(format(), { scaled_width, scaled_height }, scale()); if (!new_bitmap) return nullptr; @@ -476,7 +476,7 @@ RefPtr<Gfx::Bitmap> Bitmap::scaled(float sx, float sy) const RefPtr<Gfx::Bitmap> Bitmap::cropped(Gfx::IntRect crop) const { - auto new_bitmap = Gfx::Bitmap::create(format(), { crop.width(), crop.height() }, 1); + auto new_bitmap = Gfx::Bitmap::try_create(format(), { crop.width(), crop.height() }, 1); if (!new_bitmap) return nullptr; @@ -501,7 +501,7 @@ RefPtr<Bitmap> Bitmap::to_bitmap_backed_by_anonymous_buffer() const auto buffer = Core::AnonymousBuffer::create_with_size(round_up_to_power_of_two(size_in_bytes(), PAGE_SIZE)); if (!buffer.is_valid()) return nullptr; - auto bitmap = Bitmap::create_with_anonymous_buffer(m_format, move(buffer), size(), scale(), palette_to_vector()); + auto bitmap = Bitmap::try_create_with_anonymous_buffer(m_format, move(buffer), size(), scale(), palette_to_vector()); if (!bitmap) return nullptr; memcpy(bitmap->scanline(0), scanline(0), size_in_bytes()); diff --git a/Userland/Libraries/LibGfx/Bitmap.h b/Userland/Libraries/LibGfx/Bitmap.h index 87f2499f18..2fc2247486 100644 --- a/Userland/Libraries/LibGfx/Bitmap.h +++ b/Userland/Libraries/LibGfx/Bitmap.h @@ -90,13 +90,14 @@ enum RotationDirection { class Bitmap : public RefCounted<Bitmap> { public: - static RefPtr<Bitmap> create(BitmapFormat, const IntSize&, int intrinsic_scale = 1); - static RefPtr<Bitmap> create_shareable(BitmapFormat, const IntSize&, int intrinsic_scale = 1); - static RefPtr<Bitmap> create_purgeable(BitmapFormat, const IntSize&, int intrinsic_scale = 1); - static RefPtr<Bitmap> create_wrapper(BitmapFormat, const IntSize&, int intrinsic_scale, size_t pitch, void*); - static RefPtr<Bitmap> load_from_file(String const& path, int scale_factor = 1); - static RefPtr<Bitmap> create_with_anonymous_buffer(BitmapFormat, Core::AnonymousBuffer, const IntSize&, int intrinsic_scale, const Vector<RGBA32>& palette); - static RefPtr<Bitmap> create_from_serialized_byte_buffer(ByteBuffer&& buffer); + [[nodiscard]] static RefPtr<Bitmap> try_create(BitmapFormat, const IntSize&, int intrinsic_scale = 1); + [[nodiscard]] static RefPtr<Bitmap> try_create_shareable(BitmapFormat, const IntSize&, int intrinsic_scale = 1); + [[nodiscard]] static RefPtr<Bitmap> try_create_purgeable(BitmapFormat, const IntSize&, int intrinsic_scale = 1); + [[nodiscard]] static RefPtr<Bitmap> try_create_wrapper(BitmapFormat, const IntSize&, int intrinsic_scale, size_t pitch, void*); + [[nodiscard]] static RefPtr<Bitmap> try_load_from_file(String const& path, int scale_factor = 1); + [[nodiscard]] static RefPtr<Bitmap> try_create_with_anonymous_buffer(BitmapFormat, Core::AnonymousBuffer, const IntSize&, int intrinsic_scale, const Vector<RGBA32>& palette); + [[nodiscard]] static RefPtr<Bitmap> try_create_from_serialized_byte_buffer(ByteBuffer&& buffer); + static bool is_path_a_supported_image_format(const StringView& path) { #define __ENUMERATE_IMAGE_FORMAT(Name, Ext) \ diff --git a/Userland/Libraries/LibGfx/ClassicStylePainter.cpp b/Userland/Libraries/LibGfx/ClassicStylePainter.cpp index 6509350f58..ecbf0bb4c0 100644 --- a/Userland/Libraries/LibGfx/ClassicStylePainter.cpp +++ b/Userland/Libraries/LibGfx/ClassicStylePainter.cpp @@ -344,10 +344,10 @@ static const Gfx::Bitmap& circle_bitmap(bool checked, bool changing) void ClassicStylePainter::paint_radio_button(Painter& painter, const IntRect& rect, const Palette&, bool is_checked, bool is_being_pressed) { if (!s_unfilled_circle_bitmap) { - s_unfilled_circle_bitmap = Bitmap::load_from_file("/res/icons/serenity/unfilled-radio-circle.png"); - s_filled_circle_bitmap = Bitmap::load_from_file("/res/icons/serenity/filled-radio-circle.png"); - s_changing_filled_circle_bitmap = Bitmap::load_from_file("/res/icons/serenity/changing-filled-radio-circle.png"); - s_changing_unfilled_circle_bitmap = Bitmap::load_from_file("/res/icons/serenity/changing-unfilled-radio-circle.png"); + s_unfilled_circle_bitmap = Bitmap::try_load_from_file("/res/icons/serenity/unfilled-radio-circle.png"); + s_filled_circle_bitmap = Bitmap::try_load_from_file("/res/icons/serenity/filled-radio-circle.png"); + s_changing_filled_circle_bitmap = Bitmap::try_load_from_file("/res/icons/serenity/changing-filled-radio-circle.png"); + s_changing_unfilled_circle_bitmap = Bitmap::try_load_from_file("/res/icons/serenity/changing-unfilled-radio-circle.png"); } auto& bitmap = circle_bitmap(is_checked, is_being_pressed); diff --git a/Userland/Libraries/LibGfx/DDSLoader.cpp b/Userland/Libraries/LibGfx/DDSLoader.cpp index d83721ef9a..43a28d9d4d 100644 --- a/Userland/Libraries/LibGfx/DDSLoader.cpp +++ b/Userland/Libraries/LibGfx/DDSLoader.cpp @@ -792,7 +792,7 @@ static bool decode_dds(DDSLoadingContext& context) dbgln_if(DDS_DEBUG, "There are {} bytes remaining, we need {} for mipmap level {} of the image", stream.remaining(), needed_bytes, mipmap_level); VERIFY(stream.remaining() >= needed_bytes); - context.bitmap = Bitmap::create_purgeable(BitmapFormat::BGRA8888, { width, height }); + context.bitmap = Bitmap::try_create_purgeable(BitmapFormat::BGRA8888, { width, height }); decode_bitmap(stream, context, format, width, height); diff --git a/Userland/Libraries/LibGfx/Emoji.cpp b/Userland/Libraries/LibGfx/Emoji.cpp index 665557083c..b29c9c0839 100644 --- a/Userland/Libraries/LibGfx/Emoji.cpp +++ b/Userland/Libraries/LibGfx/Emoji.cpp @@ -19,7 +19,7 @@ const Bitmap* Emoji::emoji_for_code_point(u32 code_point) if (it != s_emojis.end()) return (*it).value.ptr(); - auto bitmap = Bitmap::load_from_file(String::formatted("/res/emoji/U+{:X}.png", code_point)); + auto bitmap = Bitmap::try_load_from_file(String::formatted("/res/emoji/U+{:X}.png", code_point)); if (!bitmap) { s_emojis.set(code_point, nullptr); return nullptr; diff --git a/Userland/Libraries/LibGfx/Filters/GenericConvolutionFilter.h b/Userland/Libraries/LibGfx/Filters/GenericConvolutionFilter.h index b82a4cd0be..0ee8ec01ad 100644 --- a/Userland/Libraries/LibGfx/Filters/GenericConvolutionFilter.h +++ b/Userland/Libraries/LibGfx/Filters/GenericConvolutionFilter.h @@ -94,7 +94,7 @@ public: if (&target == &source && (!apply_cache.m_target || !apply_cache.m_target->size().contains(source_rect.size()))) { // TODO: We probably don't need the entire source_rect, we could inflate // the target_rect appropriately - apply_cache.m_target = Gfx::Bitmap::create(source.format(), source_rect.size()); + apply_cache.m_target = Gfx::Bitmap::try_create(source.format(), source_rect.size()); target_rect.translate_by(-target_rect.location()); } diff --git a/Userland/Libraries/LibGfx/GIFLoader.cpp b/Userland/Libraries/LibGfx/GIFLoader.cpp index 233fbac0ed..2db9ec6060 100644 --- a/Userland/Libraries/LibGfx/GIFLoader.cpp +++ b/Userland/Libraries/LibGfx/GIFLoader.cpp @@ -299,10 +299,10 @@ static bool decode_frame(GIFLoadingContext& context, size_t frame_index) size_t start_frame = context.current_frame + 1; if (context.state < GIFLoadingContext::State::FrameComplete) { start_frame = 0; - context.frame_buffer = Bitmap::create_purgeable(BitmapFormat::BGRA8888, { context.logical_screen.width, context.logical_screen.height }); + context.frame_buffer = Bitmap::try_create_purgeable(BitmapFormat::BGRA8888, { context.logical_screen.width, context.logical_screen.height }); if (!context.frame_buffer) return false; - context.prev_frame_buffer = Bitmap::create_purgeable(BitmapFormat::BGRA8888, { context.logical_screen.width, context.logical_screen.height }); + context.prev_frame_buffer = Bitmap::try_create_purgeable(BitmapFormat::BGRA8888, { context.logical_screen.width, context.logical_screen.height }); if (!context.prev_frame_buffer) return false; } else if (frame_index < context.current_frame) { diff --git a/Userland/Libraries/LibGfx/ICOLoader.cpp b/Userland/Libraries/LibGfx/ICOLoader.cpp index dd6b27e5ca..e9d458c345 100644 --- a/Userland/Libraries/LibGfx/ICOLoader.cpp +++ b/Userland/Libraries/LibGfx/ICOLoader.cpp @@ -246,7 +246,7 @@ static bool load_ico_bmp(ICOLoadingContext& context, ICOImageDescriptor& desc) return false; } - desc.bitmap = Bitmap::create_purgeable(BitmapFormat::BGRA8888, { desc.width, desc.height }); + desc.bitmap = Bitmap::try_create_purgeable(BitmapFormat::BGRA8888, { desc.width, desc.height }); if (!desc.bitmap) return false; Bitmap& bitmap = *desc.bitmap; diff --git a/Userland/Libraries/LibGfx/JPGLoader.cpp b/Userland/Libraries/LibGfx/JPGLoader.cpp index c6c2b46508..3d784f85c2 100644 --- a/Userland/Libraries/LibGfx/JPGLoader.cpp +++ b/Userland/Libraries/LibGfx/JPGLoader.cpp @@ -1064,7 +1064,7 @@ static void ycbcr_to_rgb(const JPGLoadingContext& context, Vector<Macroblock>& m static bool compose_bitmap(JPGLoadingContext& context, const Vector<Macroblock>& macroblocks) { - context.bitmap = Bitmap::create_purgeable(BitmapFormat::BGRx8888, { context.frame.width, context.frame.height }); + context.bitmap = Bitmap::try_create_purgeable(BitmapFormat::BGRx8888, { context.frame.width, context.frame.height }); if (!context.bitmap) return false; diff --git a/Userland/Libraries/LibGfx/PNGLoader.cpp b/Userland/Libraries/LibGfx/PNGLoader.cpp index 7174b6d50d..d40ba7591f 100644 --- a/Userland/Libraries/LibGfx/PNGLoader.cpp +++ b/Userland/Libraries/LibGfx/PNGLoader.cpp @@ -606,7 +606,7 @@ static bool decode_png_bitmap_simple(PNGLoadingContext& context) } } - context.bitmap = Bitmap::create_purgeable(context.has_alpha() ? BitmapFormat::BGRA8888 : BitmapFormat::BGRx8888, { context.width, context.height }); + context.bitmap = Bitmap::try_create_purgeable(context.has_alpha() ? BitmapFormat::BGRA8888 : BitmapFormat::BGRx8888, { context.width, context.height }); if (!context.bitmap) { context.state = PNGLoadingContext::State::Error; @@ -708,7 +708,7 @@ static bool decode_adam7_pass(PNGLoadingContext& context, Streamer& streamer, in } } - subimage_context.bitmap = Bitmap::create(context.bitmap->format(), { subimage_context.width, subimage_context.height }); + subimage_context.bitmap = Bitmap::try_create(context.bitmap->format(), { subimage_context.width, subimage_context.height }); if (!unfilter(subimage_context)) { subimage_context.bitmap = nullptr; return false; @@ -726,7 +726,7 @@ static bool decode_adam7_pass(PNGLoadingContext& context, Streamer& streamer, in static bool decode_png_adam7(PNGLoadingContext& context) { Streamer streamer(context.decompression_buffer->data(), context.decompression_buffer->size()); - context.bitmap = Bitmap::create_purgeable(context.has_alpha() ? BitmapFormat::BGRA8888 : BitmapFormat::BGRx8888, { context.width, context.height }); + context.bitmap = Bitmap::try_create_purgeable(context.has_alpha() ? BitmapFormat::BGRA8888 : BitmapFormat::BGRx8888, { context.width, context.height }); if (!context.bitmap) return false; diff --git a/Userland/Libraries/LibGfx/PortableImageLoaderCommon.h b/Userland/Libraries/LibGfx/PortableImageLoaderCommon.h index bc3d1d3cee..ac1793b25d 100644 --- a/Userland/Libraries/LibGfx/PortableImageLoaderCommon.h +++ b/Userland/Libraries/LibGfx/PortableImageLoaderCommon.h @@ -178,7 +178,7 @@ static bool read_max_val(TContext& context, Streamer& streamer) template<typename TContext> static bool create_bitmap(TContext& context) { - context.bitmap = Bitmap::create_purgeable(BitmapFormat::BGRx8888, { context.width, context.height }); + context.bitmap = Bitmap::try_create_purgeable(BitmapFormat::BGRx8888, { context.width, context.height }); if (!context.bitmap) { context.state = TContext::State::Error; return false; diff --git a/Userland/Libraries/LibGfx/ShareableBitmap.cpp b/Userland/Libraries/LibGfx/ShareableBitmap.cpp index 76783d5e6c..b1b789b64b 100644 --- a/Userland/Libraries/LibGfx/ShareableBitmap.cpp +++ b/Userland/Libraries/LibGfx/ShareableBitmap.cpp @@ -76,7 +76,7 @@ bool decode(Decoder& decoder, Gfx::ShareableBitmap& shareable_bitmap) auto buffer = Core::AnonymousBuffer::create_from_anon_fd(anon_file.take_fd(), Gfx::Bitmap::size_in_bytes(Gfx::Bitmap::minimum_pitch(size.width(), bitmap_format), size.height())); if (!buffer.is_valid()) return false; - auto bitmap = Gfx::Bitmap::create_with_anonymous_buffer(bitmap_format, buffer, size, scale, palette); + auto bitmap = Gfx::Bitmap::try_create_with_anonymous_buffer(bitmap_format, buffer, size, scale, palette); if (!bitmap) return false; shareable_bitmap = Gfx::ShareableBitmap { bitmap.release_nonnull(), Gfx::ShareableBitmap::ConstructWithKnownGoodBitmap }; diff --git a/Userland/Libraries/LibTTF/Glyf.cpp b/Userland/Libraries/LibTTF/Glyf.cpp index 9ec8e6f586..cfc60eb7f5 100644 --- a/Userland/Libraries/LibTTF/Glyf.cpp +++ b/Userland/Libraries/LibTTF/Glyf.cpp @@ -207,7 +207,7 @@ void Rasterizer::draw_path(Gfx::Path& path) RefPtr<Gfx::Bitmap> Rasterizer::accumulate() { - auto bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, m_size); + auto bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, m_size); if (!bitmap) return {}; Color base_color = Color::from_rgb(0xffffff); diff --git a/Userland/Libraries/LibVT/TerminalWidget.cpp b/Userland/Libraries/LibVT/TerminalWidget.cpp index 780496296e..c79f002924 100644 --- a/Userland/Libraries/LibVT/TerminalWidget.cpp +++ b/Userland/Libraries/LibVT/TerminalWidget.cpp @@ -123,12 +123,12 @@ TerminalWidget::TerminalWidget(int ptm_fd, bool automatic_size_policy, RefPtr<Co m_terminal.set_size(m_config->read_num_entry("Window", "Width", 80), m_config->read_num_entry("Window", "Height", 25)); - m_copy_action = GUI::Action::create("&Copy", { Mod_Ctrl | Mod_Shift, Key_C }, Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-copy.png"), [this](auto&) { + m_copy_action = GUI::Action::create("&Copy", { Mod_Ctrl | Mod_Shift, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png"), [this](auto&) { copy(); }); m_copy_action->set_swallow_key_event_when_disabled(true); - m_paste_action = GUI::Action::create("&Paste", { Mod_Ctrl | Mod_Shift, Key_V }, Gfx::Bitmap::load_from_file("/res/icons/16x16/paste.png"), [this](auto&) { + m_paste_action = GUI::Action::create("&Paste", { Mod_Ctrl | Mod_Shift, Key_V }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/paste.png"), [this](auto&) { paste(); }); m_paste_action->set_swallow_key_event_when_disabled(true); diff --git a/Userland/Libraries/LibWeb/DOMTreeJSONModel.cpp b/Userland/Libraries/LibWeb/DOMTreeJSONModel.cpp index 78b8dbf81d..a4a9300bc9 100644 --- a/Userland/Libraries/LibWeb/DOMTreeJSONModel.cpp +++ b/Userland/Libraries/LibWeb/DOMTreeJSONModel.cpp @@ -15,9 +15,9 @@ namespace Web { DOMTreeJSONModel::DOMTreeJSONModel(JsonObject dom_tree) : m_dom_tree(move(dom_tree)) { - m_document_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-html.png")); - m_element_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/inspector-object.png")); - m_text_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-unknown.png")); + m_document_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-html.png")); + m_element_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png")); + m_text_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-unknown.png")); map_dom_nodes_to_parent(nullptr, &m_dom_tree); } diff --git a/Userland/Libraries/LibWeb/DOMTreeModel.cpp b/Userland/Libraries/LibWeb/DOMTreeModel.cpp index 5857c78445..35a2799cc0 100644 --- a/Userland/Libraries/LibWeb/DOMTreeModel.cpp +++ b/Userland/Libraries/LibWeb/DOMTreeModel.cpp @@ -17,9 +17,9 @@ namespace Web { DOMTreeModel::DOMTreeModel(DOM::Document& document) : m_document(document) { - m_document_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-html.png")); - m_element_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/inspector-object.png")); - m_text_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-unknown.png")); + m_document_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-html.png")); + m_element_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png")); + m_text_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-unknown.png")); } DOMTreeModel::~DOMTreeModel() diff --git a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp index 0b0f2561c3..63e42b8b8d 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp @@ -80,7 +80,7 @@ bool HTMLCanvasElement::create_bitmap() return false; } if (!m_bitmap || m_bitmap->size() != size) - m_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, size); + m_bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, size); return m_bitmap; } diff --git a/Userland/Libraries/LibWeb/HTML/ImageData.cpp b/Userland/Libraries/LibWeb/HTML/ImageData.cpp index e9044829ed..bab3aa2b21 100644 --- a/Userland/Libraries/LibWeb/HTML/ImageData.cpp +++ b/Userland/Libraries/LibWeb/HTML/ImageData.cpp @@ -26,7 +26,7 @@ RefPtr<ImageData> ImageData::create_with_size(JS::GlobalObject& global_object, i auto data_handle = JS::make_handle(data); - auto bitmap = Gfx::Bitmap::create_wrapper(Gfx::BitmapFormat::RGBA8888, Gfx::IntSize(width, height), 1, width * sizeof(u32), data->data().data()); + auto bitmap = Gfx::Bitmap::try_create_wrapper(Gfx::BitmapFormat::RGBA8888, Gfx::IntSize(width, height), 1, width * sizeof(u32), data->data().data()); if (!bitmap) return nullptr; return adopt_ref(*new ImageData(bitmap.release_nonnull(), move(data_handle))); diff --git a/Userland/Libraries/LibWeb/LayoutTreeModel.cpp b/Userland/Libraries/LibWeb/LayoutTreeModel.cpp index 8832e4ce2a..85dc029617 100644 --- a/Userland/Libraries/LibWeb/LayoutTreeModel.cpp +++ b/Userland/Libraries/LibWeb/LayoutTreeModel.cpp @@ -19,9 +19,9 @@ namespace Web { LayoutTreeModel::LayoutTreeModel(DOM::Document& document) : m_document(document) { - m_document_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-html.png")); - m_element_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/inspector-object.png")); - m_text_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-unknown.png")); + m_document_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-html.png")); + m_element_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png")); + m_text_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-unknown.png")); } LayoutTreeModel::~LayoutTreeModel() diff --git a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp index 9d78de522c..8485992626 100644 --- a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp +++ b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp @@ -145,13 +145,13 @@ void OutOfProcessWebView::handle_resize() if (available_size().is_empty()) return; - if (auto new_bitmap = Gfx::Bitmap::create_shareable(Gfx::BitmapFormat::BGRx8888, available_size())) { + if (auto new_bitmap = Gfx::Bitmap::try_create_shareable(Gfx::BitmapFormat::BGRx8888, available_size())) { m_client_state.front_bitmap = move(new_bitmap); m_client_state.front_bitmap_id = m_client_state.next_bitmap_id++; client().async_add_backing_store(m_client_state.front_bitmap_id, m_client_state.front_bitmap->to_shareable_bitmap()); } - if (auto new_bitmap = Gfx::Bitmap::create_shareable(Gfx::BitmapFormat::BGRx8888, available_size())) { + if (auto new_bitmap = Gfx::Bitmap::try_create_shareable(Gfx::BitmapFormat::BGRx8888, available_size())) { m_client_state.back_bitmap = move(new_bitmap); m_client_state.back_bitmap_id = m_client_state.next_bitmap_id++; client().async_add_backing_store(m_client_state.back_bitmap_id, m_client_state.back_bitmap->to_shareable_bitmap()); diff --git a/Userland/Services/SpiceAgent/ClipboardServerConnection.cpp b/Userland/Services/SpiceAgent/ClipboardServerConnection.cpp index 3dffb40659..ea48e046f2 100644 --- a/Userland/Services/SpiceAgent/ClipboardServerConnection.cpp +++ b/Userland/Services/SpiceAgent/ClipboardServerConnection.cpp @@ -39,8 +39,8 @@ RefPtr<Gfx::Bitmap> ClipboardServerConnection::get_bitmap() return nullptr; auto data = ByteBuffer::copy(clipping.data().data<void>(), clipping.data().size()); - auto clipping_bitmap = Gfx::Bitmap::create_wrapper((Gfx::BitmapFormat)format.value(), { (int)width.value(), (int)height.value() }, scale.value(), pitch.value(), data.data()); - auto bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, { (int)width.value(), (int)height.value() }, scale.value()); + auto clipping_bitmap = Gfx::Bitmap::try_create_wrapper((Gfx::BitmapFormat)format.value(), { (int)width.value(), (int)height.value() }, scale.value(), pitch.value(), data.data()); + auto bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, { (int)width.value(), (int)height.value() }, scale.value()); for (int y = 0; y < clipping_bitmap->physical_height(); ++y) { for (int x = 0; x < clipping_bitmap->physical_width(); ++x) { diff --git a/Userland/Services/Taskbar/ClockWidget.cpp b/Userland/Services/Taskbar/ClockWidget.cpp index 99ee56d5bb..bb1fe1c4b9 100644 --- a/Userland/Services/Taskbar/ClockWidget.cpp +++ b/Userland/Services/Taskbar/ClockWidget.cpp @@ -62,7 +62,7 @@ ClockWidget::ClockWidget() m_prev_date = navigation_container.add<GUI::Button>(); m_prev_date->set_button_style(Gfx::ButtonStyle::Coolbar); m_prev_date->set_fixed_size(24, 24); - m_prev_date->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/go-back.png")); + m_prev_date->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png")); m_prev_date->on_click = [&](auto) { unsigned view_month = m_calendar->view_month(); unsigned view_year = m_calendar->view_year(); @@ -96,7 +96,7 @@ ClockWidget::ClockWidget() m_next_date = navigation_container.add<GUI::Button>(); m_next_date->set_button_style(Gfx::ButtonStyle::Coolbar); m_next_date->set_fixed_size(24, 24); - m_next_date->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png")); + m_next_date->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png")); m_next_date->on_click = [&](auto) { unsigned view_month = m_calendar->view_month(); unsigned view_year = m_calendar->view_year(); @@ -146,7 +146,7 @@ ClockWidget::ClockWidget() m_jump_to_button = settings_container.add<GUI::Button>(); m_jump_to_button->set_button_style(Gfx::ButtonStyle::Coolbar); m_jump_to_button->set_fixed_size(24, 24); - m_jump_to_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/calendar-date.png")); + m_jump_to_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/calendar-date.png")); m_jump_to_button->set_tooltip("Jump to today"); m_jump_to_button->on_click = [this](auto) { jump_to_current_date(); @@ -155,7 +155,7 @@ ClockWidget::ClockWidget() m_calendar_launcher = settings_container.add<GUI::Button>(); m_calendar_launcher->set_button_style(Gfx::ButtonStyle::Coolbar); m_calendar_launcher->set_fixed_size(24, 24); - m_calendar_launcher->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-calendar.png")); + m_calendar_launcher->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-calendar.png")); m_calendar_launcher->set_tooltip("Calendar"); m_calendar_launcher->on_click = [](auto) { pid_t pid; diff --git a/Userland/Services/Taskbar/ShutdownDialog.cpp b/Userland/Services/Taskbar/ShutdownDialog.cpp index 8bc39e1c50..7f7ef31c90 100644 --- a/Userland/Services/Taskbar/ShutdownDialog.cpp +++ b/Userland/Services/Taskbar/ShutdownDialog.cpp @@ -63,7 +63,7 @@ ShutdownDialog::ShutdownDialog() icon_wrapper.set_layout<GUI::VerticalBoxLayout>(); auto& icon_image = icon_wrapper.add<GUI::ImageWidget>(); - icon_image.set_bitmap(Gfx::Bitmap::load_from_file("/res/icons/32x32/shutdown.png")); + icon_image.set_bitmap(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/shutdown.png")); auto& right_container = content_container.add<GUI::Widget>(); right_container.set_layout<GUI::VerticalBoxLayout>(); @@ -112,7 +112,7 @@ ShutdownDialog::ShutdownDialog() center_on_screen(); set_resizable(false); set_title("Exit SerenityOS"); - set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/power.png")); + set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/power.png")); // Request WindowServer to re-update us on the current theme as we might've not been alive for the last notification. refresh_system_theme(); diff --git a/Userland/Services/Taskbar/TaskbarWindow.cpp b/Userland/Services/Taskbar/TaskbarWindow.cpp index d6a2e7a990..4c1a808757 100644 --- a/Userland/Services/Taskbar/TaskbarWindow.cpp +++ b/Userland/Services/Taskbar/TaskbarWindow.cpp @@ -78,7 +78,7 @@ TaskbarWindow::TaskbarWindow(NonnullRefPtr<GUI::Menu> start_menu) m_task_button_container->set_layout<GUI::HorizontalBoxLayout>(); m_task_button_container->layout()->set_spacing(3); - m_default_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/window.png"); + m_default_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png"); m_applet_area_container = main_widget.add<GUI::Frame>(); m_applet_area_container->set_frame_thickness(1); diff --git a/Userland/Services/Taskbar/main.cpp b/Userland/Services/Taskbar/main.cpp index 4ef6f732e1..864d75489b 100644 --- a/Userland/Services/Taskbar/main.cpp +++ b/Userland/Services/Taskbar/main.cpp @@ -110,7 +110,7 @@ NonnullRefPtr<GUI::Menu> build_system_menu() const Vector<String> sorted_app_categories = discover_apps_and_categories(); auto system_menu = GUI::Menu::construct("\xE2\x9A\xA1"); // HIGH VOLTAGE SIGN - system_menu->add_action(GUI::Action::create("About SerenityOS", Gfx::Bitmap::load_from_file("/res/icons/16x16/ladyball.png"), [](auto&) { + system_menu->add_action(GUI::Action::create("About SerenityOS", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/ladyball.png"), [](auto&) { pid_t child_pid; const char* argv[] = { "/bin/About", nullptr }; if ((errno = posix_spawn(&child_pid, "/bin/About", nullptr, nullptr, const_cast<char**>(argv), environ))) { @@ -152,7 +152,7 @@ NonnullRefPtr<GUI::Menu> build_system_menu() auto& category_menu = parent_menu->add_submenu(child_category); auto category_icon_path = category_icons->read_entry("16x16", category); if (!category_icon_path.is_empty()) { - auto icon = Gfx::Bitmap::load_from_file(category_icon_path); + auto icon = Gfx::Bitmap::try_load_from_file(category_icon_path); category_menu.set_icon(icon); } app_category_menus.set(category, category_menu); @@ -200,7 +200,7 @@ NonnullRefPtr<GUI::Menu> build_system_menu() g_themes_group.set_unchecking_allowed(false); g_themes_menu = &system_menu->add_submenu("Themes"); - g_themes_menu->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/themes.png")); + g_themes_menu->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/themes.png")); { Core::DirIterator dt("/res/themes", Core::DirIterator::SkipDots); @@ -232,7 +232,7 @@ NonnullRefPtr<GUI::Menu> build_system_menu() } system_menu->add_separator(); - system_menu->add_action(GUI::Action::create("Help", Gfx::Bitmap::load_from_file("/res/icons/16x16/app-help.png"), [](auto&) { + system_menu->add_action(GUI::Action::create("Help", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png"), [](auto&) { pid_t child_pid; const char* argv[] = { "/bin/Help", nullptr }; if ((errno = posix_spawn(&child_pid, "/bin/Help", nullptr, nullptr, const_cast<char**>(argv), environ))) { @@ -242,7 +242,7 @@ NonnullRefPtr<GUI::Menu> build_system_menu() perror("disown"); } })); - system_menu->add_action(GUI::Action::create("Run...", Gfx::Bitmap::load_from_file("/res/icons/16x16/app-run.png"), [](auto&) { + system_menu->add_action(GUI::Action::create("Run...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-run.png"), [](auto&) { pid_t child_pid; const char* argv[] = { "/bin/Run", nullptr }; if ((errno = posix_spawn(&child_pid, "/bin/Run", nullptr, nullptr, const_cast<char**>(argv), environ))) { @@ -253,7 +253,7 @@ NonnullRefPtr<GUI::Menu> build_system_menu() } })); system_menu->add_separator(); - system_menu->add_action(GUI::Action::create("Exit...", Gfx::Bitmap::load_from_file("/res/icons/16x16/power.png"), [](auto&) { + system_menu->add_action(GUI::Action::create("Exit...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/power.png"), [](auto&) { auto command = ShutdownDialog::show(); if (command.size() == 0) diff --git a/Userland/Services/WindowServer/ClientConnection.cpp b/Userland/Services/WindowServer/ClientConnection.cpp index c4dc7b563a..8b263586a9 100644 --- a/Userland/Services/WindowServer/ClientConnection.cpp +++ b/Userland/Services/WindowServer/ClientConnection.cpp @@ -680,7 +680,7 @@ void ClientConnection::set_window_backing_store(i32 window_id, [[maybe_unused]] did_misbehave("SetWindowBackingStore: Failed to create anonymous buffer for window backing store"); return; } - auto backing_store = Gfx::Bitmap::create_with_anonymous_buffer( + auto backing_store = Gfx::Bitmap::try_create_with_anonymous_buffer( has_alpha_channel ? Gfx::BitmapFormat::BGRA8888 : Gfx::BitmapFormat::BGRx8888, move(buffer), size, @@ -1001,7 +1001,7 @@ Messages::WindowServer::GetScreenBitmapResponse ClientConnection::get_screen_bit return bitmap.to_shareable_bitmap(); } // TODO: Mixed scale setups at what scale? Lowest? Highest? Configurable? - if (auto bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, Screen::bounding_rect().size(), 1)) { + if (auto bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, Screen::bounding_rect().size(), 1)) { Gfx::Painter painter(*bitmap); Screen::for_each([&](auto& screen) { auto screen_rect = screen.rect(); @@ -1043,7 +1043,7 @@ Messages::WindowServer::GetScreenBitmapAroundCursorResponse ClientConnection::ge return bitmap->to_shareable_bitmap(); } - if (auto bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, rect.size(), 1)) { + if (auto bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, rect.size(), 1)) { auto bounding_screen_src_rect = Screen::bounding_rect().intersected(rect); Gfx::Painter painter(*bitmap); auto& screen_with_cursor = ScreenInput::the().cursor_location_screen(); diff --git a/Userland/Services/WindowServer/Compositor.cpp b/Userland/Services/WindowServer/Compositor.cpp index b51b7cab2d..5ef3a82fa2 100644 --- a/Userland/Services/WindowServer/Compositor.cpp +++ b/Userland/Services/WindowServer/Compositor.cpp @@ -99,20 +99,20 @@ void CompositorScreenData::init_bitmaps(Compositor& compositor, Screen& screen) auto size = screen.size(); m_front_bitmap = nullptr; - m_front_bitmap = Gfx::Bitmap::create_wrapper(Gfx::BitmapFormat::BGRx8888, size, screen.scale_factor(), screen.pitch(), screen.scanline(0, 0)); + m_front_bitmap = Gfx::Bitmap::try_create_wrapper(Gfx::BitmapFormat::BGRx8888, size, screen.scale_factor(), screen.pitch(), screen.scanline(0, 0)); m_front_painter = make<Gfx::Painter>(*m_front_bitmap); m_front_painter->translate(-screen.rect().location()); m_back_bitmap = nullptr; if (m_screen_can_set_buffer) - m_back_bitmap = Gfx::Bitmap::create_wrapper(Gfx::BitmapFormat::BGRx8888, size, screen.scale_factor(), screen.pitch(), screen.scanline(1, 0)); + m_back_bitmap = Gfx::Bitmap::try_create_wrapper(Gfx::BitmapFormat::BGRx8888, size, screen.scale_factor(), screen.pitch(), screen.scanline(1, 0)); else - m_back_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, size, screen.scale_factor()); + m_back_bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, size, screen.scale_factor()); m_back_painter = make<Gfx::Painter>(*m_back_bitmap); m_back_painter->translate(-screen.rect().location()); m_temp_bitmap = nullptr; - m_temp_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, size, screen.scale_factor()); + m_temp_bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, size, screen.scale_factor()); m_temp_painter = make<Gfx::Painter>(*m_temp_bitmap); m_temp_painter->translate(-screen.rect().location()); } @@ -786,7 +786,7 @@ bool Compositor::set_wallpaper(const String& path, Function<void(bool)>&& callba { Threading::BackgroundAction<RefPtr<Gfx::Bitmap>>::create( [path](auto&) { - return Gfx::Bitmap::load_from_file(path); + return Gfx::Bitmap::try_load_from_file(path); }, [this, path, callback = move(callback)](RefPtr<Gfx::Bitmap> bitmap) { @@ -915,7 +915,7 @@ void CompositorScreenData::draw_cursor(Screen& screen, const Gfx::IntRect& curso auto& wm = WindowManager::the(); if (!m_cursor_back_bitmap || m_cursor_back_bitmap->size() != cursor_rect.size() || m_cursor_back_bitmap->scale() != screen.scale_factor()) { - m_cursor_back_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, cursor_rect.size(), screen.scale_factor()); + m_cursor_back_bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, cursor_rect.size(), screen.scale_factor()); m_cursor_back_painter = make<Gfx::Painter>(*m_cursor_back_bitmap); } diff --git a/Userland/Services/WindowServer/Cursor.cpp b/Userland/Services/WindowServer/Cursor.cpp index 85df6a2022..9481dd4b35 100644 --- a/Userland/Services/WindowServer/Cursor.cpp +++ b/Userland/Services/WindowServer/Cursor.cpp @@ -132,7 +132,7 @@ bool Cursor::load(const StringView& filename, const StringView& default_filename bool did_load_any = false; auto load_bitmap = [&](const StringView& path, int scale_factor) { - auto bitmap = Gfx::Bitmap::load_from_file(path, scale_factor); + auto bitmap = Gfx::Bitmap::try_load_from_file(path, scale_factor); if (bitmap) { did_load_any = true; m_bitmaps.set(scale_factor, bitmap.release_nonnull()); diff --git a/Userland/Services/WindowServer/MultiScaleBitmaps.cpp b/Userland/Services/WindowServer/MultiScaleBitmaps.cpp index f5c49f20f6..0c1cc854b3 100644 --- a/Userland/Services/WindowServer/MultiScaleBitmaps.cpp +++ b/Userland/Services/WindowServer/MultiScaleBitmaps.cpp @@ -52,7 +52,7 @@ bool MultiScaleBitmaps::load(StringView const& filename, StringView const& defau m_bitmaps.clear(); // If we're reloading the bitmaps get rid of the old ones auto add_bitmap = [&](StringView const& path, int scale_factor) { - auto bitmap = Gfx::Bitmap::load_from_file(path, scale_factor); + auto bitmap = Gfx::Bitmap::try_load_from_file(path, scale_factor); if (bitmap) { auto bitmap_format = bitmap->format(); if (m_format == Gfx::BitmapFormat::Invalid || m_format == bitmap_format) { diff --git a/Userland/Services/WindowServer/Overlays.cpp b/Userland/Services/WindowServer/Overlays.cpp index f183375537..0450e76f3b 100644 --- a/Userland/Services/WindowServer/Overlays.cpp +++ b/Userland/Services/WindowServer/Overlays.cpp @@ -106,7 +106,7 @@ void RectangularOverlay::render(Gfx::Painter& painter, Screen const& screen) auto scale_factor = screen.scale_factor(); auto* bitmap = m_rendered_bitmaps->find_bitmap(scale_factor); if (!bitmap) { - auto new_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, rect().size(), scale_factor); + auto new_bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, rect().size(), scale_factor); if (!new_bitmap) return; bitmap = new_bitmap.ptr(); @@ -291,7 +291,7 @@ void DndOverlay::update_rect() RefPtr<Gfx::Bitmap> DndOverlay::create_bitmap(int scale_factor) { - auto new_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, rect().size(), scale_factor); + auto new_bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, rect().size(), scale_factor); if (!new_bitmap) return {}; diff --git a/Userland/Services/WindowServer/Window.cpp b/Userland/Services/WindowServer/Window.cpp index cf4596a70b..b4db2feb0c 100644 --- a/Userland/Services/WindowServer/Window.cpp +++ b/Userland/Services/WindowServer/Window.cpp @@ -31,7 +31,7 @@ static Gfx::Bitmap& default_window_icon() { static Gfx::Bitmap* s_icon; if (!s_icon) - s_icon = Gfx::Bitmap::load_from_file(default_window_icon_path()).leak_ref(); + s_icon = Gfx::Bitmap::try_load_from_file(default_window_icon_path()).leak_ref(); return *s_icon; } @@ -39,7 +39,7 @@ static Gfx::Bitmap& minimize_icon() { static Gfx::Bitmap* s_icon; if (!s_icon) - s_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/downward-triangle.png").leak_ref(); + s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/downward-triangle.png").leak_ref(); return *s_icon; } @@ -47,7 +47,7 @@ static Gfx::Bitmap& maximize_icon() { static Gfx::Bitmap* s_icon; if (!s_icon) - s_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/upward-triangle.png").leak_ref(); + s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/upward-triangle.png").leak_ref(); return *s_icon; } @@ -55,7 +55,7 @@ static Gfx::Bitmap& restore_icon() { static Gfx::Bitmap* s_icon; if (!s_icon) - s_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/window-restore.png").leak_ref(); + s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window-restore.png").leak_ref(); return *s_icon; } @@ -63,7 +63,7 @@ static Gfx::Bitmap& close_icon() { static Gfx::Bitmap* s_icon; if (!s_icon) - s_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/window-close.png").leak_ref(); + s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window-close.png").leak_ref(); return *s_icon; } @@ -71,7 +71,7 @@ static Gfx::Bitmap& pin_icon() { static Gfx::Bitmap* s_icon; if (!s_icon) - s_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/window-pin.png").leak_ref(); + s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window-pin.png").leak_ref(); return *s_icon; } Window::Window(Core::Object& parent, WindowType type) @@ -144,7 +144,7 @@ void Window::set_rect(const Gfx::IntRect& rect) if (rect.is_empty()) { m_backing_store = nullptr; } else if (!m_client && (!m_backing_store || old_rect.size() != rect.size())) { - m_backing_store = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, m_rect.size()); + m_backing_store = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, m_rect.size()); } invalidate(true, old_rect.size() != rect.size()); diff --git a/Userland/Services/WindowServer/WindowFrame.cpp b/Userland/Services/WindowServer/WindowFrame.cpp index 6cdf02d81c..4465e124f4 100644 --- a/Userland/Services/WindowServer/WindowFrame.cpp +++ b/Userland/Services/WindowServer/WindowFrame.cpp @@ -410,7 +410,7 @@ void WindowFrame::PerScaleRenderedCache::render(WindowFrame& frame, Screen& scre if (tmp_it != s_tmp_bitmap_cache.end()) tmp_it->value = nullptr; - auto bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, frame_rect_including_shadow.size(), scale); + auto bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, frame_rect_including_shadow.size(), scale); if (!bitmap) { s_tmp_bitmap_cache.remove(scale); dbgln("Could not create bitmap of size {}", frame_rect_including_shadow.size()); @@ -433,14 +433,14 @@ void WindowFrame::PerScaleRenderedCache::render(WindowFrame& frame, Screen& scre if (!m_top_bottom || m_top_bottom->width() != frame_rect_including_shadow.width() || m_top_bottom->height() != top_bottom_height || m_top_bottom->scale() != scale) { if (top_bottom_height > 0) - m_top_bottom = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, { frame_rect_including_shadow.width(), top_bottom_height }, scale); + m_top_bottom = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, { frame_rect_including_shadow.width(), top_bottom_height }, scale); else m_top_bottom = nullptr; m_shadow_dirty = true; } if (!m_left_right || m_left_right->height() != frame_rect_including_shadow.height() || m_left_right->width() != left_right_width || m_left_right->scale() != scale) { if (left_right_width > 0) - m_left_right = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, { left_right_width, frame_rect_including_shadow.height() }, scale); + m_left_right = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, { left_right_width, frame_rect_including_shadow.height() }, scale); else m_left_right = nullptr; m_shadow_dirty = true; diff --git a/Userland/Utilities/notify.cpp b/Userland/Utilities/notify.cpp index 5be167dd0b..affa66c389 100644 --- a/Userland/Utilities/notify.cpp +++ b/Userland/Utilities/notify.cpp @@ -26,7 +26,7 @@ int main(int argc, char** argv) auto notification = GUI::Notification::construct(); notification->set_text(message); notification->set_title(title); - notification->set_icon(Gfx::Bitmap::load_from_file(icon_path)); + notification->set_icon(Gfx::Bitmap::try_load_from_file(icon_path)); notification->show(); return 0; |