Skip to content

Handle transparency in PNG decoding #199

Closed

Description

@ruuda

I encountered this in src/png/decoder.rs:

            // (b"tRNS", HavePLTE) => {
            //     TODO: handle transparency
            // }

I am not familiar enough with the codebase to fix this myself yet, but will add the issue number to the todo in the code.

Activity

  1. added
    kind: new features
    on Dec 13, 2014
  2. nwin commented on Dec 13, 2014

    @nwin
    Contributor

    The most strait forward solution would probably be to add an alpha channel to the image and selectively set the value to 0. But it's a bit tricky because we would have to lie the outside an use the real color type internally.

  3. retep998 commented on Jan 12, 2015

    @retep998
    Contributor

    I recently ran into some images that image was unable to decode the transparency for.
    Is this issue related to this image?

    When I try working with that image it gives me an opaque black background instead of a transparent background as it should.

  4. added this to the 1.0 milestone on Jan 28, 2015
  5. kmcallister commented on Mar 26, 2015

    @kmcallister

    Unfortunately this is blocking adoption in Servo, because a tRNS chunk is used in Acid2. The base64 for that PNG file is:

    iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAABnRSTlMAAAAAAABupgeRAAAABmJL
    R0QA/wD/AP+gvaeTAAAAEUlEQVR42mP4/58BCv7/ZwAAHfAD/abwPj4AAAAASUVORK5CYII=
    

    The most strait forward solution would probably be to add an alpha channel to the image and selectively set the value to 0. But it's a bit tricky because we would have to lie the outside an use the real color type internally.

    This would be ideal from Servo's perspective. We convert RGB8 to RGBA8 in any case. At this stage we are not too worried about the overhead of copying the data.

  6. nwin commented on Mar 26, 2015

    @nwin
    Contributor

    Maybe I should just hack it in. We have to rewrite the decoder anyway to support streaming at some point.

  7. removed this from the 1.0 milestone on Nov 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    easykind: new features

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions