Lucas CHOLLET
271d0015fe
LibGfx/JPEGXL: Add support for x4 and x8 upsampling
...
All the logic is exactly the same as for x2 upsampling, so this commit
essentially boils down to adding arrays for default weights and the
logic to select the correct array.
2023-07-24 10:28:36 -04:00
Lucas CHOLLET
9975bdb2d1
LibGfx/JPEGXL: Align the stream to byte boundary before reading a frame
...
As this is stated in the spec, all frames are byte-aligned.
2023-07-22 08:52:57 -04:00
Lucas CHOLLET
a2955501d3
LibGfx/JPEGXL: Don't decode the header twice
...
This is something I missed when I ported the JPEG XL decoder to the new
plugin interface (decoding the header at creation). First sorry because
that's entirely my fault, second sorry because a test should have caught
that.
2023-07-21 22:25:56 -04:00
Lucas CHOLLET
65565d377b
LibGfx/JPEGXL: Accept images with high bit depth
...
Instead of rejecting them, we truncate each value to 8 bits. This is
clearly a hack, but given the lack of support of variable bit-depth in
`Bitmap` this is the only sensible change.
This allows us to display "Iceberg" on https://jpegxl.info/art/ .
2023-07-21 19:34:21 -04:00
Lucas CHOLLET
475f1b6083
LibCore+LibGfx+LibGUI: Consider JPEG XL files as images
...
This includes registering the mime type and adding it to both the list
of supported image format and the filter for images type in LibGUI.
2023-07-21 10:47:34 -06:00
Lucas CHOLLET
e8a63eeb0e
LibGfx/JPEGXL: Add a JPEG-XL decoder :^)
...
JPEG-XL is a new image format standardized by the same committee as the
original JPEG image format. It has all the nice feature of recent
formats, and great compression ratios. For more details, look at:
https://jpegxl.info/
This decoder is far from being feature-complete, as it features a grand
total of 60 FIXMEs and TODOs but anyway, it's still a good start.
I developed this decoder in the Serenity way, I just try to decode a
specific image while staying as close as possible to the specification.
Considering that the format supports a lot of options, and that we
basically support only one possibility for each of them, I'm pretty sure
that we can only decode the image I've developed this decoder for.
Which is:
0aff 3ffa 9101 0688 0001 004c 384b bc41
5ced 86e5 2a19 0696 03e5 4920 8038 000b
2023-07-21 10:47:34 -06:00
Sam Atkins
98eaa4b044
LibGfx: Add functions to convert font widths to/from strings
...
This isn't a "width" in the sense of a fixed-width font, but of the OS/2
width class defined in some font formats.
2023-07-20 08:02:12 +01:00
Sam Atkins
835dada3d3
LibGfx: Add method to get String data from an ICC Profile tag
2023-07-20 08:02:12 +01:00
Sam Atkins
1066831b39
LibGfx: Add a method to get a specific tag from an ICC Profile
2023-07-20 08:02:12 +01:00
Matthew Olsson
25b89aa962
LibGfx: Replace a magic number in ScaledFont with the calculation
...
This makes the reason for the multiplication much clearer.
2023-07-20 06:56:41 +01:00
Matthew Olsson
fa1b1f8244
LibGfx: Forward-declare TagData in WellKnownProfiles
2023-07-20 06:56:41 +01:00
Lucas CHOLLET
b918dcd4db
LibGfx/TGA: Compute the number of pixels with a wider type
...
Both width and height are stored in an u16 inside the TGA header,
computing the total number of pixel without using another type can
easily lead to overflows.
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=55309&q=serenity&can=2
2023-07-19 06:52:45 +02:00
Aliaksandr Kalenik
0bdc93bca8
LibGfx: Fix double x_scale multiply when glyph kerning is cached
...
This resolves a problem where the kerning value multiplied by the scale
is stored in the cache, even though the code retrieving the value from
the cache does not anticipate it to be scaled. As a result, it leads to
a buggy double multiplication by the scale.
2023-07-19 06:43:04 +02:00
Lucas CHOLLET
806808f406
LibGfx: Provide a default implementation for animation-related methods
...
Most image decoders that we have only support non-animated images,
providing a default implementation for them allows to remove quite some
code.
2023-07-18 14:34:35 +01:00
Lucas CHOLLET
7acb656826
LibGfx: Comment ImageDecoderPlugin's interface
...
This is done as an effort to unify the behavior of every plugin. See
#19893 for more details.
2023-07-18 14:34:35 +01:00
Lucas CHOLLET
4291288a31
LibGfx: Remove ImageDecoderPlugin::initialize()
...
No plugin is currently overriding the default implementation, which is a
no-op. So we can safely delete it.
2023-07-18 14:34:35 +01:00
Lucas CHOLLET
3752facfbc
LibGfx: Don't assume that image decoder plugin creation succeeds
...
An image with an incorrect header should fail at this step, so we have
to handle that without crashing.
This should have been done in 7b72bf29
.
2023-07-18 14:34:35 +01:00
Lucas CHOLLET
38dd4168be
LibGfx/ICO: Decode the header in create()
and remove initialize()
...
This is done as a part of #19893 .
2023-07-17 20:17:08 +01:00
Lucas CHOLLET
5d94bb4fcc
LibGfx/PNG: Remove the useless HeaderDecoded
state
2023-07-17 06:49:03 +01:00
Lucas CHOLLET
a173275afa
LibGfx/PNG: Reject files that doesn't start with a IHDr chunk
2023-07-17 06:49:03 +01:00
Lucas CHOLLET
8d907b6535
LibGfx/PNG: Don't use a loop to read chunks in decode_png_ihdr()
...
This chunk is the first one, so we can remove that loop.
2023-07-17 06:49:03 +01:00
Lucas CHOLLET
ff6d82c3e7
LibGfx/PNG: Decode the header in create()
and remove initialize()
...
This is done as a part of #19893 . As `create()` is now the last user of
`decode_png_ihdr()`, we can easily make it return an `ErrorOr`.
2023-07-17 06:49:03 +01:00
Lucas CHOLLET
07f72b6d41
LibGfx/PNG: Don't try to guess if IHDR has been decoded
2023-07-17 06:49:03 +01:00
Lucas CHOLLET
07d3232f2d
LibGfx/PNG: Use PNG specific vocabulary over a generic name
2023-07-17 06:49:03 +01:00
Lucas CHOLLET
0520490577
LibGfx/DDS: Read the header in create()
and remove initialize()
...
This is done as a part of #19893 .
2023-07-17 06:44:37 +01:00
Lucas CHOLLET
aa9470880f
LibGfx/DDS: Prefer static constexpr Array
over Vector<u32>
2023-07-17 06:44:37 +01:00
Lucas CHOLLET
742897519d
LibGfx/DDS: Move the code to read the header in its own function
2023-07-17 06:44:37 +01:00
Lucas CHOLLET
76efdaeecd
LibGfx/DDS: Save the format in the context
...
This allows us to simplify the signature of a few functions.
2023-07-17 06:44:37 +01:00
Lucas CHOLLET
4cb7573582
LibGfx/DDS: Only use a FixedMemoryStream
...
This allows us to drop the data pointer in the `DDSLoadingContext`.
2023-07-17 06:44:37 +01:00
Lucas CHOLLET
8946c0c104
LibGfx/DDS: Don't double-check the magic number
...
This is already done in `decode_dds()`.
2023-07-17 06:44:37 +01:00
Lucas CHOLLET
c336cef065
LibGfx/BMP: Decode the header in create()
and remove initialize()
...
This is done as a part of #19893 .
2023-07-17 06:39:57 +01:00
Lucas CHOLLET
7b72bf2910
LibGfx: Don't assume that image decoder plugin creation succeeds
...
An image with an incorrect header should fail at this step, so we have
to handle that without crashing.
2023-07-17 06:39:57 +01:00
Lucas CHOLLET
35dcd16ea6
LibGfx/TinyVG: Decode the header in create()
and remove initialize()
...
This is done as a part of #19893 .
2023-07-16 20:39:51 +02:00
MacDue
dcb7c299bf
LibGfx: Use stroke_to_fill() for Painter::stroke_path()
2023-07-16 18:52:38 +02:00
MacDue
a9b4e876d0
LibGfx: Only attempt to paint strokes with a width > 0
2023-07-16 18:52:38 +02:00
MacDue
1bc7b0320e
LibGfx: Approximate elliptical arcs with cubic beziers
...
Unlike all other primitives elliptical arcs are non-trivial to
manipulate, it's tricky to correctly apply a Gfx::AffineTransform to
them. Prior to this change, Path::copy_transformed() was still
incorrectly applying transforms such as flips and skews to arcs.
This patch very closely approximates arcs with cubic beziers (I can not
visually spot any differences), which can then be easily and correctly
transformed in all cases.
Most of the maths here was taken from:
https://mortoray.com/rendering-an-svg-elliptical-arc-as-bezier-curves/
(which came from https://www.joecridge.me/content/pdf/bezier-arcs.pdf ,
now a dead link).
2023-07-16 06:22:55 +02:00
MacDue
2a1bf63f9e
LibGfx: Use AK::sincos() and AK::Pi<double> in Path::elliptical_arc_to()
2023-07-16 06:22:55 +02:00
MacDue
8d4f90df4e
LibGfx: Pass angles as floats to Path::elliptical_arc_to()
...
These are stored as floats internally and other parameters are
FloatPoints, so taking doubles is a little inconsistent. Doubles are
needed for the endpoint -> center parametrization conversion, but that
does not need exposing in the API.
2023-07-16 06:22:55 +02:00
MacDue
cf05da131f
LibGfx/TinyVG: Close polygon path in OutlineFillPolygon
2023-07-15 21:36:28 +02:00
MacDue
a853f7b133
LibGfx/TinyVG: Map gradients to equivalent SVG gradients
2023-07-15 21:36:28 +02:00
MacDue
fb61082a6c
LibGfx/TinyVG: Don't move fill/stroke styles that are used in a loop
2023-07-15 21:36:28 +02:00
MacDue
bebfb81c85
LibGfx/TinyVG: Parse and ignore line_width
in paths
...
TinyVG allows varying the line width along a path, this is not supported
in LibGfx so we just ignore this (but still need to parse the field).
2023-07-15 21:36:28 +02:00
Shannon Booth
2b46e6f664
Everywhere: Update copyrights with my new serenityos.org e-mail :^)
2023-07-15 16:21:29 +02:00
Lucas CHOLLET
500097de82
LibGfx/GIF: Decode the header in create()
...
Again, header includes the logical screen descriptor here. This is done
as a part of #19893 .
2023-07-15 09:44:30 +02:00
Lucas CHOLLET
294217586b
LibGfx/GIF: Move the code to read the header to its own function
...
By header, I include the logical screen descriptor here, so all the
information that is not specific to each frame.
2023-07-15 09:44:30 +02:00
Lucas CHOLLET
b8bc84a3e8
LibGfx/GIF: Only use a FixedMemoryStream
...
This allows us to drop the data pointer in the `GIFLoadingContext`.
2023-07-15 09:44:30 +02:00
Lucas CHOLLET
1192e46c09
LibGfx/GIF: Don't read the header twice
...
This is already done in `load_gif_frame_descriptors()`. As the method
`initialize()` is now empty, we can delete it.
2023-07-15 09:44:30 +02:00
Lucas CHOLLET
e56809dda8
LibGfx: Register WebP as a supported image format
...
Basically, it means that we now render a thumbnail for WebP images.
2023-07-15 09:34:07 +02:00
Lucas CHOLLET
8ef5170bd5
LibGfx/WebP: Remove a typo
...
:redthakis:
2023-07-15 09:34:07 +02:00
Lucas CHOLLET
4adef05e6d
LibGfx/WebP: Decode the first chunk in create()
...
And remove `initialize()`.
This is done as a part of #19893 .
2023-07-15 09:34:07 +02:00