sws_scale PAL8 to RGBA returns image that isn't clear

433 views Asked by At

I'm using sws_scale to convert images and videos from every format to RGBA, using an SWSContext created thus:

auto context = sws_getContext(width, height, pix_fmt, width, height, AV_PIX_FMT_RGBA,
                              SWS_BICUBIC, nullptr, nullptr, nullptr);

but when using a PNG with color type Palette (pix_fmt = AV_PIX_FMT_PAL8) sws_scale doesn't seem to take into account the transparent color, and the resulting RGBA raster isn't transparent. Is this a bug with sws_scale, or am I making some assumption about the result?

palette image: https://drive.google.com/file/d/1CIPkYeHElNSsH2TAGMmr0kfHxOkYiZTK/view?usp=sharing

RGBA image: https://drive.google.com/open?id=1GMlC7RxJGLy9lpyKLg2RWfup1nJh-JFc

1

There are 1 answers

0
nihohit On BEST ANSWER

I was making a wrong assumption - sws_scale doesn't promise to return a premultiplied-alpha color, so the values I was getting were r:255,g:255,b:255,a:0.