Commit Graph

1134 Commits

Author SHA1 Message Date
Kim Woelders 3ab9498777 x11: Pass X11 context around by struct
A bit nicer, I think.
2023-03-06 06:53:06 +01:00
Kim Woelders c47e18d571 imlib2_view: Add option to set background checkerboard field size 2023-03-01 11:03:15 +01:00
Kim Woelders 8d3539234d x11_grab: Drop now unused 1:1 scaling path in __imlib_GrabDrawableScaledToRGBA() 2023-02-19 22:36:46 +01:00
Kim Woelders 5ea6a407cf imlib_create_scaled_image_from_drawable(): Simplify call path
On 1:1 scaling call  __imlib_GrabDrawableToRGBA() directly instead of
going through __imlib_GrabDrawableScaledToRGBA().

This fixes 1:1 grabbing of pixmaps.
Non-1:1 pixmaps grabs are still not ok (window grabs are).
2023-02-19 22:35:58 +01:00
Kim Woelders 61097080e5 x11_grab: Eliminate unnecessary pixmap copy
Speeds up 1:1 scaling with non-zero source offset in
2023-02-19 17:53:11 +01:00
Kim Woelders f54961f0cd x11_grab: Let __imlib_Grab..() return error instead of ok 2023-02-19 17:17:22 +01:00
Kim Woelders 702432f5ed api: Oops - debug-- 2023-02-15 21:14:15 +01:00
Kim Woelders ce0ac1eeff Add imlib_save_image_fd()
2023-02-15 18:31:19 +01:00
Kim Woelders 1ba40142f7 api: Minor simplification in error handling in save functions 2023-02-15 18:23:34 +01:00
Kim Woelders 81a1d1d929 api: Cosmetics around image save functions
Consistently use "file" for the file name in save functions as well as
in load functions.
2023-02-15 18:22:39 +01:00
Kim Woelders 3840c6636c api: Update documentation for imlib_get_error() 2023-02-15 18:22:39 +01:00
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).

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
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 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.

2023-01-13 10:55:47 +01:00
q3cpma 27db42330e PNM loader: add read support for PAM 2023-01-12 22:14:03 +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
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