Skip to content

Commit 7a0e8d3

Browse files
committed
fix: use BlendMode.Src for video frame rendering
Video frames from Windows Media Foundation have alpha bytes set to 0x00. With the default SrcOver blend mode, this causes the video to appear washed out or nearly invisible on light backgrounds, as pixels blend with the underlying surface color. Using BlendMode.Src ensures video pixels fully replace the destination, regardless of the alpha channel value. Fixes #98
1 parent f2fe9c6 commit 7a0e8d3

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

mediaplayer/src/commonMain/kotlin/io/github/kdroidfilter/composemediaplayer/util/ContentScaleCanvasUtils.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package io.github.kdroidfilter.composemediaplayer.util
33
import androidx.compose.foundation.layout.*
44
import androidx.compose.runtime.Composable
55
import androidx.compose.ui.Modifier
6+
import androidx.compose.ui.graphics.BlendMode
67
import androidx.compose.ui.graphics.ImageBitmap
78
import androidx.compose.ui.graphics.drawscope.DrawScope
89
import androidx.compose.ui.layout.ContentScale
@@ -98,7 +99,8 @@ internal fun DrawScope.drawScaledImage(
9899
image = image,
99100
srcOffset = IntOffset(srcX, srcY),
100101
srcSize = IntSize(srcW, srcH),
101-
dstSize = dstSize, // draw into full destination rect
102+
dstSize = dstSize,
103+
blendMode = BlendMode.Src,
102104
)
103105
} else {
104106
/* --------------------------------------------------------------
@@ -109,6 +111,7 @@ internal fun DrawScope.drawScaledImage(
109111
drawImage(
110112
image = image,
111113
dstSize = dstSize,
114+
blendMode = BlendMode.Src,
112115
)
113116
}
114117
}

0 commit comments

Comments
 (0)