mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:47:35 +00:00
LibGfx/JPEGWriter: Fix crash on macOS when csize coefficient is 0
This fixes #21108
This commit is contained in:
parent
80eec1e16b
commit
68e916490b
3 changed files with 9 additions and 5 deletions
|
@ -1 +1,2 @@
|
||||||
1. "image/png"
|
1. "image/png"
|
||||||
|
2. "image/jpeg"
|
||||||
|
|
|
@ -13,10 +13,9 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
// 2. Export a canvas to JPEG data URL
|
// 2. Export a canvas to JPEG data URL
|
||||||
// FIXME: This fails on macOS: https://github.com/SerenityOS/serenity/issues/21108
|
testPart(() => {
|
||||||
// testPart(() => {
|
const canvas = document.createElement('canvas');
|
||||||
// const canvas = document.createElement('canvas');
|
return canvas.toDataURL('image/jpeg').substring(5, 15);
|
||||||
// return canvas.toDataURL('image/jpeg').substring(5, 15);
|
});
|
||||||
// });
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -326,6 +326,10 @@ private:
|
||||||
static u8 csize(i16 coefficient)
|
static u8 csize(i16 coefficient)
|
||||||
{
|
{
|
||||||
VERIFY(coefficient >= -2047 && coefficient <= 2047);
|
VERIFY(coefficient >= -2047 && coefficient <= 2047);
|
||||||
|
|
||||||
|
if (coefficient == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return floor(log2(abs(coefficient))) + 1;
|
return floor(log2(abs(coefficient))) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue