Issue with "saveImage" and Parts with Transparency Nonzero

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
UR_
Veteran
Posts: 1354
Joined: Tue Jan 03, 2017 8:42 pm

Issue with "saveImage" and Parts with Transparency Nonzero

Post by UR_ »

There is glitch using saveImage to screenshot a part with transparency inequal to 0

Here's a sample of two parts and transparency set to 80%

Screenshot 002.png
Screenshot 002.png (3.15 KiB) Viewed 1903 times

Screenshot using:

Code: Select all

Gui.activeDocument().activeView().saveImage('C:/Users/aio/Desktop/pics/saveImage.png',640,480,'Current')
saveImage.png
saveImage.png (15.08 KiB) Viewed 1903 times
displayed color depends on viewers background color :?


No issues using windows standard tool:
Screenshot 001.png
Screenshot 001.png (9.6 KiB) Viewed 1903 times

No issue if transparency is set to zero.


driver:
OpenGL version is: 4.6 (4.6.0 NVIDIA 441.66)


version:

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.19055 (Git)
Build type: Release
Branch: master
Hash: 0af2e760a154ceb08ac2b7230b8ab93e6a20e364
Python version: 3.7.3
Qt version: 5.12.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: German/Germany (de_DE)
otoien
Posts: 87
Joined: Sun Aug 13, 2017 2:38 am

Re: Issue with "saveImage" and Parts with Transparency Nonzero

Post by otoien »

It might be related to the following discussion
https://forum.freecadweb.org/viewtopic. ... 81#p349497

and report of issue
https://forum.freecadweb.org/viewtopic. ... 81#p349497

It seems global transparency of an object is pretty fragile if transparency/color is not uniform of the contained objects/faces.
UR_
Veteran
Posts: 1354
Joined: Tue Jan 03, 2017 8:42 pm

Re: Issue with "saveImage" and Parts with Transparency Nonzero

Post by UR_ »

Screenshot file created by saveImage

Code: Select all

Gui.activeDocument().activeView().saveImage('C:/Users/aio/Desktop/pics/saveImage.png',640,480,'Current')
displayed by gimp

Screenshot 001.png
Screenshot 001.png (19.82 KiB) Viewed 1858 times

Full part is transparent (not only particular faces)
saveImage has no more any WYSIWYG mode.
Even in mode "current" background color isn't merged to transparent portion of color.
Therefore display depends on used image viewer and it's background color settings.
A screenshot shared by your team mate is no more trustworthy, :(


Three different viewers, same file:

Screenshot 003.png
Screenshot 003.png (79 KiB) Viewed 1858 times

file:
saveImage.png.zip
(13.77 KiB) Downloaded 46 times
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Issue with "saveImage" and Parts with Transparency Nonzero

Post by wmayer »

There is glitch using saveImage to screenshot a part with transparency inequal to 0
I think this mainly depends on the graphic driver. On my old and broken Windows machine the transparent faces were painted correctly while with my replacement system (that was a few years older) it caused several problems.
In order to get other things working the git commit f4bc889b4d was required and when creating the key InternalTextureFormat and setting it to GL_RGB at least improves the output image somewhat.
displayed by gimp
The pattern must be created by Gimp because when you load the file with FreeCAD it doesn't do that. I think this pattern is drawn to let the user know that this is a (partially) transparent area.
UR_
Veteran
Posts: 1354
Joined: Tue Jan 03, 2017 8:42 pm

Re: Issue with "saveImage" and Parts with Transparency Nonzero

Post by UR_ »

wmayer wrote:
Thank you for this GrabFramebuffer option. :+1:

Please can we have in View3DInventorViewer.cpp line 1507:

Code: Select all

img = img.scaledToWidth(w);
It's needed especially by users with hires monitors. :?
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Issue with "saveImage" and Parts with Transparency Nonzero

Post by wmayer »

UR_ wrote: Fri Dec 27, 2019 4:56 pm
wmayer wrote:
Thank you for this GrabFramebuffer option. :+1:
For the record for others: this option is implemented in git commit e7796c0497
Note: if no multi-sampling is set then the content should be exactly the same as you see on the screen.
Note: the option to set background color will be ignored when using this nethod
Please can we have in View3DInventorViewer.cpp line 1507:

Code: Select all

img = img.scaledToWidth(w);
It's needed especially by users with hires monitors. :?
git commit bd36bcb22
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Issue with "saveImage" and Parts with Transparency Nonzero

Post by uwestoehr »

wmayer wrote: Fri Dec 27, 2019 12:16 pm I think this mainly depends on the graphic driver. ...
I still have the same problem and was referred to this thread from this one: https://forum.freecadweb.org/viewtopic. ... 85#p358085

I don't understand because I tested now on 3 different Win machines. As user I expect to get a PNG or JPG that shows me the scene exactly as I see it withing FC. One need to share screenshots to colleagues via mail etc. So the generated images must fulfill the standards that the image viewers display it correctly.
The PNG FC created has transparency but the most important thing is that its content displays the situation as it is visible for the user.

So what do I have to do to get (not only PNG but also a JPG) that shows the scene exactly as I see it?
UR_
Veteran
Posts: 1354
Joined: Tue Jan 03, 2017 8:42 pm

Re: Issue with "saveImage" and Parts with Transparency Nonzero

Post by UR_ »

uwestoehr wrote: Sun Jan 05, 2020 9:01 pm So what do I have to do ...
Set this parameter:

Screenshot 001.png
Screenshot 001.png (48.05 KiB) Viewed 1704 times
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Issue with "saveImage" and Parts with Transparency Nonzero

Post by uwestoehr »

UR_ wrote: Sun Jan 05, 2020 9:19 pm Set this parameter:...
I recompiled now everything from scratch but I don't have this parameter in FC 0.19. Do I need a special CMake flag to get it?
UR_
Veteran
Posts: 1354
Joined: Tue Jan 03, 2017 8:42 pm

Re: Issue with "saveImage" and Parts with Transparency Nonzero

Post by UR_ »

uwestoehr wrote: Sun Jan 05, 2020 11:10 pm ... but I don't have this parameter
If you miss this parameter just create a new one.
Just right-click and awake context menu.

Screenshot 002.png
Screenshot 002.png (44.92 KiB) Viewed 1671 times
Post Reply