Repository navigation
Draw splash PNG via GDI+ DrawImage - #22
Open
dominicletz wants to merge 2 commits into
Open
dominicletz wants to merge 2 commits into
dominicletz wants to merge 2 commits into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Splash PNG scaling darkens logo edges
- Splash PNG scaling now draws with ImageAttributes WrapModeTileFlipXY so bicubic samples repeat edge texels instead of transparent black.
Preview (4b4e3627a1)
diff --git a/docs/status/windows.md b/docs/status/windows.md
--- a/docs/status/windows.md
+++ b/docs/status/windows.md
@@ -13,6 +13,7 @@
| `--edw-no-beam` / argv strip | done | E2E |
| Ini + defaults | done | Same semantics as Linux/macOS |
| Shared AppUserModelID | done | `[windows] app_user_model_id` / `--edw-app-user-model-id`; host sets via Win32 API; BEAM via `EDW_APP_USER_MODEL_ID` + prebuilt `aumid_nif.dll` (`build_windows.ps1`) |
+| Splash PNG draw | done | GDI+ `DrawImage` at 128×128 (HQ bicubic); PE icon fallback when file missing |
| Lifetime reconnect | done | Packaged mode (keep listening) |
| Lifetime coupled | done | Exit on disconnect; `--edw-no-beam` exits |
| Window open/show/hide/title/min size | done | E2E window test |
diff --git a/native/windows/src/splash_window.cpp b/native/windows/src/splash_window.cpp
--- a/native/windows/src/splash_window.cpp
+++ b/native/windows/src/splash_window.cpp
@@ -14,6 +14,21 @@
if (!g_bg_brush) g_bg_brush = CreateSolidBrush(kSplashBg);
return g_bg_brush;
}
+
+bool ensure_gdiplus() {
+ static ULONG_PTR token = 0;
+ static bool ready = false;
+ if (ready) return true;
+ Gdiplus::GdiplusStartupInput input;
+ ready = Gdiplus::GdiplusStartup(&token, &input, nullptr) == Gdiplus::Ok;
+ return ready;
+}
+
+bool is_raster_image_path(const std::wstring& path) {
+ return ends_with_ignore_case(path, L".png") || ends_with_ignore_case(path, L".jpg") ||
+ ends_with_ignore_case(path, L".jpeg") || ends_with_ignore_case(path, L".bmp") ||
+ ends_with_ignore_case(path, L".gif");
+}
} // namespace
void SplashWindow::register_class() {
@@ -37,18 +52,36 @@
SplashWindow::~SplashWindow() { dismiss(); }
-void SplashWindow::load_icon(const std::optional<std::wstring>& icon_path) {
+void SplashWindow::clear_logo() {
+ if (image_) {
+ delete image_;
+ image_ = nullptr;
+ }
if (icon_ && owns_icon_) DestroyIcon(icon_);
icon_ = nullptr;
owns_icon_ = false;
+}
+void SplashWindow::load_icon(const std::optional<std::wstring>& icon_path) {
+ clear_logo();
+
if (icon_path && !icon_path->empty()) {
+ if (is_raster_image_path(*icon_path) && ensure_gdiplus()) {
+ auto* img = new Gdiplus::Image(icon_path->c_str());
+ if (img->GetLastStatus() == Gdiplus::Ok) {
+ image_ = img;
+ return;
+ }
+ delete img;
+ }
+
icon_ = load_hicon_from_file(*icon_path);
if (icon_) {
owns_icon_ = true;
return;
}
}
+
icon_ = extract_module_icon();
owns_icon_ = icon_ != nullptr;
}
@@ -92,9 +125,7 @@
DestroyWindow(hwnd_);
hwnd_ = nullptr;
}
- if (icon_ && owns_icon_) DestroyIcon(icon_);
- icon_ = nullptr;
- owns_icon_ = false;
+ clear_logo();
}
LRESULT CALLBACK SplashWindow::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
@@ -135,9 +166,22 @@
GetClientRect(hwnd, &client);
FillRect(hdc, &client, splash_bg_brush());
- if (icon_) {
- int icon_x = (client.right - kIconSize) / 2;
- int icon_y = 28;
+ const int icon_x = (client.right - kIconSize) / 2;
+ const int icon_y = 28;
+
+ if (image_) {
+ Gdiplus::Graphics graphics(hdc);
+ graphics.SetInterpolationMode(Gdiplus::InterpolationModeHighQualityBicubic);
+ graphics.SetPixelOffsetMode(Gdiplus::PixelOffsetModeHighQuality);
+ graphics.SetSmoothingMode(Gdiplus::SmoothingModeHighQuality);
+ // HQ bicubic reads past the source edge. TileFlipXY repeats those texels
+ // so the sample is not transparent black (dark halo on the gray splash).
+ Gdiplus::ImageAttributes attrs;
+ attrs.SetWrapMode(Gdiplus::WrapModeTileFlipXY);
+ const Gdiplus::Rect dest(icon_x, icon_y, kIconSize, kIconSize);
+ graphics.DrawImage(image_, dest, 0, 0, static_cast<INT>(image_->GetWidth()),
+ static_cast<INT>(image_->GetHeight()), Gdiplus::UnitPixel, &attrs);
+ } else if (icon_) {
DrawIconEx(hdc, icon_x, icon_y, icon_, kIconSize, kIconSize, 0, nullptr, DI_NORMAL);
}
diff --git a/native/windows/src/splash_window.hpp b/native/windows/src/splash_window.hpp
--- a/native/windows/src/splash_window.hpp
+++ b/native/windows/src/splash_window.hpp
@@ -2,6 +2,8 @@
#include "win_prefix.hpp"
+#include <gdiplus.h>
+
#include <optional>
#include <string>
@@ -27,8 +29,12 @@
LRESULT on_message(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
void paint(HWND hwnd);
void load_icon(const std::optional<std::wstring>& icon_path);
+ void clear_logo();
HWND hwnd_ = nullptr;
+ // Prefer GDI+ image for PNG/JPEG (sharp DrawImage). Fall back to HICON for
+ // .ico / embedded PE icons.
+ Gdiplus::Image* image_ = nullptr;
HICON icon_ = nullptr;
bool owns_icon_ = false;
std::wstring status_;You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 315cd27. Configure here.
| graphics.SetInterpolationMode(Gdiplus::InterpolationModeHighQualityBicubic); | ||
| graphics.SetPixelOffsetMode(Gdiplus::PixelOffsetModeHighQuality); | ||
| graphics.SetSmoothingMode(Gdiplus::SmoothingModeHighQuality); | ||
| graphics.DrawImage(image_, icon_x, icon_y, kIconSize, kIconSize); |
There was a problem hiding this comment.
Splash PNG scaling darkens logo edges
Medium Severity
High-quality bicubic DrawImage samples pixels outside the source as transparent black, so scaled splash PNGs pick up a dark halo on the gray splash background. Packaged logos are typically transparent PNGs not already 128×128, so this fringe appears on the host-first splash path this change is meant to sharpen.
Reviewed by Cursor Bugbot for commit 315cd27. Configure here.
High-quality bicubic DrawImage reads past the bitmap as transparent black, which leaves a dark halo on the gray splash. TileFlipXY repeats edge texels instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
DrawImagewith high-quality bicubic scaling for splash PNG/JPEGTest plan
splash.pnglooks sharp (no soft PE upscale)Made with Cursor
Note
Low Risk
UI-only splash rendering change with existing icon fallbacks; no security or data-path impact.
Reviewed by Cursor Bugbot for commit 315cd27. Configure here.