summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx/TGALoader.cpp
AgeCommit message (Collapse)Author
2023-03-21LibGfx: Move all image loaders and writers to a subdirectoryLucas CHOLLET
2023-02-19LibGfx: Fix sign-compare compile error in TGALoaderLinus Groh
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-01-27LibGfx: Add a method to ImageDecoderPlugin for reading ICC dataNico Weber
This probably won't be the final API for getting color spaces from images, since some formats just store an "is sRGB?" flag instead of a full profile. Instead, once everything works, we probably want to give every Bitmap a pointer to some color space abstraction. But we can always change this later, once things are further along and better understood.
2023-01-26LibGfx: Remove `try_` prefix from bitmap creation functionsTim Schumacher
Those don't have any non-try counterpart, so we might as well just omit it.
2023-01-20LibGfx: Fix TGA decoder being out of boundary after calling frame methodLiav A
This happened because the reader was incrementing the byte index of it after each read of a byte from the Span, so by the end of the frame method, we could be at the end of the mapped file, so the next call on the same decoder will just resume from that point and will be quickly out of boundary. To ensure this doesn't happen we only set the bitmap to m_context member at the end of the method, and call to that method again will just give the already-generated bitmap. In case of setting the bitmap as volatile, we test for that case and re-generate a reader to read the frame again correctly.
2023-01-20LibGfx: Re-structure the whole initialization pattern for image decodersLiav A
When trying to figure out the correct implementation, we now have a very strong distinction on plugins that are well suited for sniffing, and plugins that need a MIME type to be chosen. Instead of having multiple calls to non-static virtual sniff methods for each Image decoding plugin, we have 2 static methods for each implementation: 1. The sniff method, which in contrast to the old method, gets a ReadonlyBytes parameter and ensures we can figure out the result with zero heap allocations for most implementations. 2. The create method, which just creates a new instance so we don't expose the constructor to everyone anymore. In addition to that, we have a new virtual method called initialize, which has a per-implementation initialization pattern to actually ensure each implementation can construct a decoder object, and then have a correct context being applied to it for the actual decoding.
2023-01-15LibGfx: Prevent reading OOB in TGA header decodeJelle Raaijmakers
2023-01-15LibGfx: Add support for RLE compressed TGA imagesLiav A
RLE is an old technique being used for decades, as is known as Run-Length-Encoding, which means that for repeating sequence of bytes, we keep an indicator for the length of the sequence and only one sample of it, to save storage space. GIMP can generate lossless-compressed TGA images, with RLE compression being used. It means that for a compressed image, the data is no longer arranged in sequence of pixels, but a sequence of pixel packets. There are two possible pixel packets: - RLE packets, which are encoded with one byte for indicating the run-length and another one pixel (3 bytes for TrueColor pixel), so essentially in runtime, the TGA decoder will use the length to plot the same pixel in multiple pixels of the output pixel bitmap. - Raw packets, which are encoded with one byte as indicator for the length of the whole pixel sequence and N-length pixel sequence afterwards. This is not used for any sort of compression by the TGA format, but still needed to be supported for full compatibility with TGA images that uses the RLE compression.
2023-01-15LibGfx: Handle tga images with top-left and bottom-left orientationLiav A
GIMP allows a user to export a TGA image with either of these possible orientations, so we can easily support it by looking at the X origin and Y origin values to determine where to put the pixels in the bitmap.
2023-01-15LibGfx: Add TGA Loader :^)Tom Needham
This patch adds a basic TGA Loader. Currently it can only handle uncompressed files with a bit depth of 24 or 32 bits per pixel.