summaryrefslogtreecommitdiff
path: root/Libraries/LibGfx/GIFLoader.cpp
AgeCommit message (Collapse)Author
2021-01-03LibGUI: Use String::formatted() and String::number() moreAndreas Kling
2020-12-28LibGfx: fix OOB access in LZW decoder on bad inputPeter Nelson
This fixes an issue where a corrupted LZW code can result in the first element of an empty buffer being accessed. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=27863
2020-12-25LibGfx: Make all image decoders reject image sizes above 16384 pixelsAndreas Kling
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-22LibGfx: Fix OOB access in GIF deinterlacingAndreas Kling
It was possible to go outside the interlacing row strid/offset arrays. Just fail the decode if this is about to happen. I've added a FIXME about rejecting such images earlier, since it's a bit sad to only do this once we realize the pass index is about to overflow. Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28239
2020-12-20LibGfx: Teach all image decoders to fail on bitmap allocation failureAndreas Kling
We don't need to wait for oss-fuzz to find this for us. :^)
2020-11-29LibGfx: Don't assert on files ending right before lzw_min_code_sizeNico Weber
Not yet found by oss-fuzz, but I hit it a while ago when running FuzzGIFLoader locally.
2020-11-29LibGfx: skip zero-width framesNico Weber
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=27913 and https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=27873
2020-11-20LibGfx: Make some GIFLoader magic numbers a bit less magicNico Weber
No behavior change.
2020-11-20LibGfx: Put GIFLoader logging behind GIF_DEBUGNico Weber
2020-11-13LibGfx: Add missing stream error handling in GIF frame descriptor parseAndreas Kling
If we try to read a sentinel byte but the stream is fresh out of data, we have to take care of the stream error and bail out right away, or we'll hit an assertion when exiting the function soon after. Fixes #3486.
2020-11-08LibGfx: remove debug printfs from GIFLoaderPeter Nelson
2020-11-08LibGfx: gracefully handle GIFs with frame decode errorsPeter Nelson
GIFLoader now tracks the state of errors during the decoding process and will fall back to displaying the first frame of the GIF if any of the subsequent frames fail to decode.
2020-11-01LibGfx: add bounds checking before set_pixel call in GIF decoderPeter Nelson
This fixes a crash when a GIF frame extends beyond the limits of the logical screen, causing writes past the end of the frame buffer
2020-09-21LibGfx+GIFLoader: Use InputMemoryStream instead of BufferStream.asynts
2020-09-12LibGfx: return clone from frame() instead of underlying framebufferPeter Nelson
This prevents frame() from modifying the contents of the same bitmap that was returned from previous calls to frame()
2020-08-31LibGfx: implement GIF RestorePrevious frame disposal modePeter Nelson
2020-08-31LibGfx: clear previous GIF frame to transparent instead of whole imagePeter Nelson
2020-08-30LibGfx: Fix Lagom build (possible uninitialized variable warnings)Andreas Kling
2020-08-30LibGfx: use Gfx::Color instead of local struct for GIF colour mapPeter Nelson
2020-08-30LibGfx: only cache last decoded GIF framePeter Nelson
GIFLoader now uses a single frame buffer to cache the last decoded frame. This drastically reduces memory usage at the small expense of re-decoding frames on each loop.
2020-08-30LibGfx: add support for interlaced GIFsPeter Nelson
2020-08-30LibGfx: correctly handle GIF frame disposal modesPeter Nelson
RestoreBackground disposal mode is now a transparent fill to allow background to show through. RestorePrevious disposal mode now restores the previous frame.
2020-08-20LibGfx: Support loading GIF local color maps if present :^)Andreas Kling
2020-08-20LibGfx: Initialize some uninitialized things in GIFLoaderAndreas Kling
2020-08-13LibGfx: use disposal method of previous frame in GIF transparencyPeter Nelson
The disposal method on a GIF animation frame now correctly applies to rendering of the next frame.
2020-08-13LibGfx: correctly handle transparency between GIF framesPeter Nelson
This fixes an issue where transparent pixels in GIF animation frames have their alpha values incorrectly set to zero, allowing the background behind the GIF to show through, instead of the previous animation frame. Additionally, transparent pixels are now correctly identified based on their index matching the image transparency index, instead of their color values.
2020-08-12LibGfx: Mark compilation-unit-only functions as staticBen Wiederhake
This enables a nice warning in case a function becomes dead code.
2020-08-12Meta: Replace remaining LibM/math.h includes with math.hLinus Groh
2020-08-06Refactor: Expose const_cast by removing ByteBuffer::warp(const void*, size_t)asynts
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-04Revert "LibM: Always include <math.h> instead of <LibM/math.h>"Andreas Kling
This reverts commit dc12cbca41b8b667ae7ced1066647d47186d1557. Sadly this broke the build due to some confusion about <new>. Reverting until this can be solved fully.
2020-08-04LibM: Always include <math.h> instead of <LibM/math.h>Andreas Kling
This makes Lagom pick up the host math.h, which is what we want.
2020-07-23Lagom: Add LibGemini, LibGfxNico Weber
They are dependencies of LibWeb and might be useful for running test-web on GitHub actions one day.
2020-06-18LibGfx: Fix color alfa for transparent color in GIFLoaderHüseyin ASLITÜRK
2020-06-10LibGfx: Rename Rect,Point,Size => IntRect,IntPoint,IntSizeAndreas Kling
This fits nicer with FloatRect,FloatPoint,FloatSize and gives a much better visual clue about what type of metric is being used.
2020-05-26AK: Rename FileSystemPath -> LexicalPathSergey Bugaev
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-09LibGfx: Implement GIFImageDecoderPlugin animation methodsPeter Nelson
GIFImageDecoderPlugin now lazily decodes GIF frames as they are requested.
2020-05-09LibGfx: Optimise LZWDecoderPeter Nelson
Various optimisations to speed up LZWDecoder - Take advantage of the fact that we add new codes in the order they are discovered so no need to store the code as part of a separate CodeTableEntry structure. Instead we store directly store vectors of colors and the code is the index into the vector. - Cache current table capacity to avoid calling pow2 every time. - Prevent some unnecessary vector copies by returning by reference from get_output.
2020-05-09LibGfx: Add support for animated images to ImageDecoder{Plugin}Peter Nelson
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-04-25LibGfx: Fix crash on decoding small gifsPeter Nelson
The LZW decode step will now copy and pad LZW data out to 4 bytes if there are less than 4 bytes remaining in the buffer. This means it will now also work when the total size of the LZW image data is less than 4 bytes.
2020-04-25LibGfx: Don't proceed with GIF format sniffing if stream read failsAndreas Kling
2020-04-25LibGfx: Remove unnecessary castsPeter Nelson
2020-04-25LibGfx: Minor changes to adhere to code style guidelinesPeter Nelson
2020-04-25LibGfx: Add a sniff method to ImageDecoder and implement for GIF and PNGPeter Nelson
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-25LibGfx: Extract GIF header decoding into separate functionPeter Nelson
2020-04-25LibGfx: implement remaining GIFImageDecoderPlugin methodsPeter Nelson
2020-04-25LibGfx: decode first frame of GIF LZW dataPeter Nelson
Also: - Define the GIFLoadingContext structure. - The load_gif_impl function now returns load operation success, and takes a reference to a GIFLoadingContext as input. - Implement GIFImageDecoderPlugin::bitmap which calls onto load_gif_impl.
2020-04-25LibGfx: Implement GIF LZW decodingPeter Nelson
Add an LZWDecoder class that can decode GIF LZW data.
2020-03-08Userspace: Add missing #includes now that AK/StdLibExtras.h is smallerAndreas Kling
2020-02-25AK: Make Vector use size_t for its size and capacityAndreas Kling
2020-02-25AK, LibGfx, LibGUI: Initialize various variables to zero.Emanuel Sprung
The not initialized variables can lead to compiler warnings that become errors with the -Werror flag.