Some images have small artifacts of alpha transparency

Change requirement to at least 50% transparency. Not perfect, good for now.
This commit is contained in:
Lim Chee Aun 2023-03-14 11:56:52 +08:00
parent b47c904729
commit 2a80c42c87

View file

@ -57,9 +57,10 @@ function Avatar({ url, size, alt = '', ...props }) {
canvas.height,
);
const hasAlpha = allPixels.data.some((pixel, i) => {
return i % 4 === 3 && pixel !== 255;
return i % 4 === 3 && pixel <= 128;
});
if (hasAlpha) {
console.log('hasAlpha', hasAlpha, allPixels.data);
avatarRef.current.classList.add('has-alpha');
alphaCache[url] = true;
}