mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:37:34 +00:00
LibGfx: Add the start of a JBIG2 loader
JBIG2 is infamous for two things: 1. It's used in xerox scanners were it falsifies scanned numbers: https://www.dkriesel.com/en/blog/2013/0802_xerox-workcentres_are_switching_written_numbers_when_scanning 2. It was allegedly used in an iOS zero day, in a very cool way: https://googleprojectzero.blogspot.com/2021/12/a-deep-dive-into-nso-zero-click.html Needless to say, we need support for it in Serenity. (...because it's used in PDF files.) This adds all the scaffolding, but no actual implementation yet. It's enough for `file` to print the mime type of .jb2 files, but `image` can't do anything with the files yet.
This commit is contained in:
parent
d7ad134ae5
commit
58838db445
12 changed files with 86 additions and 22 deletions
26
Userland/Libraries/LibGfx/ImageFormats/JBIG2Loader.cpp
Normal file
26
Userland/Libraries/LibGfx/ImageFormats/JBIG2Loader.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Nico Weber <thakis@chromium.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibGfx/ImageFormats/JBIG2Loader.h>
|
||||
|
||||
// Spec: ITU-T_T_88__08_2018.pdf in the zip file here:
|
||||
// https://www.itu.int/rec/T-REC-T.88-201808-I
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
bool JBIG2ImageDecoderPlugin::sniff(ReadonlyBytes data)
|
||||
{
|
||||
// JBIG2 spec, Annex D, D.4.1 ID string
|
||||
u8 id_string[] = { 0x97, 0x4A, 0x42, 0x32, 0x0D, 0x0A, 0x1A, 0x0A };
|
||||
return data.starts_with(id_string);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullOwnPtr<ImageDecoderPlugin>> JBIG2ImageDecoderPlugin::create(ReadonlyBytes)
|
||||
{
|
||||
return Error::from_string_view("FIXME: Draw the rest of the owl"sv);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue