Skip to content

Conversation

@dl3sdo
Copy link
Member

@dl3sdo dl3sdo commented Nov 17, 2025

Add option to export .png and .tif(f) images with transparent background.

layout->addRow(world_file_check);
world_file_check->hide();

transparent_background_check = new QCheckBox(tr("Make background transparent"));
Copy link
Member

@dg0yt dg0yt Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot enforce transparent background, but we can enforce white background.
Looking for feedback: Should this be

  • White background

For formats without transparency, drawing the white background would be done implicitly.

Copy link
Member Author

@dl3sdo dl3sdo Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That change is indeed an option as making the background transparent is sometimes a unrealizable promise.
OTOH a user might wonder what happens if he deselects the checkmark: will the background be black (BTW: this happens if Mapper would allow transparency for .bmp) as he might not think about transparency?
So I personally have a preference for the current wording but I'm fine with the alternative.

&& !path.endsWith(QLatin1String(".tif"), Qt::CaseInsensitive) && !path.endsWith(QLatin1String(".tiff"), Qt::CaseInsensitive) )
{
transparent_background = false;
QMessageBox::warning(this, tr("Warning"), tr("Transparent background not supported for this file format."));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personaly I would prefer to avoid message box.
Changing the option as suggested might reduce the need for information. But at least a status bar notification would still be needed: Uninformed users might wonder why the background is always white in JPEG format.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that the average user of Mapper is a fast learner and notices how and why to avoid this dialog box being shown. I modified the dialog to be an information instead a warning and tell about the consequence (i.e., using a white background). At least a dialog is not so easy to be overseen.

@dl3sdo
Copy link
Member Author

dl3sdo commented Nov 23, 2025

@dg0yt: As proposed by you, I tried to use a status bar indication instead. However, this status bar indication won't be visible as it is (normally) immediately replaced by
main_window->showStatusBarMessage(tr("Exported successfully to %1").arg(path), 4000);
We could change the MainWindow::showStatusBarMessage functionality to put multiple messages in a queue and show one after another (maybe by using the QStatusBar::messageChanged() signal) but that means an extension of how Mapper shows status bar messages.
I thus still prefer the message box to avoid fundamental changes for now.

Another issue is that the 'Transparent background' setting is not saved in the map file - but neither is the 'Save world file' option (or 'Tiles' size in KMZ export).
Maybe because we only save Print related options in the <print> element.
I see three options (for another PR):

  1. don't save image related options (i.e., transparent background and world file)
  2. also save image related options in the <print> element
  3. add a new (e.g., <export>) element

What is your opinion?

Add option to export .png and .tif(f) images with transparent
background.
@dl3sdo dl3sdo force-pushed the export-transparent-images branch from a024459 to 6bf1500 Compare November 24, 2025 12:28
@dl3sdo
Copy link
Member Author

dl3sdo commented Nov 24, 2025

Pushing the minimal required set of changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants