Giter VIP home page Giter VIP logo

Comments (4)

lvandeve avatar lvandeve commented on July 23, 2024

Hello,

What was the exact image? I could use it as a test case to ensure there is no bug.

The intended behaviour is that if there are less than 257 colors, LodePNG writes the alpha channels in the tRNS chunk (see point 4.2.1.1. here: http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html).

So there are multiple ways that a PNG image file can be semi-translucent: either it uses the RGBA or Grey+Alpha color format, or, it uses a palette, with a tRNS chunk containing the alpha value for each palette index. Of course the latter method has smaller filesize, so is chosen for less than 257 colors.

Normally, most software reads that tRNS chunk, but in theory is allowed to ignore it. What program do you view the PNG image with?

Thanks!

from lodepng.

tomgrus avatar tomgrus commented on July 23, 2024

Hey, you're right! It was Paint Shop Pro 7 (very very old, but it does what I need and I'm used to it). Other software deals with the output just fine.

Thanks and sorry!

from lodepng.

lvandeve avatar lvandeve commented on July 23, 2024

No problem, interesting to know. I'll consider adding a setting (no promises tho :)) for this, after all the PNG spec specifically mentions software is allowed to ignore it...

from lodepng.

abetusk avatar abetusk commented on July 23, 2024

Just FYI, I ran into this same problem while using the C function lodepng_encode32_file. Viewing the PNG in Gimp and it looks like there's only two states for the alpha channel. In Gimp for the output PNG, some pixels look to be completely translucent when they go below a certain threshold while others aren't, but it's either all or none.

Using Imagemagick to convert to a BMP and then viewing through Gimp renders just fine so the alpha channel is definitely there and isn't being lost.

I don't know what the answer is but you might want to consider defaulting to 8-bit RGBA instead of trying to be clever and using a colormap.

from lodepng.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.