简体   繁体   中英

sws_scale PAL8 to RGBA returns image that isn't clear

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM