fix(ambilight): [PKG-AMBILIGHT-PROXY-01] sample canvas output pixels after resizing

This commit is contained in:
Harvey Zhao committed 2026-09-12 12:04:41 +08:00
1 parent 959cccf515
commit 20f062bc90
19 files changed
+508 -20

No files matched your search

+6 -2
View File
@@ -4,6 +4,9 @@
* (c) 2017-2026 Harvey Zhao
* Released under the MIT License.
*/
function isCanvas(source) {
return source.nodeName === "CANVAS";
}
function createColorSampler(canvas, video, createCanvas) {
let context;
try {
@@ -20,8 +23,9 @@ function createColorSampler(canvas, video, createCanvas) {
function read(active) {
if (destroyed || !active())
return null;
const width = video.videoWidth;
const height = video.videoHeight;
const canvasOutput = isCanvas(video);
const width = canvasOutput ? video.width : video.videoWidth;
const height = canvasOutput ? video.height : video.videoHeight;
if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0)
return null;
const w = width / 3;