How is PNG transparency handled and why does it not behave the same way across softwares ?


What in the way PNG works makes it so that it behaviour differs according to the software you place it in (transparency or solid color background), and why is it that its behaviour isn’t universal ?

In: 3

PNG has multiples ways of storing transparency. The basic variant is more or less: Paint the background in a certain colour and then define that colour in general to be displayed transparent. This is saving space by only saying once that a certain colour is transparent, but it limits to having only fully transparent or fully opaque.

The second way is an alpha channel. This adds information to each pixel about how transparent it is. Because each pixel has additional information, this costs more size.

Why it is not properly handled by every software depends on the rendering capabilities. To support transparency, the software displaying the PNG needs to have a concept of order of layers and needs to determine the colour based on that order and the involved colours and transparencies at every given pixel. If it opts to ignore PNG transparency, it could default to just drawing transparent as solid white.