General - canvas background color - improve consistency of use

*** Please report new bugs here! ***

Moderators: XnTriq, helmut, xnview, Dreamer

User avatar
user0
XnThusiast
Posts: 2213
Joined: Sat May 09, 2015 9:37 am

General - canvas background color - improve consistency of use

Post by user0 »

XnViewMP 1.8.0 64bit
Windows11 (23H2), display resolution 3840x2160, win scaling 150%


General - canvas background color
there is inconsistency of the canvas background color applied to image when removing transparency (old thread):
- no single source of bg color
- sometimes its ignored and white color is used

To reproduce:
0. have 2 test images in folder (PNGs: 8bit palleted+tRNS chunk, 32bit truecolor+alpha channel)
test_img_color_to_replace_transparency.zip
1. set custom canvas background color (Viewer > Edit > Background color...), eg orange
2. perform any one of the following actions:

Issue A - white color
  • 8bit image
    - Change color depth... > set 24bit, any color
    - Save into format that does not support transparency
    - Rotate... > set 45°, ☑ Use anti-aliasing
    - Offset... set any option for Empty area
    image will be converted to 24bit* (tRNS chunk deleted) - OK
    color of transparent index will be changed to white
    expected behavior
    Index color should be used (yellow in example file)
    * although it's not entirely clear why this is required in the case of Offset, eg Rotation w/o antialiasing can preserve 8bit-ness
  • 32bit image
    - Remove alpha channel
    - Change color depth... > set 32bit, ☑ Replace alpha for 32bit images
    - Save into format that does not support transparency
    alpha channel will be applied using white color as background
    expected behavior
    color from step1 should be used (orange in our case)

Issue B - custom color
  • 8bit
    - Rotate... > set 45° (tool's default bg - black)
    color of 1st index will be used by default, however
    once you set custom bg color in tool - only tool's color, but with some unexpected limitation (try to set pink, black will be used instead)
  • 32bit image
    - Change color depth... > 24bit (tool's default bg - white)
    - Canvas resize... (tool's default bg - black)
    - Rotate... > 45° (tool's default bg - black)

    expected behavior
    some consistency required here
    options:
    • single bg color
      single global variable for all tools to use
      pro: simple
      con: may have issues in batch convert
    • single bg color + master
      tools have individual color, but all updates when 'master' color changed (Viewer > Edit > Background color...)
    • single bg color + master + option
      same as above, plus add checkbox somewhere "Update background color for all tools" (or "Changing master background color updates all tools")


ps: worth mentioning that PNG has background color in spec, but it just seems to be ignored everywhere.
https://www.w3.org/TR/png-3/#apng-canvas wrote: The canvas is the area on the output device on which the frames are to be displayed. The contents of the canvas are not necessarily available to the decoder. If a bKGD chunk exists, it may be used to fill the canvas if there is no preferable background.




Related
You do not have the required permissions to view the files attached to this post.