1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 16:15:10 +00:00
Commit graph

991 commits

Author SHA1 Message Date
MacDue
bb8c8a67dc LibGfx: Fix a slight mistake in AA ellipse error calculation
The initial signs were wrong for the deltas of f(x), the ellipse
equation. This seemed to be fine for larger circles/ellipses but
broke things at a small scale, this was previously fixed with a
horrible "error = error / 4" hack. With this change, all ellipses
look a little better :^)

This also fixed a signed integer overflow Andreas found with UBSAN,
which happened for circles with a 1px radius.
2023-02-19 18:40:15 +01:00
Sam Atkins
2db168acc1 LibTextCodec+Everywhere: Port Decoders to new Strings 2023-02-19 17:15:47 +01:00
Lucas CHOLLET
85287fcc1e LibGfx: Rename all JPG_* macros to JPEG_* in JPEGLoader 2023-02-19 11:31:45 +01:00
Nico Weber
19e91e5211 LibGfx: Dedupe identical tag data objects when writing ICC data
With this, common v4 profiles, such as embedded into jpgs by iPhones
(when configured to write jpegs) or Pixel phones, are identical to
the input when reexported :^)
2023-02-19 08:12:04 +00:00
Nico Weber
2504f2035c LibGfx: Implement serialization of ViewingConditionsTagData 2023-02-19 08:12:04 +00:00
Nico Weber
933002ae5a LibGfx: Move ICC ViewingConditionsHeader to BinaryFormat.h 2023-02-19 08:12:04 +00:00
Lucas CHOLLET
841e359341 LibGfx: Correctly handle JPEG image with restart markers
Restart markers are supposed to be applied every restart interval.
However, in these loops macroblocks are counted taking the luma sampling
factor into consideration. Meaning that we need to correct this factor
when testing if we should reset the DC.

Also, the decoder was discarding the first byte of every scan with a set
restart interval, as `0 % n == 0` is always true.
2023-02-19 07:59:58 +00:00
Linus Groh
10575fea9f LibGfx: Fix sign-compare compile error in TGALoader
I'm not sure why this isn't caught on other people's setups or CI, but
when building on NixOS it fails with:

    error: comparison of integer expressions of different signedness:
    ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Werror=sign-compare]
2023-02-19 00:37:51 +01:00
Nico Weber
22c0e6b60e LibGfx: Implement serialization of MeasurementTagData 2023-02-19 00:01:44 +01:00
Nico Weber
8e5392f9c0 LibGfx: Move ICC MeasurementHeader to BinaryFormat.h 2023-02-19 00:01:44 +01:00
Nico Weber
a1de65c34f LibGfx: Implement serialization of TextTagData 2023-02-19 00:01:44 +01:00
Nico Weber
eaa0e3484b LibGfx: Make TextTagData verify input is 7-bit ASCII
TextTagData::from_bytes() errors out if that isn't the case, but
let's make sure other potential future callers get it right too.
2023-02-19 00:01:44 +01:00
Nico Weber
df5dbc180f LibGfx: Implement serialization of SignatureTagData 2023-02-19 00:01:44 +01:00
Nico Weber
3690305794 LibGfx: Implement serialization of CurveTagData 2023-02-19 00:01:44 +01:00
Nico Weber
1ca7f109a1 LibGfx: Implement serialization of CicpTagData 2023-02-19 00:01:44 +01:00
Nico Weber
fd590fe55d LibGfx: Implement serialization of ChromaticityTagData 2023-02-19 00:01:44 +01:00
Nico Weber
ececea9a1c LibGfx: Implement serialization of ParametricCurveTagData
With this, simple v4 matrix profiles using parametric curves, such as
Compact-ICC-Profiles/profiles/sRGB-v4.icc, can be completely serialized
and the serialized file can be read again by `icc` :^)
2023-02-19 00:01:44 +01:00
Nico Weber
685e2da302 LibGfx: Implement serialization of S15Fixed16ArrayTagData 2023-02-19 00:01:44 +01:00
Nico Weber
931594fce3 LibGfx: Implement serialization of XYZTagData 2023-02-19 00:01:44 +01:00
Nico Weber
eb6dccb675 LibGfx: Implement serialization of MultiLocalizedUnicodeTagData 2023-02-19 00:01:44 +01:00
Nico Weber
4a62cf35fc LibGfx: Move MultiLocalizedUnicodeRawRecord to BinaryFormat.h 2023-02-19 00:01:44 +01:00
Nico Weber
4e72a35398 LibGfx: Add scaffolding for writing tag data
This doesn't deduplicate identical TagDatas yet.

It also doesn't implement actual serialization of TagData yet.
2023-02-19 00:01:44 +01:00
Nico Weber
1457e36b79 LibGfx: Write ICC tag table
All offsets and sizes are set to 0 for now, so this still doesn't
produce a valid icc file. It gets closer, though.
2023-02-19 00:01:44 +01:00
Nico Weber
9bd7048519 LibGfx: Move ICC TagTableEntry to BinaryFormat.h 2023-02-19 00:01:44 +01:00
Nico Weber
026d9ceaf9 LibGfx: Extract encode_header() function in ICC writing code 2023-02-19 00:01:44 +01:00
Lucas CHOLLET
743b6e8781 LibGfx: Rename format name from jpg to jpeg 2023-02-18 23:56:24 +01:00
Lucas CHOLLET
856d0202f2 LibGfx: Rename JPGLoader to JPEGLoader
The patch also contains modifications on several classes, functions or
files that are related to the `JPGLoader`.

Renaming include:
 - JPGLoader{.h, .cpp}
 - JPGImageDecoderPlugin
 - JPGLoadingContext
 - JPG_DEBUG
 - decode_jpg
 - FuzzJPGLoader.cpp
 - Few string literals or texts
2023-02-18 23:56:24 +01:00
MacDue
6ceb185865 LibGfx: Add ALWAYS_INLINE to Color::mixed_with()/interpolate()
I can see small speedup of about 6-7% with this for some gradient
painting, though Tim has been able to see an ~30% speedup in some
resizing cases so this seems like a worthwhile change.

Co-authored-by: Tim Ledbetter <timledbetter@gmail.com>
2023-02-18 17:10:04 +01:00
MacDue
3cc074c1b0 LibGfx: De-duplicate color interpolation code 2023-02-18 17:10:04 +01:00
MacDue
e5a39d134b LibGfx: Move Color::mixed_with() inline
This seems to give a small speedup to gradient painting and removes
Color::mixed_with() (which was 10% of the time) from the profile.
2023-02-18 17:10:04 +01:00
Nico Weber
8b8b7b232e LibGfx: Add start of an ICC profile writer
For now, this can write the profile header.

`icc` refuses to dump its contents since the required copyrightTag,
profileDescriptionTag, and required per-device-class tags are missing,
but it looks ok in a hex editor.
2023-02-17 20:05:50 -07:00
Nico Weber
e8a2c17f8f LibGfx: Add an accessor for the raw ICC Version minor_and_bugfix byte
This is makes it easier to write this value back out.
2023-02-17 20:05:50 -07:00
Nico Weber
0ab3f45135 LibGfx: Add a XYZ->XYZNumber conversion constructor
This is useful for converting XYZs back to the on-disk format.
2023-02-17 20:05:50 -07:00
Nico Weber
0ca620a286 LibGfx: Move ICC ProfileFileSignature into a constant in BinaryFormat.h
...so that it can be used by ICC writing code too.
2023-02-17 20:05:50 -07:00
Nico Weber
78d849bce2 LibGfx: Make ICCHeader use RenderingIntent enum
No behavior change.
2023-02-17 20:05:50 -07:00
Nico Weber
429467f46c LibGfx: Move ICC on-disk structs to new BinaryFormat.h
Removes some existing code duplication and allows future files to use
these structs too.
2023-02-17 20:05:50 -07:00
Nico Weber
2a1cd84155 LibGfx: Minorly simplify BMPLoader's decode_bmp_dib()
header_size is already set to 0 if context.is_included_in_ico is true
and to bmp_header_size else, so we can remove some redundant checks
for context.is_included_in_ico.

No behavior change.
2023-02-18 01:45:12 +01:00
Nico Weber
89a8a198b2 LibGfx: Read embedded ICC profiles in .bmp files
Also add a spec link and slightly more BMP_DEBUG output.
2023-02-17 14:30:34 +00:00
Lucas CHOLLET
782b1d20f5 LibGfx: Remove Bitmap::load_from_fd_and_close()
The method was only used in `load_from_file(StringView path)` and
replacing it with `load_from_file(NonnullOwnPtr<Core::File>)` is very
straightforward.
2023-02-17 10:36:03 +01:00
Lucas CHOLLET
b13695c9f4 LibGfx: Add a stream compatible overload of Bitmap::load_from_file() 2023-02-16 10:56:01 +00:00
Nico Weber
ecc321e099 LibGfx: Move QOIWriter implementation-only things into cpp file
No behavior change.
2023-02-15 20:32:08 +01:00
Sam Atkins
d6075ef5b5 LibTextCodec+Everywhere: Make TextCodec::decoder_for() take a StringView
We don't need a full String/DeprecatedString inside this function, so we
might as well not force users to create one.
2023-02-15 12:48:26 -05:00
Nico Weber
9ba3c8e36d LibGfx: Move ICC::Profile towards "Fallible Constructors" pattern
Not quite there yet due to check_required_tags() / check_tag_types(),
but getting closer :^)
2023-02-15 10:15:24 +01:00
Nico Weber
db614b47dd LibGfx: Move ICC::Profile::read_header() out of class
This one is slightly more involved: To make it nice, extract
all the Profile fields that belong to the header into a separate
struct.
2023-02-15 10:15:24 +01:00
Nico Weber
272e5321e3 LibGfx: Move ICC::Profile::read_tag_table() out of class 2023-02-15 10:15:24 +01:00
Nico Weber
006dff6878 LibGfx: Move ICC::Profile::read_tag() out of class 2023-02-15 10:15:24 +01:00
Nico Weber
1c259b7a5a LibGfx: Validate ICC namedColor2Tag consistency 2023-02-14 19:28:13 +01:00
Nico Weber
45e391dae9 LibGfx: Add v2 "ncol" tag, expand comment
I had missed this in 21cc0c0cb2 because this tag is missing in
"Table 32 — Tag list" in the v2 ICC spec O_o. But it's in
"6.4.26 namedColorTag".

Also add a comment pointing to a page saying that all these tags
are very deprecated and not even recommended for new v2 profiles.
(That's how I noticed that namedColorTag was missing.)
2023-02-14 19:28:13 +01:00
Tim Schumacher
43f98ac6e1 Everywhere: Remove the AK:: qualifier from Stream usages 2023-02-13 00:50:07 +00:00
Tim Schumacher
874c7bba28 LibCore: Remove Stream.h 2023-02-13 00:50:07 +00:00