Commit Graph

1912 Commits

Author SHA1 Message Date
Kim Woelders d52c1a5dae api: Remove pointless statement 2023-02-14 20:01:07 +01:00
Kim Woelders 592bea9208 Loaders, savers: Handle EINTR during fopen()
Fixes potential error when saving to pipe in the presence of signals
(if nothing else).

#5
2023-02-04 11:02:19 +01:00
Kim Woelders 5352caecb3 PNG saver: Avoid potential clobber warning
Also remove some unnecessary png cleanup function calls.
All is done by png_destroy_write_struct(), which was even called twice.
2023-02-04 10:49:37 +01:00
Kim Woelders 2ad8d7d785 JPG saver: Avoid potential clobber warning 2023-02-04 10:49:37 +01:00
Kim Woelders c3d524924e Savers: Centralize file open/close
As done for the loaders a while back.
2023-02-04 10:49:37 +01:00
Kim Woelders a81078e204 Loaders: Debug tweaks 2023-02-04 10:15:14 +01:00
Kim Woelders fb19c620e8 Loaders: decompress_load() is not part of the loader API 2023-02-04 10:15:05 +01:00
Guilherme Janczak 84314f013f
remove bad unused function
__imlib_FileCanRead() suffers from TOCTTOU issues. The file behind the
path it takes as a parameter can change while the function executes, and
also between the function's return and the caller's use of the path.

The function is also unused, so just delete it.
2023-02-04 04:17:57 +00:00
Kim Woelders 829632a735 __imlib_FileDir(): Fix missing closedir() on OOM
Noted by NRK.

And some cosmetics.
2023-01-31 19:32:03 +01:00
Kim Woelders 5c226954c1 ANI, PNG, TGA loaders: Enable handling of unaligned data
Fixes warnings seen with -fsanitize=undefined when using
--enable-packed.
2023-01-29 10:25:08 +01:00
Kim Woelders 9222dad42d autofoo: Add __PACKED__ for optional struct packing 2023-01-29 10:25:08 +01:00
Kim Woelders d27354926a Loaders: Avoid cast-align warnings with -Wcast-align=strict 2023-01-29 10:25:08 +01:00
Kim Woelders 6337c54d30 ANI loader: Use struct to access chunk data 2023-01-28 16:25:15 +01:00
Kim Woelders 495fb5e6f8 Loaders: Debug macro cleanups 2023-01-28 16:25:15 +01:00
Kim Woelders 8c6c40097e x11_rgba: Avoid cast-align warnings with -Wcast-align=strict
Just silencing the warnings, assuming things are properly aligned.
2023-01-28 16:16:17 +01:00
Kim Woelders 09bb1a1c4c x11_grab: Avoid cast-align warnings with -Wcast-align=strict
Just silencing the warnings, assuming things are properly aligned.
2023-01-28 16:16:17 +01:00
Kim Woelders a910b58242 x11_rgba: Add missing const
Also add missing header.
2023-01-28 16:16:17 +01:00
Kim Woelders 00dcf6851f PNM saver: Write images with alpha as P7 PAM RGB_ALPHA type
The previously used P8 type seems to be known only by imlib2.
2023-01-22 17:20:01 +01:00
Kim Woelders 1ca706b79a test: test_save: Check that files are written and ok 2023-01-22 17:20:01 +01:00
Kim Woelders 87bd2fa58a test: test_save: Trivial changes 2023-01-22 17:19:48 +01:00
Kim Woelders 9b9abcdc1e test: Introduce image_get_crc32() 2023-01-22 17:14:52 +01:00
Kim Woelders c8dcabc62a PNM loader: Speedups
Eliminate copy of data to intermediary buffer.
2023-01-22 09:20:07 +01:00
Kim Woelders ac4fb5e21f imlib2_view: Be more verbose about load errors 2023-01-14 10:47:12 +01:00
Kim Woelders 66a5e03de6 imlib2_load: Show error on deferred data load problem 2023-01-14 10:47:12 +01:00
Kim Woelders 930243411e api: Remember error on deferred image data loads
Now it can be fetched with imlib_get_error().
2023-01-14 10:47:12 +01:00
Kim Woelders a856571312 Drop some redundant calls to __imlib_LoadImageData() 2023-01-14 10:47:12 +01:00
Kim Woelders 5d1083858c image: Let __imlib_CreateImage() allocate pixel data buffer
..and check dimensions.

Does simplify things nicely.
2023-01-14 08:59:32 +01:00
Kim Woelders 5d16eb8bb8 api: Tweak/correct error handling in drawable grabbing functions
imlib_create_scaled_image_from_drawable() now returns NULL if the
drawable could not be grabbed, just as imlib_create_image_from_drawable()
has always done.
2023-01-14 08:59:32 +01:00
Kim Woelders dafd7eb33d api: Change some parameter names
- Shorten some names - mostly to avoid some line wrapping
  source_...      -> src_...
  destination_... -> dst_...

- Change some parameter names for consistency/clarity
  Change (x, y, width, height) to (src_x, src_y, src_width, src_height)
  or (dst_x, dst_y, dst_width, dst_height) a couple of places.
2023-01-14 08:59:17 +01:00
Kim Woelders a4e240bc96 api: Fix code duplication around some __imlib_BlendImageToImage() calls 2023-01-13 16:19:02 +01:00
Kim Woelders 207cffb207 Avoid some more undefined behaviors with shifts 2023-01-13 10:55:47 +01:00
NRK e76d9bcf9f PNM loader: avoid some undefined behavior
`ptr` is a `uint8_t` pointer, which will get promoted to an `int` due to
integer promotion. and shifting a signed int by 24 places could cause
signed overflow which is undefined.

> If E1 has a signed type and nonnegative value, and E1 x 2^E2 is
> representable in the result type, then that is the resulting value;
> otherwise, the behavior is undefined.

ref: https://port70.net/~nsz/c/c99/n1256.html#6.5.7p4
2023-01-13 10:55:47 +01:00
Kim Woelders 0f27c5e6ec test: Add some pam tests 2023-01-12 22:14:03 +01:00
q3cpma 27db42330e PNM loader: add read support for PAM 2023-01-12 22:14:03 +01:00
Kim Woelders 8fc05e400e test: Add a few tests for obscure pnm formats 2023-01-12 22:13:54 +01:00
Kim Woelders 4b595dde3a v1.10.0 2022-12-17 18:54:42 +01:00
Kim Woelders 03e4460c17 ANI loader: Multiframe suport 2022-12-14 19:33:09 +01:00
Kim Woelders 7e7eae168a ANI loader: Disable progress in embed loader 2022-12-14 19:33:09 +01:00
Kim Woelders 19028a4ca3 image: Cosmetics (slightly more consisent naming) 2022-12-08 19:03:41 +01:00
Kim Woelders 68a5af8cb2 Add new ani loader 2022-12-08 17:46:09 +01:00
Kim Woelders 108af6d186 image: Introduce __imlib_LoadEmbeddedMem() 2022-12-07 20:03:18 +01:00
Kim Woelders b7d4cab412 image: Cosmetics
- Remove unused function argument in __imlib_ImageFileContextPush()
- Swap function arguments in __imlib_LoadEmbedded()
2022-12-07 20:03:18 +01:00
Kim Woelders 472c823aaf imlib2_view: Don't load bad images twice if first or last in argument list 2022-12-07 18:41:05 +01:00
Kim Woelders bce3ca564d imlib2_view: Properly handle caching vs progress callbacks
When viewing animated images using progress callbacks we could
unintentionally cache a frame, causing incorrect rendering.
2022-12-07 18:40:43 +01:00
Kim Woelders dbeff07758 imlib2_view: Deal with all pending X events at once
Sometimes processing of e.g. key events were deferred do to frame
handling.
2022-11-21 18:56:17 +01:00
Kim Woelders 84948cb698 imlib2_view: Fix multiframe after update coordinate change 2022-11-21 18:49:19 +01:00
Kim Woelders 2d2f8899ec multiframe: Remove frame offset from updates
The frame offsets were recently removed from the loader update callbacks
and added in the infrastructure before calling the user update function.
Now drop the frame offsets so that the update coordinates are relative
to the frame, not the canvas.
Should make things simpler in the end.
2022-11-21 18:49:19 +01:00
Kim Woelders bfcaff3976 imlib2_view: Fix multiframe rendering detail
On dispose, we must re-render saved before saving next.
2022-11-21 18:49:19 +01:00
Kim Woelders a5daa9e33c PNG loader: Simplify update callback handling 2022-11-21 18:49:19 +01:00
Kim Woelders 5a1b88547a PNG loader: Quit after loading first frame
.. in the IDAT data case too.
2022-11-21 18:49:19 +01:00