From c50575ddaccc966286054483ba22b2dc4f0d6348 Mon Sep 17 00:00:00 2001 From: Liam Date: Sat, 12 Oct 2024 05:22:29 -0400 Subject: [PATCH 1/2] gobjectptr: fix member name --- src/util/gobjectptr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/gobjectptr.h b/src/util/gobjectptr.h index 1f4f37136d..aa142e765b 100644 --- a/src/util/gobjectptr.h +++ b/src/util/gobjectptr.h @@ -20,7 +20,7 @@ public: GObjectPtr() = default; explicit GObjectPtr(T *p, bool add_ref = false) : _p(p) { if (add_ref) _ref(); } GObjectPtr(GObjectPtr const &other) : _p(other._p) { _ref(); } - GObjectPtr &operator=(GObjectPtr const &other) { if (&other != this) { _unref(); _p = other.p; _ref(); } return *this; } + GObjectPtr &operator=(GObjectPtr const &other) { if (&other != this) { _unref(); _p = other._p; _ref(); } return *this; } GObjectPtr(GObjectPtr &&other) noexcept : _p(other._p) { other._p = nullptr; } GObjectPtr &operator=(GObjectPtr &&other) { if (&other != this) { _unref(); _p = other._p; other._p = nullptr; } return *this; } ~GObjectPtr() { _unref(); } -- GitLab From f69264c4ee6bc2bd68b03e02e40823d705d3fe59 Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Fri, 21 Feb 2025 11:28:27 +0100 Subject: [PATCH 2/2] FileDialogImplWin32: Use gdk_pixbuf_new_from_file_at_scale ...to load the preview GdkPixbuf. Before this commit we loaded the GdkPixbuf at the original size and then downscaled. This was inefficient and could hit the size limits of cairo surfaces. Fixes https://gitlab.com/inkscape/inbox/-/issues/11741 --- src/ui/dialog/filedialogimpl-win32.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index bd6cba557e..31d2481419 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -1054,18 +1054,29 @@ bool FileOpenDialogImplWin32::set_image_preview() _mutex->lock(); - try { - _preview_bitmap_image = Gdk::Pixbuf::create_from_file(path); - if (_preview_bitmap_image) { + constexpr int preview_size = 512; + + int width = 0; + int height = 0; + if (gdk_pixbuf_get_file_info(path.c_str(), &width, &height) && + width > 0 && height > 0) + { + GdkPixbuf *c_pixbuf = gdk_pixbuf_new_from_file_at_scale(path.c_str(), + preview_size, + preview_size, + TRUE, + nullptr); + if (c_pixbuf) { + _preview_bitmap_image = Glib::wrap(c_pixbuf); + _preview_image_width = _preview_bitmap_image->get_width(); - _preview_document_width = _preview_image_width; + _preview_document_width = width; _preview_image_height = _preview_bitmap_image->get_height(); - _preview_document_height = _preview_image_height; + _preview_document_height = height; + successful = true; } } - catch (const Gdk::PixbufError&) {} - catch (const Glib::FileError&) {} _mutex->unlock(); -- GitLab