Andreas Kling
edf01803cd
LibGfx: Make all image decoders reject image sizes above 16384 pixels
...
Let's just say no to shenanigans by capping images at 16384 pixels both
wide and tall. If a day comes in the future where we need to handle
images larger than this, we can deal with it then.
2020-12-25 00:19:06 +01:00
Andreas Kling
0fc8561029
LibGfx: Catch integer overflows in PNG decoder and fail the decode
...
Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28134&sort=reported&q=serenity
2020-12-23 19:04:12 +01:00
Andreas Kling
491a5f5e34
LibGfx: Avoid a ByteBuffer heap allocation in PNG filtering
2020-12-23 18:06:25 +01:00
Andreas Kling
068615fe5e
LibGfx: Reject PNG files with invalid filter/interlace methods
...
Might as well reject these when parsing the IHDR chunk instead of
continuing to load something invalid.
2020-12-23 15:45:59 +01:00
Andreas Kling
c7d0c2ee7a
LibGfx: Teach all image decoders to fail on bitmap allocation failure
...
We don't need to wait for oss-fuzz to find this for us. :^)
2020-12-20 16:04:29 +01:00
Andreas Kling
3e0b913e44
LibGfx: Fail PNG decode if output bitmap can't be allocated
...
Otherwise we'll assert soon afterwards.
Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28838
2020-12-20 15:24:50 +01:00
Andreas Kling
8cf6b75dd9
LibGfx: Remove use of ByteBuffer::wrap() in PNG decoder
2020-12-19 12:00:35 +01:00
Nico Weber
34c5478f31
LibGfx: Validate bit depths, and don't assert on invalid color type
...
The PNG spec says that each color type only allows certain bit depths,
so add explicit checks for that.
2020-11-29 21:28:44 +01:00
Nico Weber
fe999d6281
LibGfx: Make PNGLoader not assert on images with missing chunks
...
Before this, images without IHDR, or palettized images with no or
too small PLTE would lead to asserts. Found by running FuzzPNGLoader
locally.
2020-11-29 21:28:44 +01:00
Nico Weber
7db765bb73
LibGfx: Put debug output in PNGLoader behind PNG_DEBUG
2020-11-29 21:28:44 +01:00
Andreas Kling
c0aa455f76
LibGfx: Refuse to decode PNG images with geometry outside i32 bounds
...
Just fail the decode immediately when encountering an IHDR chunk with
width and/or height larger than the maximum i32 value.
Fixes #3818 .
Fixes #3819 .
2020-11-13 12:01:25 +01:00
Matthew L. Curry
5d5c32cec1
Style: Remove uses of NULL, substituting nullptr
2020-10-13 13:52:52 +02:00
asynts
10c6f062b3
AK: Add Endian.h header to replace NetworkOrdered.h.
2020-08-25 16:22:14 +02:00
Linus Groh
7072806234
Meta: Replace remaining LibM/math.h includes with math.h
2020-08-12 16:18:33 +02:00
asynts
b3d1a05261
Refactor: Expose const_cast by removing ByteBuffer::warp(const void*, size_t)
...
This function did a const_cast internally which made the call side look
"safe". This method is removed completely and call sites are replaced
with ByteBuffer::wrap(const_cast<void*>(data), size) which makes the
behaviour obvious.
2020-08-06 10:33:16 +02:00
Andreas Kling
984683cf34
Revert "LibM: Always include <math.h> instead of <LibM/math.h>"
...
This reverts commit dc12cbca41
.
Sadly this broke the build due to some confusion about <new>.
Reverting until this can be solved fully.
2020-08-04 21:17:43 +02:00
Andreas Kling
dc12cbca41
LibM: Always include <math.h> instead of <LibM/math.h>
...
This makes Lagom pick up the host math.h, which is what we want.
2020-08-04 19:06:27 +02:00
Andreas Kling
7bb6b1d44d
LibGfx: Fix dumb typo in PNG decoder
...
'=' is not the same as '*', indeed.
2020-07-27 19:10:18 +02:00
Andreas Kling
0b1a40a6fe
LibGfx: Simplify some excessive use of pow() in scanline unfiltering
2020-07-27 16:40:12 +02:00
Nico Weber
3f45e9ab1e
Lagom: Add LibGemini, LibGfx
...
They are dependencies of LibWeb and might be useful for
running test-web on GitHub actions one day.
2020-07-23 23:02:28 +02:00
Paul Roukema
b6147de1cb
LibGfx: Implement support for decoding interlaced PNGs
...
This adds support for decoding the Adam7 interlacing used in some PNGs.
Notably this includes many of the images (such as the eyes) used in the acid2 test :^)
Note that the HTML engine still doesn't understand the <object> tag well enough to show the eyes on the test.
2020-06-13 19:47:43 +02:00
Paul Roukema
76553f9f06
LibGfx: Fix PNG decoder handling of 16-bit RGB images
2020-06-13 19:47:43 +02:00
Andreas Kling
bc5a862cbe
LibGfx: Silence debug spam in the PNG decoder
2020-06-13 15:37:10 +02:00
Andreas Kling
fea77abcf6
LibGfx: Fail PNG decoding on invalid scanline filter
...
Only filter types 0 thru 4 are valid.
2020-06-11 16:27:54 +02:00
Andreas Kling
d59a308c7e
LibGfx: Minor tweaks in PNG decoder
2020-06-11 16:27:54 +02:00
Andreas Kling
3aca84a299
LibGfx: Use size_t for the Streamer offset and sizes
2020-06-10 18:59:58 +02:00
Andreas Kling
116cf92156
LibGfx: Rename Rect,Point,Size => IntRect,IntPoint,IntSize
...
This fits nicer with FloatRect,FloatPoint,FloatSize and gives a much
better visual clue about what type of metric is being used.
2020-06-10 10:59:04 +02:00
Andreas Kling
8ea4375d4a
LibGfx: Templatize some of the scanline unpacking code
2020-06-02 19:28:55 +02:00
Andreas Kling
19587934f3
LibGfx: Consolidate some types in the PNG decoder
2020-06-02 19:28:55 +02:00
Sergey Bugaev
602c3fdb3a
AK: Rename FileSystemPath -> LexicalPath
...
And move canonicalized_path() to a static method on LexicalPath.
This is to make it clear that FileSystemPath/canonicalized_path() only
perform *lexical* canonicalization.
2020-05-26 14:35:10 +02:00
Peter Nelson
d22bb92764
LibGfx: Add support for animated images to ImageDecoder{Plugin}
...
Adds methods to determine whether an image is animated, how many times
the animation loops, the number of frames, and to get individual frames.
Implements stubs of these methods for PNGImageDecoderPlugin and
GIFImageDecoderPlugin.
2020-05-09 12:01:59 +02:00
LepkoQQ
c7f0de14b5
LibGfx: Decode paletted and grayscale images with 1/2/4 bit depth
...
When dealing with png data that has less than 8 bits per pixel, round
up to the next byte when allocating per row buffers and streamers. This
fixes decoding odd sized PNGs with less than 8 bits per pixel.
Also added a test page with some odd sized palleted PNGs.
2020-05-02 01:28:18 +02:00
Andreas Kling
888e35f0fe
AK: Add ALWAYS_INLINE, NEVER_INLINE and FLATTEN macros
...
It's tedious to write (and look at) [[gnu::always_inline]] etc. :^)
2020-04-30 11:43:25 +02:00
LepkoQQ
e5a598414f
LibGfx: PNGLoader support for grayscale images with alpha.
2020-04-26 20:29:17 +02:00
LepkoQQ
d009df074f
LibGfx: PNGLoader support for grayscale images with 8/16bpp.
2020-04-26 20:29:17 +02:00
Peter Nelson
2cd9716b38
LibGfx: Add a sniff method to ImageDecoder and implement for GIF and PNG
...
The sniff method is intended to be used for content sniffing. It should be a
cheap test to rapidly rule out whether a candidate image can be successfully
decoded. For the GIF and PNG implementations it simply attempts to decode the
image header, returning true if successful and false if not.
2020-04-25 16:49:09 +02:00
Andreas Kling
4393a2a96d
LibGfx: Let the PNG decoder fail if the header is missing or too short
2020-04-19 17:48:43 +02:00
Andreas Kling
ceec1a7d38
AK: Make Vector use size_t for its size and capacity
2020-02-25 14:52:35 +01:00
Andreas Kling
3fe2640c8c
LibGfx: Add forward declaration header
...
This patch adds <LibGfx/Forward.h> with forward declarations for Gfx.
2020-02-14 23:31:18 +01:00
Andreas Kling
3bbf4610d2
AK: Add a forward declaration header
...
You can now #include <AK/Forward.h> to get most of the AK types as
forward declarations.
Header dependency explosion is one of the main contributors to compile
times at the moment, so this is a step towards smaller include graphs.
2020-02-14 23:31:18 +01:00
Andreas Kling
c39d44fc2e
LibGfx: Rename GraphicsBitmap.{cpp,h} => Bitmap.{cpp,h}
2020-02-06 12:07:05 +01:00
Andreas Kling
9ac94d393e
LibGfx: Rename from LibDraw :^)
2020-02-06 12:04:00 +01:00