I am trying to blend two bitmaps with alpha blending method stated on WebP Container Specification. My code is extracting frames and rather displaying on view I am trying to make bitmap for each fraames. As we know decoder draws frames over view using various information stored in that animated webp image, but we are making bitmaps so we need to do some operations to make each frame look like it is displayed over view component by the encoder/decoder. Everything working fine but stuck with the blending flag which stores value of 1 bit. where 0 means alpha blending should be used to blend current frame with previous frame and 1 means no blending.

I am trying to know which mode of PorterDuff class in Android performs alpha blending as per the given formula. Google's WebP Container Specification suggests this formula for alpha blending.

blend.A = src.A + dst.A * (1 - src.A / 255)
if blend.A = 0 then
  blend.RGB = 0
else
  blend.RGB =
      (src.RGB * src.A +
       dst.RGB * dst.A * (1 - src.A / 255)) / blend.A

I am confused that which mode will give exact or similar results according to this formula.

I used SRC_OVER and it simply draws the bitmap over another bitmap. Although those images have the same alpha value for all pixels so I can't be sure if alpha blending is performed or not. I saw a project on gitub which uses SRC and SRC_OVER for alpha blending. as the blending flag contains.

WEBP Encoder called APNG4Android used SRC_OVER and SRC mode for alpha blending. (as doc says blending flag's bit would be 1 - No blending and 0 - alpha blending) so reading codes I guess SRC_OVER is used for alpha blending and SRC for not blending. Her is that Code block

0

There are 0 best solutions below