Commit Graph

1116 Commits

Author SHA1 Message Date
Kim Woelders ffbd8bbca0 SVG loader: Avoid problems when loading the module more than once
It appears that the svg loader fails when dlopen'ed a second time,
presumably due to some issue in librsvg2:

thread '<unnamed>' panicked at 'Type RsvgHandle has already been registered', /builddir/build/BUILD/librsvg-2.52.4/vendor/glib/src/subclass/types.rs:751:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5

A second load of a loader will only happen if an application calls
imlib_flush_loaders(), which I don't see why regular applications would
need to do.
However, calling imlib_flush_loaders() shouldn't cause applications to
potentially fail (abort) anyway.

The failure can be avoided by dlopen'ing with RTLD_NODELETE, but that
would apply to all loaders, which doesn't seem right.
With the solution here the svg.so module is marked to be un-unloadable
which seems to solve the problem and doesn't affect other modules.
2022-01-08 16:08:38 +01:00
Kim Woelders a542fb6724 Add svg loader 2022-01-08 16:08:37 +01:00
Kim Woelders 04b8c35e17 XBM loader: Correct load2() result when no header is found
Also require that the header is found within the first 30 lines in the
file.
Otherwise we may waste some time parsing large C files.
2022-01-07 21:17:50 +01:00
Kim Woelders 564334d708 LZMA loader: Fix potential warning 2022-01-04 09:36:03 +01:00
Sören Tempel 7d60151ba9 ICO loader: Fix compilation on big endian architectures
Commit ff79901a07 refactors the
ico_read_idir function and removed the local nr variable. Unfortunately,
this variable is still used within an `#ifdef WORDS_BIGENDIAN` block on
big endian architectures as a for loop index variable. As such, the code
does presently not compile since the aforementioned commit. This patch
fixes this issue by re-introducing the variable conditionally on big
endian architectures.

Note: It would likely be cleaner to declare the nr variable as part of
the loop declaration, however, this C99 feature does not seem to be used
anywhere in the code base, hence I refrained from using it here.
2022-01-03 17:29:06 +01:00
Kim Woelders 31d6d8532c imlib2_load: Verbosity twaeks 2022-01-02 12:59:24 +01:00
Kim Woelders 8f65acf7c2 imlib2_view: Verbosity twaeks 2022-01-02 12:51:24 +01:00
Kim Woelders 86e3b4fada imlib2_grab: Print error message if saving fails 2021-12-30 06:56:35 +01:00
Kim Woelders 503e8527c3 Add lzma loader 2021-12-28 16:08:06 +01:00
Kim Woelders c880edac55 BZ2, ZLIB loaders: Move duplicated code to separate file
Also change decompressors to use mmap'ed data.
2021-12-28 16:08:06 +01:00
Kim Woelders bf93574b8b Introduce more loader return codes
Used to avoid potentially wasting time trying to load corrupt images
by trying loaders which won't recognize the image anyway.
2021-12-28 16:08:06 +01:00
Kim Woelders f3db9c99b6 imlib2_view: Rework display of animated images 2021-12-28 16:07:19 +01:00
Kim Woelders 350101ff62 GIF loader: Always set BLEND flag
... always?
2021-12-28 16:06:38 +01:00
Kim Woelders 34b54a8fc2 ICO loader: Mostly cosmetic changes (inline ico_read())
Avoids unnecessary memory allocation, simplifies error handling.
2021-12-26 12:22:20 +01:00
Kim Woelders 8bc72491e8 ICO loader: Minor optimization
Or maybe not. A decent compiler would probably do this anyway.
2021-12-26 12:22:20 +01:00
Kim Woelders 71a905d700 imlib2_view: Fix(?) animated image frame dispose handling
Still need to deal with the blend flag.
2021-12-26 11:00:14 +01:00
Kim Woelders 2bbd3dc7f9 Updates for animated image handling 2021-12-26 11:00:14 +01:00
Kim Woelders 31d5eb6dbf autofoo/loader cosmetics
Consistently place loaders in same order.
2021-12-23 17:51:24 +01:00
Kim Woelders 40b6498281 Drop some intermediate type definitions
Not helpful, IMO.
2021-12-21 06:05:32 +01:00
Kim Woelders b28d9110e4 updates: Reduce memory usage
Apparently, sizeof(struct _tile) was 4 (gcc 11.2.1) ?!?
Weird - I think that once upon a time it was 1.
Anyway, avoid having ill defined struct size.

Also, simplify logic a bit (no need to deal with .usage as bit flags.
2021-12-21 06:05:32 +01:00
Kim Woelders f9e0e92189 Loader loading: Avoid access to uninitialized load() item 2021-12-21 06:05:18 +01:00
Kim Woelders f1bef7ae01 debug: Avoid use of uninitialized data 2021-12-21 06:05:18 +01:00
Kim Woelders 82bbd0a278 Indent 2021-12-21 06:05:18 +01:00
Kim Woelders 6ce28a9380 ICO loader: Debug tweaks 2021-12-19 14:58:43 +01:00
Kim Woelders 179d3b7e05 GIF loader: Multiframe support 2021-12-19 14:58:43 +01:00
Kim Woelders bdfcc554ed GIF loader: Some refactoring, add debug 2021-12-19 14:58:43 +01:00
Kim Woelders 7a0022684d ICO loader: Multiframe support 2021-12-19 14:58:43 +01:00
Kim Woelders b2ac97d93a WEBP loader: Multiframe support 2021-12-19 14:58:43 +01:00
Kim Woelders 549ff77b85 debug: Add DL macro for additional loader debug 2021-12-19 14:58:43 +01:00
Kim Woelders f09d3d022a imlib2_view: Add support for multiframe images 2021-12-19 14:58:43 +01:00
Kim Woelders fdd6419fe4 imlib2_load: Add support for multiframe images 2021-12-19 14:58:43 +01:00
Kim Woelders d105b29017 Enable caching for multiframe images 2021-12-19 14:58:43 +01:00
Kim Woelders 1a57db7dcb Add support for multiframe (animated) images 2021-12-19 14:58:43 +01:00
Kim Woelders d792aaa130 imlib2_view: Fix caching option
As imlib2_view did rendering via the (loader) progress callback, cached
images wouldn't be rendered.
Now, when caching is enabled, we don't use progress callbacks but render
explicitly after the image is loaded.
2021-12-19 09:32:53 +01:00
Kim Woelders 343b2041cf debug: Add some image caching debug 2021-12-19 09:32:34 +01:00
Kim Woelders b5e2bd146d imlib2_view: Tweaks around timeout 2021-12-19 09:32:34 +01:00
Kim Woelders d8e2f7a32d imlib2_view: Remove some pointless function calls 2021-12-19 09:32:13 +01:00
Kim Woelders d5c23565bd imlib2_view: Refactor pixmap rendering 2021-12-18 23:05:36 +01:00
Kim Woelders eb7eee0dfc imlib2_view: Move window background image init to separate function 2021-12-18 23:05:36 +01:00
Kim Woelders f2d98a2c15 imlib2_view: Add 'r' command to refresh 2021-12-18 23:05:29 +01:00
Kim Woelders 45575222f5 imlib2_view: Cosmetics (if -> switch) 2021-12-18 23:03:28 +01:00
Kim Woelders 104f330c9f Trivial cleanups 2021-12-18 06:07:08 +01:00
Kim Woelders 52b0752af4 Pass parameters to __imlib_LoadImage() by struct
Makes it much easier to change stuff.
2021-12-18 06:07:08 +01:00
Kim Woelders 8470ecec66 Use __func__ instead of open coded function names
We are already requiring C99, at least since the recent initial context
changes.
2021-12-18 06:07:08 +01:00
Kim Woelders 89def8bab3 Drop context check/init in API functions
Obsolete as we now have an initial static one.
2021-12-10 19:29:46 +01:00
Kim Woelders 8370777a31 Make initial context static
Avoids having to check on every API function call.
2021-12-08 19:12:29 +01:00
Kim Woelders 01d76b56a0 Drop context image save/restore around __imlib_Load/SaveImage() calls
Should not be necessary.
2021-12-06 14:30:30 +01:00
Kim Woelders 1216f11686 Update doc for imlib_load_image_fd() 2021-12-06 07:08:06 +01:00
Kim Woelders 273a7aaac3 Refactor condition for using assembly functions
Makes it easier to override the decision for testing.

Setting IMLIB2_ASM_OFF will now disable use of assembly functions.
2021-12-04 15:14:50 +01:00
Kim Woelders b1208a1333 Refactoring around mmx and scaling function calls
Move call to __imlib_Scale_mmx_AARGBA() into __imlib_ScaleAARGBA() and
__imlib_ScaleAARGB().

Similar to mmx/rotation handling.
2021-12-04 06:55:21 +01:00
Kim Woelders 1411f6ac69 Refactoring around mmx and rotate function calls
Move call to __imlib_mmx_RotateAA() into __imlib_RotateAA().

Avoids some code duplication.
2021-12-04 06:55:21 +01:00
Kim Woelders f935f31bad Simplify build wrt. asm files 2021-12-04 06:55:21 +01:00
Kim Woelders 8f28d7d706 blend.c: Tweaks, cleanups 2021-12-04 06:55:11 +01:00
Kim Woelders 152366c87e Avoid "exceeds maximum object size" warning
..for 32 bit arch too.
2021-12-02 18:10:18 +01:00
Kim Woelders 84343e5a61 Avoid signedness warning 2021-12-02 18:10:18 +01:00
Kim Woelders 5627edbb76 Speedup in imlib_create_scaled_image_from_drawable()
Avoid intermediate pixmap copy when scaling 1:1 with no offset.
2021-11-29 17:37:20 +01:00
Kim Woelders b2d7af466e x11_grab.c: Introduce function to get shape mask
Avoiding some code duplication.
2021-11-29 17:37:20 +01:00
Kim Woelders 314fb50e92 x11_grab.c: Cosmetics 2021-11-29 17:37:20 +01:00
Kim Woelders 5ab0fa77f1 imlib2_view: Enable grabbing/viewing drawables 2021-11-29 17:37:20 +01:00
Kim Woelders 1471e92f62 Only set MAINTAINERCLEANFILES in top-level Makefile.am
Less likely to forget one (currently in test/).
2021-11-29 17:37:20 +01:00
NRK 524d439adf WEBP loader: fix key selecting last frame
as far as i can tell, iter is being used uninitialized here leading to
reading garbage values resulting in the last frame always being selected
when key is present.
2021-11-29 17:37:20 +01:00
Kim Woelders 6e27c1e2c3 Fix y-upscaling in imlib_create_scaled_image_from_drawable() 2021-11-25 15:45:56 +01:00
Kim Woelders add72b4023 x11_grab.c: Rename source/destination variables for clarity 2021-11-25 09:17:50 +01:00
Kim Woelders 86a5a73b5e Refactor imlib_create_scaled_image_from_drawable() - take 2
The X11 stuff should be in x11_grab.c, like the
imlib_create_image_from_drawable() implementation.
2021-11-25 09:17:50 +01:00
Kim Woelders 4019015a47 Revert "Refactor imlib_create_scaled_image_from_drawable()"
This reverts commit eebe5a2747.

Got source/destination mixed up.
2021-11-25 09:16:54 +01:00
Kim Woelders eebe5a2747 Refactor imlib_create_scaled_image_from_drawable()
The X11 stuff should be in x11_grab.c, like the
imlib_create_image_from_drawable() implementation.
2021-11-23 20:33:25 +01:00
Kim Woelders 892af451f2 Trivial changes in __imlib_Grab...() function prototypes 2021-11-23 20:33:25 +01:00
Kim Woelders 63a0279785 Move pixmap stuff to x11_pixmap.c/h 2021-11-23 20:33:25 +01:00
Kim Woelders 21a4172e81 Move ImlibImagePixmap population to __imlib_AddImagePixmapToCache()
For similarity with __imlib_FindCachedImagePixmap().
2021-11-23 20:07:56 +01:00
Kim Woelders 59d6b148f5 Rename X11 related files for clarity
And only build them when BUILD_X11.
2021-11-23 20:07:56 +01:00
Kim Woelders 601cdb4d0d Remove some unneeded headers 2021-11-23 20:07:56 +01:00
Kim Woelders 688ab0edba Drop unnecessary free() NULL argument checks 2021-11-20 17:02:23 +01:00
Kim Woelders d4fa61dc50 WEBP loader: Enable loading animated images (first frame by default) 2021-11-05 17:22:01 +01:00
Kim Woelders d9e2854f23 Loader loading: Don't bother looking up load() if we have load2() 2021-11-05 17:22:01 +01:00
Kim Woelders ac1f75daf0 Loader loading: Avoid always loading all loaders
Introduce "known loaders" list associating the known loader modules
with the usual file name extensions they handle.
If file name extensions match known ones we will only load the required
loader.
2021-11-05 17:22:01 +01:00
Kim Woelders 1cf913701c Loader loading: Minor loader lookup refactoring
Split off __imlib_LookupLoadedLoader() which just does lookup in loaded
loader list.
2021-11-05 17:22:01 +01:00
Kim Woelders a0b32e292b Loader loading: Move __imlib_GetLoaderList()
Paving the way for other changes.
2021-11-05 17:22:01 +01:00
Kim Woelders b45ea50c4b Loader loading: Move to __imlib_FindBestLoaderForFormat() 2021-11-05 17:22:01 +01:00
Kim Woelders 3b2d26deac Loader loading: Tweaks 2021-11-05 17:22:01 +01:00
Kim Woelders 96426fee70 Loader cosmetics 2021-11-05 17:22:01 +01:00
Kim Woelders 59561dcb1b Introduce ARRAY_SIZE() 2021-11-05 17:22:01 +01:00
Kim Woelders 5433232308 Introduce UPDATE_FLAG()
Somewhat simpler.
2021-11-05 17:22:01 +01:00
Kim Woelders 55a27d01f8 imlib2_view: Add option to cache images 2021-11-05 17:22:01 +01:00
Kim Woelders 88231b52eb XPM loader: Use mmap() for loading 2021-10-22 19:27:47 +02:00
Kim Woelders d812457afe XBM loader: Ignore comments and other stuff in header
Add naive signature check to avoid trivial cases where we might
otherwise scan through large non-xbm file.
2021-10-22 19:27:47 +02:00
Kim Woelders 868f2434f1 XBM loader: Use mmap() for loading 2021-10-22 19:27:47 +02:00
Kim Woelders 9caccf41f6 XBM loader: Cosmetics 2021-10-22 19:27:47 +02:00
Kim Woelders 3e1783b846 XBM loader: Fix potential buffer overrun 2021-10-22 19:27:47 +02:00
Kim Woelders 59dc04fe56 PNM loader: Use mmap() for loading 2021-10-22 19:27:47 +02:00
Kim Woelders 164e628951 LBM loader: Use mmap() for loading 2021-10-22 19:27:47 +02:00
Kim Woelders 64bf73d851 LBM loader: Cleanups 2021-10-22 19:27:47 +02:00
Kim Woelders ff79901a07 ICO loader: Use mmap() for loading 2021-10-22 19:27:47 +02:00
Kim Woelders 7c0ec91fe2 ICO loader: Cosmetics 2021-10-22 19:27:47 +02:00
Kim Woelders b99b984bb8 BMP loader: Use mmap() for loading 2021-10-22 19:27:47 +02:00
Kim Woelders 902427c428 BMP loader: Cosmetics 2021-10-22 19:27:47 +02:00
Kim Woelders ffd356a43a ARGB loader: Use mmap() for loading 2021-10-22 19:27:47 +02:00
Kim Woelders 670a4a41f8 ARGB loader: Cosmetics 2021-10-22 19:27:47 +02:00
Kim Woelders a40971035e FF loader: Use mmap() for loading 2021-10-22 19:27:47 +02:00
Kim Woelders c4e4741cc8 FF loader: Cosmetics 2021-10-22 19:27:47 +02:00
Kim Woelders 51999ad031 WEBP loader: Use mmap() for loading 2021-10-22 19:27:47 +02:00
Kim Woelders 546bb20f52 WEBP loader: Cosmetics
Some variable renaming for consistency.
2021-10-22 19:27:47 +02:00
Kim Woelders b7b72ce0b5 TGA loader: Use im->fsize, cosmetics, debug 2021-10-22 19:27:47 +02:00
Kim Woelders 66c941c267 TIFF loader: Use mmap() during signature check 2021-10-22 19:27:47 +02:00
Kim Woelders 07deb8c893 PNG loader: Use mmap() during signature check 2021-10-22 19:27:47 +02:00
Kim Woelders df050d2dbc PNG loader: Cosmetics 2021-10-22 19:27:47 +02:00
Kim Woelders ae01ddf0b2 Introduce im->fsize 2021-10-22 19:27:47 +02:00
Kim Woelders 9996028e7d debug: Add some debug related to file access and image loading 2021-10-22 19:26:58 +02:00
Kim Woelders e47e32a247 debug: Infrastructure
Add some debug infrastructure.
Disabled by default, enable with --enable-debug.
When enabled, the environment variable IMLIB2_DEBUG controls the amount
of debug output.
2021-10-22 19:24:15 +02:00
Kim Woelders 5a2490eb7f imlib2_load: Use clock_gettime() when available 2021-10-22 15:41:44 +02:00
Kim Woelders e3a2bd5fa6 imlib2_view: If verbose show error message on failure 2021-10-19 09:19:37 +02:00
Kim Woelders 4e15a7974c Fix build (Imlib2.h is now built) 2021-10-08 19:43:14 +02:00
Kim Woelders 675d0084f8 imlib2_load: Add verbose option 2021-10-04 05:19:47 +02:00
Kim Woelders 1f7ef0225e Imlib.h: Add version macros 2021-09-26 17:38:09 +02:00
Kim Woelders ab52c354fe autofoo: Drop support for libungif
Obsolete for 15+ years.
2021-09-26 17:38:09 +02:00
Kim Woelders b200f57e92 JPEG loader: Parse EXIF data and handle orientation 2021-09-25 13:02:06 +02:00
Kim Woelders c5e0e786f9 JPEG loader: Cosmetics
Mostly trivial name changes to facilitate debugging.
2021-09-25 13:02:06 +02:00
Kim Woelders 46fca7c9a7 imlib2_load: Add option to use imlib_load_image_immediately() 2021-09-25 13:02:06 +02:00
Kim Woelders 5512f0a2e3 image.c: Use the LOAD_... macros to check loader return values 2021-09-16 10:54:09 +02:00
Kim Woelders adda6d7b9c GIF, TIFF, WEBP loaders: Fix loading if filename does not have usual suffix - take 2
Better solution from from Daniel Friesel <derf@finalrewind.org> / Lars
Stoltenow.
2021-09-15 19:43:48 +02:00
Kim Woelders b71221ce76 Revert "GIF, TIFF, WEBP loaders: Fix loading if filename does not have usual suffix"
This reverts commit 43f82f3bc8.
2021-09-15 19:43:48 +02:00
Kim Woelders 43f82f3bc8 GIF, TIFF, WEBP loaders: Fix loading if filename does not have usual suffix
Patch from Daniel Friesel <derf@finalrewind.org>:

---
Fix .gif loader if filename does not end in .gif

Imlib2 is currently unable to load gif images if the filename does not end in
.gif. This appears to be caused by imlib2 not resetting the file descriptor
back to 0 after trying to open the image with its different loaders.

While imlib2 does call rewind(FILE* im->fp) before invoking each loader, this
does not guarantee that the underlying FD is seeked as well. However, the GIF
loader uses the FD directly, and therefore tries to read from the middle of the
file (unless it is the first loader). This patch adds an explicit seek in the
same fashion as implemented in the TIFF loader.

Patch and debugging credits go to Lars Stoltenow.
---

Also fix same issue in TIFF and WEBP loaders.
2021-09-14 07:43:55 +02:00
Kim Woelders b78a66195f LBM loader: Fix potential out-of-bounds memory access 2021-09-14 07:42:34 +02:00
Kim Woelders dbeb622c7a WEBP loader: Rename fd variable to be same as everywhere else 2021-09-14 07:42:34 +02:00
Kim Woelders c018a7687c WEBP loader: Remove forgotten debug printout 2021-09-14 07:42:34 +02:00
Kim Woelders 3a4d6d4590 imlib2_view: Fix issue with new default scaling
Need to distinguish between scaling option value and applied scaling
when viewing multiple images.
2021-08-21 12:01:43 +02:00
Kim Woelders ecc7a342ff imlib2_view: Add some debug 2021-08-21 10:05:57 +02:00
Kim Woelders a748550fa4 imlib2_view: By default scale large images to fit on screen 2021-08-21 10:05:57 +02:00
Kim Woelders 34afe297cd imlib2_view: Cleanups 2021-08-21 10:05:57 +02:00
Kim Woelders 0497d2bb0c imlib2_view: Move property stuff to separate file
May reuse it elsewhere.
2021-08-21 10:05:57 +02:00
Kim Woelders 1a439ed4df WEBP saver: Use fopen() etc. like all other savers 2021-07-16 23:08:10 +02:00
Kim Woelders e709825314 Loaders: Remove unnecessary headers 2021-07-16 19:40:03 +02:00
Kim Woelders 3c21caea23 Correct (disabled) debug printouts 2021-07-13 09:07:27 +02:00
Kim Woelders 49af0f9d59 Add feature to build with ASAN (--enable-gcc-asan) 2021-07-13 08:55:33 +02:00
Kim Woelders 651c56bb29 Drop unused Imlib_Object_List:last 2021-07-13 08:20:11 +02:00
Kim Woelders c31a5b98a2 Cleanups: while->for loops (pixmaps list) 2021-07-10 15:44:17 +02:00
Kim Woelders 6cfa4a4505 Cleanups: while->for loops (images list) 2021-07-10 15:44:17 +02:00
Kim Woelders 7a460e6a6e Cleanups: while->for loops (im->tags list) 2021-07-10 15:44:17 +02:00
Kim Woelders 4f3da0de03 Cleanups: while->for loops (context list) 2021-07-10 15:44:17 +02:00
Kim Woelders 3c645829b4 Cleanups: while->for loops (loaders list) 2021-07-10 15:44:17 +02:00
Kim Woelders 407533ebdc TGA loader: Fix loading small images without footer
Patch by noospot <noospot@mail.de>.
2021-07-10 15:40:37 +02:00
Kim Woelders 933fc2ab1f TIFF loader: Drop use of libtiff defined types deprecated in libtiff-4.3.0
Switch to using C99 types, uint8 -> uint8_t, etc. now used by libtiff.
2021-04-30 10:04:05 +02:00
Kim Woelders c1ee164d6d autofoo: Move more to pkg-config
Facilitates testing alternative library versions.
2021-04-30 10:03:49 +02:00
Kim Woelders 27ab891c56 Fix clang-analyzer warnings - lib (less trivial) 2021-04-16 17:15:06 +02:00
Kim Woelders e82a5997ec Fix clang-analyzer warnings - lib (mostly trivial) 2021-04-16 17:15:06 +02:00
Kim Woelders 6f4dc94cc4 Fix clang-analyzer warnings - loaders (suppress bogus) 2021-04-16 17:15:06 +02:00
Kim Woelders cd1a42dd07 Fix clang-analyzer warnings - loaders (trivial) 2021-04-16 17:15:06 +02:00
Kim Woelders 652d30e8fe Fix clang-analyzer warnings - bin (trivial) 2021-04-16 17:15:06 +02:00
Kim Woelders 4fa2ad8566 LBM loader: Fix handling of missing RLE data
The missing bytes were cleared at the start of the line, not the end.
2021-04-16 17:15:06 +02:00
Kim Woelders 90c5f5a26a context.c: Fix potential segv
Also call __imlib_FlushContexts() before adding new context, not after
- It's pointless to check the new context
- Avoids (bogus) clang-analyzer warning
2021-04-13 06:56:32 +02:00
Kim Woelders bdbea7b384 Remove unused Context functions 2021-04-13 06:56:32 +02:00
Kim Woelders 1f6438a1c7 ICO loader: Enable specifying ico image index by key 2021-04-13 06:56:32 +02:00
Kim Woelders 7eb6c6388b ICO loader: Fix (disabled) debug stuff 2021-04-13 06:56:32 +02:00
Kim Woelders 11cc9ffa51 Restore file:key functionality
Broken by 07e1601cd5 (in v1.7.0).
2021-04-12 20:39:36 +02:00
Kim Woelders b215368196 Add XBM loader 2020-12-18 07:18:29 +01:00
Kim Woelders 418d19e066 rend.c: Remove some pointless lines 2020-12-13 06:45:11 +01:00
Kim Woelders f4c04168b4 Remove some unnecessary X_DISPLAY_MISSING stuff 2020-12-13 06:45:11 +01:00
Kim Woelders 381e65f567 Silence a couple of sign-compare warnings 2020-12-09 17:44:16 +01:00
Kim Woelders ae3d501f93 XPM loader: Get transparency right when doing header-only loading
We have to parse the colormap too to figure that out.
2020-12-08 20:07:48 +01:00
Kim Woelders 64df90de3d WEBP loader: Add initial signature check
Avoid potentially wasting much time when loading/checking large
non-webp files.
2020-12-06 18:09:42 +01:00
Kim Woelders e3be3eb0fc grab.c: Support 30bpp display in __imlib_GrabXImageToRGBA()
Patch by the_third.

https://phab.enlightenment.org/T8808
2020-12-06 14:16:45 +01:00
Kim Woelders 9219b2c6a3 rend.c: Fix __imlib_generic_render() when jump != 0
Patch by the_third.

https://phab.enlightenment.org/T8799
2020-12-06 14:14:09 +01:00
Daniel Kolesa 92d3153fee Fix big endian build 2020-08-09 21:00:46 +02:00
Kim Woelders 9e8978c6be Remove a couple of unused includes 2020-07-28 21:35:39 +02:00
Kim Woelders ea5da196cb Fix build without X11 2020-07-28 19:57:11 +02:00
Kim Woelders 06aa6d1bfc imlib2_load: Optionally use imlib_load_image_fd() 2020-04-14 17:47:00 +02:00
Alexander Volkov 204d994d8c Don't rescan loaders
Summary:
Loaders from a newer version of imlib2 may be incompatible with an
older version of imlib2. Thus already running applications may
stop loading images after system upgrade, which can be extremely
unpleasant for the user.

Reviewers: kwo

Reviewed By: kwo

Differential Revision: https://phab.enlightenment.org/D11678
2020-04-14 17:34:41 +02:00
Alexander Volkov 5db012a35e Introduce imlib_load_image_from_fd()
Summary:
It can be used to load files in a process, which has no access to the file,
by passing the file descriptor to it. For example, in a sandboxed process.
Also anonymous files created with O_TMPFILE or by memfd_create() can be loaded.

Reviewers: kwo

Differential Revision: https://phab.enlightenment.org/D10262
2020-03-04 17:15:23 +01:00
Kim Woelders 07e1601cd5 Reduce number of stat() calls during load
Also skip empty files entirely.
2020-03-01 06:28:28 +01:00
Kim Woelders 6c2fe14b82 Move loaders to load2() 2020-02-29 18:04:34 +01:00
Kim Woelders b9166551ac Add infrastructure for new loader entry - load2() 2020-02-29 18:04:34 +01:00
Kim Woelders 57a26386ba JPG, PNG loaders: Avoid clobber warnings - Take N+1 2020-02-29 11:25:18 +01:00
Kim Woelders c608354760 Revert "JPG, PNG loaders: Avoid clobber warnings"
This caused a segv in the jpg loader if trying to load a non-jpg image
(gcc 9.2.1 with -O2, not with -O).

This reverts commit f588650bb6.
2020-02-29 06:55:15 +01:00
Kim Woelders c913f97285 __imlib_FileExtension: Use basename if there are no dots 2020-02-27 21:20:36 +01:00
Kim Woelders ac41eae7fa GZ, BZ2 loaders: Accept more file names
E.g. ".png.gz", "png.gz", ".../png.gz".
2020-02-27 21:20:36 +01:00
Alexander Volkov 97865ad8ef GIF loader: Don't close file descriptor twice
Summary:
DGifOpenFileHandle() closes it on failure and DGifCloseFile()
closes it when working normally.

Reviewers: kwo

Differential Revision: https://phab.enlightenment.org/D11425
2020-02-26 19:06:34 +01:00
Kim Woelders 4d191f6492 ID3 loader: Some mostly cosmetic rearrangements 2020-02-23 13:26:00 +01:00
Kim Woelders 4ec88a0dda TIFF loader: Minor speedup 2020-02-23 13:26:00 +01:00
Kim Woelders b059049034 Add a couple of consts 2020-02-23 13:26:00 +01:00
Kim Woelders f588650bb6 JPG, PNG loaders: Avoid clobber warnings 2020-02-17 18:18:13 +01:00
Kim Woelders 8d9f33d365 Fix enum conversion warnings (gcc10) 2020-02-01 19:30:03 +01:00
Tobias Stoeckmann d5400cc047 ICO loader: Handle malloc failures
If not enough memory is available and a program is run on a system
which returns NULL in such cases, then treat this error gracefully.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2020-01-20 21:49:57 +01:00
Tobias Stoeckmann c95f938ff1 ICO loader: Do not crash on invalid files
If an ICO file contains icons with an excessively large amount of colors
in its color map, an integer overflow can lead to 0 byte allocations of
the color map.

If such an icon is displayed later on, the color map access leads to
out of boundary reads.

Also verify that excessively large icons are not parsed at all to prevent
out of boundary reads of raw pixel data during display.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2020-01-20 06:21:15 +01:00
Kim Woelders 9eaed188d2 Make ImlibLoader struct opaque
Loaders should no longer directly access it.
2020-01-11 12:56:08 +01:00
Kim Woelders 875bc82b49 Introduce __imlib_LoaderSetFormats() 2020-01-11 12:55:08 +01:00
Kim Woelders c02dc3c975 Introduce __imlib_LoadEmbedded() 2020-01-11 12:55:08 +01:00
Kim Woelders 10e21579fa Savers: Simplify progress handling 2020-01-04 15:30:20 +01:00
Kim Woelders 0f5b4fb10a Loaders: Simplify/fix progress handling
Progress handling was broken in at least bmp, gif, lbm, and png loaders.
2020-01-04 15:30:20 +01:00
Kim Woelders 87c84278ec image.c: Add infrastructure to simplify progress handling 2020-01-04 15:30:20 +01:00
Kim Woelders 9f479126f9 image.c: Remove redundant pixmap unref
Already done in __imlib_ConsumeImage().
2020-01-04 15:30:20 +01:00
Kim Woelders 495527a74e Fix loader cleanup breakage (gif) 2019-12-29 16:54:26 +01:00
Kim Woelders f4ab8e10b1 imlib2_view: Various tweaks
- Only process latest key press
- Clear to background before drawing new image
- Skip redraw of current image
2019-12-29 16:54:26 +01:00
Kim Woelders 83e7e89348 image.c: Move data_memory_func assignment to better place 2019-12-28 12:06:22 +01:00
Kim Woelders 002df3c1fa image.c: Minor refactoring of pixmap cache cleaners 2019-12-28 12:06:22 +01:00
Kim Woelders a7be91805f image.c: Enable non-dirty pixmap cache cleaning
For whatever reason this does not seem to have ever been active.
Let's activate it now.
2019-12-28 12:06:22 +01:00
Kim Woelders 6acfd27058 image.c: Move loader functions to separate file 2019-12-28 12:06:22 +01:00
Kim Woelders 02e85ee069 image.c: Move image tag functions to separate file 2019-12-28 12:06:22 +01:00
Kim Woelders 0c7464f0db image.c/h: Cleanups
- Make a number of functions static
- Shuffle prototypes around for nicer grouping
- Remove unused __imlib_SetImageAlphaFlag()
- Remove __imlib_FlushCache() prototype (not implemented)
2019-12-28 12:06:22 +01:00
Kim Woelders 6a7eb67f46 Saver cleanups
- Do exit cleanups at exit.
- Use LOAD_FAIL/SUCCESS/BREAK for save() exit code.
- Cosmetics.
2019-12-23 12:55:46 +01:00
Kim Woelders bd3aa88242 Loader cleanups
- Do exit cleanups at exit.
- Merge data load conditions.
- Use LOAD_FAIL/SUCCESS/BREAK for load() exit code.
- Cosmetics.
2019-12-23 12:07:48 +01:00
Kim Woelders 540a98870b image.c: Use loader return value, not im->w to determine load success 2019-12-23 10:53:26 +01:00
Kim Woelders 670c8428a4 image.c: Introduce __imlib_ErrorFromErrno() 2019-12-23 10:53:26 +01:00
Kim Woelders c60ad00b1e image.c: Use real_file to get file time 2019-12-23 10:53:26 +01:00
Kim Woelders 0f4c0d9453 image.c: Don't strdup() real_name when not necessary in __imlib_LoadImage() 2019-12-23 10:53:26 +01:00
Kim Woelders 2c35a349ea image.c: Rework some obscure file name stuff in __imlib_SaveImage() 2019-12-23 10:53:26 +01:00
Kim Woelders c1b2686441 image.c: Remove some unnecessary clearing of calloc'ed structs 2019-12-23 10:53:26 +01:00
Kim Woelders 0c69bb64cc image.c: Add some space for readability 2019-12-23 10:53:26 +01:00
Kim Woelders cdf64148b0 Drop the __imlib_IsRealFile() file check in __imlib_File...() functions
There should be no reason to do this everywhere.
Only keep the one used when doing an image load.
2019-12-23 06:37:00 +01:00
Kim Woelders fa670dcbd7 Refactor many __imlib_File...() functions to use common __imlib_FileStat()
And drop unused __imlib_FilePermissions()
2019-12-23 06:37:00 +01:00
Kim Woelders 57b4b12c7e Simplify __imlib_FileExtension()
__imlib_FileExtension() has (presumably by mistake) never used the
"real" file name to determine the extension so let's just drop all the
strdup'ing and return a pointer into the file string.
2019-12-23 06:37:00 +01:00
Kim Woelders 7b3b5f7f0c imlib2_load: Add repeated load option 2019-12-23 06:37:00 +01:00
Kim Woelders 55da63d700 imlib2_load: Use getopt() 2019-12-23 06:37:00 +01:00
Kim Woelders c396b32739 imlib2_load: Properly check non-full loads (load data too) 2019-12-23 06:37:00 +01:00
Kim Woelders 8e376b549f XPM loader: Major speedup for cpp > 2 2019-12-23 06:37:00 +01:00
Luiz Carlos Ramos 641dd66349 BMP loader: Fix size calculation when saving files
The sizes stored both in BMP file and bitmap headers were not considering the
padding of each row, leading to smaller values when the width was not multiple
of 4.

Fixed by including the padding in the formula.
2019-12-08 14:39:09 +01:00
Kim Woelders 48ff9e10c1 LBM loader: Fix header-only loading 2019-12-03 20:03:21 +01:00
Kim Woelders 503bce9c64 XPM loader: Minor optimization for cpp > 2 2019-12-03 17:26:24 +01:00
Kim Woelders 269e0b8572 BMP loader: Remove some bogus conditions
And tweak (disabled) debug stuff.
2019-12-03 17:26:24 +01:00
Kim Woelders 3bd4e8032c Enable specifying loader/filter paths with environment variables
Useful for testing.
2019-12-03 17:26:24 +01:00
Kim Woelders fdbf1c49e3 imlib2_view: Add progress debug options 2019-12-03 17:26:24 +01:00
Kim Woelders f9c10c19e3 imlib2_load: Optionally write to stderr instead of stdout
Sometimes useful when testing with valgrind.
2019-12-03 17:26:24 +01:00
Kim Woelders 8584b3f88a Rename imlib2_test_load to imlib2_load
imlib2_test_load was a bit long..
2019-12-03 17:26:24 +01:00
Kim Woelders 2d9511d59d Quit on 'q' or 'esc' key press in all imlib2_... test utilities
The ...free... stuff at quit seems to be needed to silence valgrind when
exiting by return from main and not by exit().
2019-12-03 17:26:24 +01:00
Kim Woelders 8bd07dbcea gz, bz2 loaders: Fix recent breakage when file name has more than two dots 2019-11-26 06:20:46 +01:00
Kim Woelders 1a0c29c873 gz loader: Use FILE, not fd
Making it more similar to the bz2 loader.
2019-11-26 06:18:48 +01:00
Kim Woelders f20038b2e7 gz, bz2 loaders: Simplify, eliminate unnecessary strdups, cosmetics
In particular, don't free the original im->real_file.
2019-11-23 07:01:37 +01:00
Kim Woelders 9b0ab12697 XPM loader: Correct signature check (avoid accessing unset data) 2019-11-22 19:08:39 +01:00
Kim Woelders 947b602cca ICO loader: Fix memory leak in error path 2019-11-17 14:52:09 +01:00
Kim Woelders baaddf9366 imlib2_view: Fix next/prev selection if last/first image is bad 2019-11-17 06:13:14 +01:00
Kim Woelders 1a6a6b6433 Remove __imlib_AllocateData() w,h args
im->w and im->h must always be set before __imlib_AllocateData() is
called due to non-immediate loading (__imlib_AllocateData() only
comes in play when the pixel data must be loaded).
2019-11-16 21:18:12 +01:00
Kim Woelders 2339dcb1cf ICO loader: Fix non-immediate loading 2019-11-16 21:09:19 +01:00
Kim Woelders 9bae2c9f02 TGA loader: Tweak error handling 2019-11-16 21:09:16 +01:00
Kim Woelders a2cb8276e5 TGA loader: Add simple 16 bpp handling
Probably not entirely correct (N alpha bits?).
2019-11-16 12:18:33 +01:00
Kim Woelders 0d0a701a96 TGA loader: Support horiontal flip 2019-11-16 12:18:33 +01:00
Kim Woelders 9cdd1bc007 TGA loader: More mostly cosmetic changes 2019-11-16 12:18:33 +01:00
Kim Woelders f01353d155 TGA loader - Mostly cosmetic refactoring 2019-11-16 12:18:33 +01:00
Kim Woelders 83243f08fa imlib2_view: Add verbose option, quit on Escape too 2019-11-16 12:17:27 +01:00
Kim Woelders d6c13ec444 imlib2_test_load: Check progress conditionally 2019-11-16 12:17:27 +01:00
Kim Woelders 6eb958fb1b imlib2_test_load: Fixup recent breakage for real 2019-11-15 17:11:12 +01:00
Olof-Joachim Frahm (欧雅福) fb0cce4caf tga loader: implement handling of palette
Summary:
implemented 8 bit color mapped images with 24/32bpp palette.

This is coming from an issue on [[ https://github.com/derf/feh/issues/491 | feh ]] to support indexed TGA images. Written by [[ https://github.com/rofl0r | rofl0r ]], I'm forwarding it because I already have the tools for submission set up.

N.b. I'm not terribly familiar with the particular code style, if there's anything to format differently I'm happy to update.

Test Plan:
- Compared [[ https://0x0.st/zgB4.tga | example file ]] with known good in GIMP, looks okay.
- Tested that said example file doesn't load without this patch (in feh, which uses Imlib2).

Reviewers: kwo

Differential Revision: https://phab.enlightenment.org/D10618
2019-11-15 17:03:05 +01:00
Kim Woelders bb42ef3f22 imlib2_view: Fix event processing bug 2019-11-10 15:11:56 +01:00
Kim Woelders 3748dd580f imlib2_view: Enable selecting next/prev using keys too 2019-11-10 15:11:56 +01:00
Kim Woelders 5d1e984e57 Simplify loader lookup functions 2019-11-10 15:11:56 +01:00
Kim Woelders 7a2769cad7 XPM loader: Accept signature not at the very start of the file 2019-11-10 15:11:56 +01:00
Kim Woelders 484bd5cc79 Eliminate READ_RGBA() 2019-11-09 12:07:15 +01:00
Kim Woelders 3e082b2310 Use macro for pixel color access in savers 2019-11-09 12:07:15 +01:00
Kim Woelders 755dc017f2 Use pixel instead of r,b,g,a in __imlib_render_str() 2019-11-09 12:07:04 +01:00
Kim Woelders e6269a9b9b Simplify pixel color handling in api.c 2019-11-09 11:32:17 +01:00
Kim Woelders 581e6baed8 Eliminate WRITE_RGBA()
Potentially causing way more memory access than needed.
2019-11-08 19:29:26 +01:00
Kim Woelders 7c426928e9 TGA loader: Refactor
Primarily make a single exit point.
2019-11-08 19:20:14 +01:00
Kim Woelders 2f228adbe1 Re-indent everything using indent-2.2.12 2019-11-08 18:57:36 +01:00