View *.png file with grey-white-checked pattern for transparent background?

Corel Paint Shop Pro

Moderator: Kathy_9

pstein
Posts: 102
Joined: Wed Dec 28, 2011 7:09 pm
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
Corel programs: PSP X2
Location: Germany/Canada

View *.png file with grey-white-checked pattern for transparent background?

Post by pstein »

I have a small *.png file with 256 Color Palette which contains a transparent color assigned to pure red.
So from my point everywhere a red colored pixel appears it means transparent.

When I load this image now into PSP X2 (!) then the picture is shown at first with red color.
I have to click menu

Image--->Palette---> View Color Transparency

to see all transparent red areas as grey-white-checked pattern.

How can I tell PSP to immediately (!) show all transparent areas as grey-white checked?

As far as I remember I have seen such images in the past.

Second problem:
When I paste this *.png file into another (bigger) *.png file then the transparent areas are not transparent but shown in red.

Whats wrong?
LeviFiction
Advisor
Posts: 6774
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Alienware M17xR4
processor: Intel Core i7-3630QM CPU - 2_40GH
ram: 6 GB
Video Card: NVIDIA GeForce GTX 660M
sound_card: Sound Blaster Recon3Di
Hard_Drive_Capacity: 500GB
Corel programs: PSP: 8-2023
Location: USA

Re: View *.png file with grey-white-checked pattern for transparent background?

Post by LeviFiction »

Because paletted transparency is simulated transparency, not actual transparency . It let's you see what it will look like when you save to GIF or PNG before actually saving. And it requires a paletted index to work. When you copy the paletted image onto another image the layer color depth is increased and transparency index is lost.

I have a script to convert single color indexed transparency to full transparency. https://levifiction.wordpress.com/2018/ ... y-to-true/
pstein
Posts: 102
Joined: Wed Dec 28, 2011 7:09 pm
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
Corel programs: PSP X2
Location: Germany/Canada

Re: View *.png file with grey-white-checked pattern for transparent background?

Post by pstein »

@LeviFiction:

Thank you for your answer.
However I am still confused.
LeviFiction wrote: Mon Jan 30, 2023 9:20 am It let's you see what it will look like when you save to GIF or PNG before actually saving.
Hmm, I already saved the PNG into file. So transparency information should be embedded
LeviFiction wrote: Mon Jan 30, 2023 9:20 am And it requires a paletted index to work.
I can look into Palette of the problem PNG. So Palette should already exists.
Can a Palette exist without Palette Index?
LeviFiction wrote: Mon Jan 30, 2023 9:20 am When you copy the paletted image onto another image the layer color depth is increased and transparency index is lost.
So If I understand it correctly if the other PNG image has the same color depth as the added PNG image then it works?
LeviFiction wrote: Mon Jan 30, 2023 9:20 am I have a script to convert single color indexed transparency to full transparency. https://levifiction.wordpress.com/2018/ ... y-to-true/
I had alook at your script. Its a *.pspscipt file.

I guess I have to copy it to subfolder "Scripts-Trusted".
And then ?

How do I apply it?

Altogether: Is there really no way to force PSP to setup transparency to a PNG file? I have full control ober source and target PNG and can adjust palette, color depth and transparency color?
If my memory serves I have done it in the past with another PNG file pair - without your script

If necessary here is my source PNG with red transparency area (see attachement):
Blue dot with transparent background.png
You do not have the required permissions to view the files attached to this post.
LeviFiction
Advisor
Posts: 6774
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Alienware M17xR4
processor: Intel Core i7-3630QM CPU - 2_40GH
ram: 6 GB
Video Card: NVIDIA GeForce GTX 660M
sound_card: Sound Blaster Recon3Di
Hard_Drive_Capacity: 500GB
Corel programs: PSP: 8-2023
Location: USA

Re: View *.png file with grey-white-checked pattern for transparent background?

Post by LeviFiction »

pstein wrote: Tue Jan 31, 2023 8:19 am Hmm, I already saved the PNG into file. So transparency information should be embedded
The format saved to your haddrive and what's inside PSP while you're editing are two different things. A file format is a set of instructions on how data is stored, and read back out. You can save a paletted image to a JPEG and it'll ignore the "transparent pixel". Since JPEG doesn't support transparency. Once an image is open in PSP, it has to follow PSP's rules.

Yes, when PSP saves the image to PNG it marks one color in the indexed color palette as the index to be treated as transparent. But this is for programs that read and render the image. It's not actual transparency. And inside of PSP an indexed image does not support actual transparency. What you see when you view palette transparency is just a rendering of what it will look like after you save to GIF or PNG. If you had to save to see the transparency while editing the image, it would take forever to get anything done. So this is a convenience feature.
pstein wrote: Tue Jan 31, 2023 8:19 am I can look into Palette of the problem PNG. So Palette should already exists.
Can a Palette exist without Palette Index?
pstein wrote: Tue Jan 31, 2023 8:19 am So If I understand it correctly if the other PNG image has the same color depth as the added PNG image then it works?
I wasn't clear here, inside PSP a palleted image doesn't support actual transparency. And as a result it cannot support layers. When you add a layer to a 256-index image it has to increase the color depth of the entire image to support adding layers. If you copy a 256-index image and paste it as a layer it'll increase the color depth of the layer to match the minimum requirement of either the host image or the needs of PSP to support layers. So if I copy a 256-index image and paste as a new layer inside of a 256-index image (both matching color depth) it'll increase both to a full 32-bit color depth to support the layers. If the destination image is a full 64-bit image and you paste a 256-index image as a new layer it'll increase the color depth of the layer to the same full 64-bit to match the destination image.

So it doesn't matter if you started with a palleted image or if both PNGs were the same color depth. Once you are using layers, there is a minimum requirement. And palleted color transparency requires that the image be palleted. Once the color depth is increased, the transparency is lost. It would be nice if PSP asked to transform the transparent pallet color to full alpha transparency, but it doesn't. Hence the existence of my script.
pstein wrote: Tue Jan 31, 2023 8:19 am I had alook at your script. Its a *.pspscipt file.

I guess I have to copy it to subfolder "Scripts-Trusted".
And then ?

How do I apply it?
To use a script copy the PSPScript file to your Scripts-Restricted folder unless told otherwise. Scripts-Restricted prevents the script from accessing your harddrive or other resources. This script does not need to access your harddrive or any advanced features. So Scripts-Restricted is fine. Never use a script that requires the Scripts-Trusted folder unless you Trust the script writer.

To run a script, open the Scripts Toolbar View -> Toolbars -> Script. From the drop-down on the toolbar, select the script to run. Then hit the Play button.
pstein wrote: Tue Jan 31, 2023 8:19 am Altogether: Is there really no way to force PSP to setup transparency to a PNG file? I have full control ober source and target PNG and can adjust palette, color depth and transparency color?
If my memory serves I have done it in the past with another PNG file pair - without your script

If necessary here is my source PNG with red transparency area (see attachement):
Blue dot with transparent background.png
Again, this isn't about PNG and GIF file formats. This is purely about the indexed color image. PSP does not support indexed color transparency. So if the original image is indexed color image, when you open it PSP will let you see what indexed transparency will look like but there are no actual transparent pixels. And it'll ignore the transparency when the indexed image color depth is increased such as when layers are added. If you saved a full-color image as PNG will full transparency as PNG, that PNG file will keep its transparency when you open it and paste it as a layer. So it's about the color depth, not the original file format.

The script I pointed you to works like this. If you open an indexed color image like a GIF and there is a transparent index set this script will change the color of the index to something outrageous that doesn't already exist in the color palette, then increases the color depth to support full transparency. Finally it selects all pixels that are set to this outrageous color and deletes them resulting in actual transparency.

In the past you probably had two PNGs that were not indexed colors, or only one of them was. In those cases, my script would not be required. My script is only for converting indexed color transparency to full 32-bit transparency.
pstein
Posts: 102
Joined: Wed Dec 28, 2011 7:09 pm
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
Corel programs: PSP X2
Location: Germany/Canada

Re: View *.png file with grey-white-checked pattern for transparent background?

Post by pstein »

@LeviFiction:

Thank you for your elaborate explanation.
It seems to work.
However I would like to add 3 important remarks to your "cooking recipe"

1.) After applying your script the user must not apply "Merge all Layers" but save it unmerged into a.png file

2.) Your script seems to setup all values in "Select color range" dialog. The user has nothing to adjust manually.

Correct?

3.) The color depth of the target image does not matter when pasting a *.png with transparency

The procedure should get its own PSP FAQ topic paragraph.

Thank you again.
Peter