mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-01-23 09:06:23 +01:00
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:
parent
b47c904729
commit
2a80c42c87
1 changed files with 2 additions and 1 deletions
|
@ -57,9 +57,10 @@ function Avatar({ url, size, alt = '', ...props }) {
|
||||||
canvas.height,
|
canvas.height,
|
||||||
);
|
);
|
||||||
const hasAlpha = allPixels.data.some((pixel, i) => {
|
const hasAlpha = allPixels.data.some((pixel, i) => {
|
||||||
return i % 4 === 3 && pixel !== 255;
|
return i % 4 === 3 && pixel <= 128;
|
||||||
});
|
});
|
||||||
if (hasAlpha) {
|
if (hasAlpha) {
|
||||||
|
console.log('hasAlpha', hasAlpha, allPixels.data);
|
||||||
avatarRef.current.classList.add('has-alpha');
|
avatarRef.current.classList.add('has-alpha');
|
||||||
alphaCache[url] = true;
|
alphaCache[url] = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue