mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:17:36 +00:00
LibGfx+LibPDF: Create filter_type() for converting u8 to FilterType
...and use it in LibPDF. No behavior change.
This commit is contained in:
parent
7e4fe8e610
commit
588d6fab22
3 changed files with 23 additions and 17 deletions
|
@ -7,6 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Array.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/SIMD.h>
|
||||
|
||||
namespace Gfx::PNG {
|
||||
|
@ -32,6 +33,13 @@ enum class FilterType : u8 {
|
|||
Paeth,
|
||||
};
|
||||
|
||||
inline ErrorOr<FilterType> filter_type(u8 byte)
|
||||
{
|
||||
if (byte <= 4)
|
||||
return static_cast<FilterType>(byte);
|
||||
return Error::from_string_literal("PNGImageDecoderPlugin: Invalid PNG filter");
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/PNG/#9Filter-type-4-Paeth
|
||||
ALWAYS_INLINE u8 paeth_predictor(u8 a, u8 b, u8 c)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue