From c36cd2d4da74251e5ff8c64187bc7fd0f036b60c Mon Sep 17 00:00:00 2001 From: GenevensiS <66968533+G-e-n-e-v-e-n-s-i-S@users.noreply.github.com> Date: Mon, 2 Jun 2025 14:05:26 +0200 Subject: [PATCH] don't draw checkerboard when image field has default --- src/render/value/image.cpp | 13 +++++++------ src/render/value/image.hpp | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/render/value/image.cpp b/src/render/value/image.cpp index a5e2759f..2f37965c 100644 --- a/src/render/value/image.cpp +++ b/src/render/value/image.cpp @@ -99,19 +99,20 @@ bool very_light(const Image& image) { return total >= 210 * 3; } -Bitmap ImageValueViewer::imagePlaceholder(const Rotation& rot, UInt w, UInt h, const Image& background, bool editing) { +Bitmap ImageValueViewer::imagePlaceholder(const Rotation& rot, UInt w, UInt h, const Image& default_image, bool editing) { // Bitmap and memory dc - Bitmap bmp(w, h, 24); + Bitmap bmp(w, h, 32); wxMemoryDC mdc; mdc.SelectObject(bmp); RealRect rect(0,0,w,h); RotatedDC dc(mdc, 0, rect, 1.0, QUALITY_AA); // Draw (checker) background - if (!background.Ok() || background.HasAlpha()) { + if (!default_image.Ok()) { draw_checker(dc, rect); } - if (background.Ok()) { - dc.DrawImage(background, RealPoint(0,0)); + else { + if (default_image.HasAlpha()) bmp.UseAlpha(true); + dc.DrawImage(default_image, RealPoint(0,0)); } // Draw text if (editing) { @@ -122,7 +123,7 @@ Bitmap ImageValueViewer::imagePlaceholder(const Rotation& rot, UInt w, UInt h, c if (rs.width <= w - 10 && rs.height < h - 10) { // text fits RealPoint pos = align_in_rect(ALIGN_MIDDLE_CENTER, rs, rect); - bool black_on_white = !background.Ok() || very_light(background); + bool black_on_white = !default_image.Ok() || very_light(default_image); dc.SetTextForeground(black_on_white ? *wxWHITE : *wxBLACK); dc.DrawText(_("double click to load image"), pos, 2, 4); // blurred dc.SetTextForeground(black_on_white ? *wxBLACK : *wxWHITE); diff --git a/src/render/value/image.hpp b/src/render/value/image.hpp index 7029fc40..f957f5af 100644 --- a/src/render/value/image.hpp +++ b/src/render/value/image.hpp @@ -32,6 +32,6 @@ private: bool is_default; ///< Is the default placeholder image used? /// Generate a placeholder image - static Bitmap imagePlaceholder(const Rotation& rot, UInt w, UInt h, const Image& background, bool editing); + static Bitmap imagePlaceholder(const Rotation& rot, UInt w, UInt h, const Image& default_image, bool editing); };