PrusaControl icon indicating copy to clipboard operation
PrusaControl copied to clipboard

Fixes related to PNG

Open CounterPillow opened this issue 6 years ago • 0 comments

I ran into a bug today when my package manager automatically losslessly optimised the PNG images that PrusaControl uses: it doesn't have proper logic for loading them. So I've fixed it, and also optimised the PNGs inside the repo.

texture_from_png made several wrong assumptions:

  • 32 bits per pixel images must always be transparent (In PNGs case, maybe, but eeehhhhh)
  • anything with less than 32 bits per pixel must never be transparent (false, PNG has a tRNS chunk which allows for transparency in palette and grayscale modes.)
  • anything transparent will always be RGBA
  • anything not transparent will always be RGB
  • PNG has colour modes that it clearly doesn't have (floating point, 32 bit integer, CMYK, ...)
  • PNG doesn't have colour modes which it has (grayscale with alpha)

The fix is twofold:

  1. Don't care about bitness. It is unrelated to transparency; what we want to know is whether the images have an alpha channel at all.
  2. Make Pillow convert all images with transparency to RGBA, and all images without transparency to RGB. We tell GL we're handing it RGBA and RGB data respectively anyway.

CounterPillow avatar May 09 '18 11:05 CounterPillow