Commit Graph

1154 Commits

Author SHA1 Message Date
NRK 4f928f53a7 WEBP saver: allow lossless and respect compression tag
this treats quality == 100 as lossless similar to some other savers.

in case of lossless encoding, compression is derived from "quality" if
compression_tag was not set. in case of lossy encoding, the default is
used when compression_tag isn't set.

additionally, this fixes a bug in the older saver where fwrite might
have been called with a null fdata (which is UB) in case of an error.
2023-05-12 16:21:35 +02:00
Kim Woelders 8a36ae6d8d loaders: Use common function to print error messages
Also:
- gif  loader: Add error about corrupt frame sequence
- tiff loader: Drop OOM message - Not done elsewhere
- webp loader: Drop messages about quality tag outside [0-100] -
               Not done elsewhere
2023-05-08 18:52:57 +02:00
Kim Woelders 11cef49cef Introduce __imlib_perror() to produce error messages 2023-05-08 18:52:57 +02:00
Kim Woelders c44f3a4124 GIF loader: Enable showing animated images even if truncated 2023-05-06 20:59:03 +02:00
Kim Woelders d1d95fb2b1 imlib2_view: Avoid potential use of uninitialized data 2023-05-06 20:59:03 +02:00
Kim Woelders 41c792bd7e loaders: Cosmetics
- Add missing const
- Consistently use imdata for pointer into imlib image data
- Minor changes
2023-05-01 11:19:24 +02:00
Kim Woelders a55f36133d Add JXL saver
old/legacy-imlib2#9
2023-04-30 20:02:15 +02:00
Kim Woelders 9468f7132c loaders: Change method used to not unload loaders
It appears that in certain environments (homebrew on MacOS) the linker
does not like the -z nodelete option, so handle this differently.

old/legacy-imlib2#8
2023-04-04 20:53:49 +02:00
Kim Woelders 7c18c9aca1 loaders: Fix loaders potentially being loaded more than once
A new loader instance was created every time it was attempted to save
an image with a loader that doesn't have a save() function.
2023-04-04 20:53:33 +02:00
Kim Woelders adba3ecd0c XPM loader: Add rgb.txt
No longer rely on it being provided by X11.

rgb.txt is copied from https://gitlab.freedesktop.org/xorg/app/rgb
2023-03-23 06:24:31 +01:00
Kim Woelders eb513bc0d0 autofoo: Tweak PACKAGE_DATA_DIR definition 2023-03-23 06:24:31 +01:00
Kim Woelders 6a1bcc2ab7 modules: Drop some disabled code 2023-03-23 06:24:31 +01:00
Kim Woelders 32901e3bab Y4M loader: Various minor changes
- configure.ac: Alphabetic order
- Makefile.am: Alphabetic order, no need for nodelete
- loaders.c: Add to known loaders
- loader_y4m.c: Remove some unneeded headers
2023-03-21 06:48:53 +01:00
Chema Gonzalez be721b0335 imlib2: added loader for y4m files (uses liby4m and libyuv)
Implemented just `_load()` for now.

Summary:

Implements a loader for y4m images. Uses liby4m and libyuv.
Only implements the `_load()` function as of now

Tested:

```
$ ./configure
...
Configuration Options Summary:

Image loaders:
 Regular image loaders
  GIF.....................: yes
  HEIF....................: yes
  Y4M.....................: yes
...

$ make -j
...

$ sudo make install
...

$ feh image.y4m
-- image shows up
```

Tested with yuv420p, yuv422p, and yuv444p images.
2023-03-21 06:48:53 +01:00
Kim Woelders 531a053d11 HEIF loader: Add some debug 2023-03-21 06:48:53 +01:00
Kim Woelders eae5c3bdbf x11_grab: Eliminate some overhead in scaled grabbing
Avoid call to XGetWindowAttributes(), X-error, call to XGetGeometry().
2023-03-06 06:59:04 +01:00
Kim Woelders 8af7975804 x11_grab: Various fixes in __imlib_GrabDrawableScaledToRGBA()
- Fix clipping to source.
- Fix error when mask from shape is requested but drawable is pixmap.
- Use queried drawable depth, not the context one.
  This eliminates the last usage of the context depth in the grabbing
  functions.
2023-03-06 06:59:04 +01:00
Kim Woelders 3b21892c77 x11_grab: Clear image pixels not actually grabbed
When using imlib_create[_scaled]_image_from_drawable() with non-zero
source offsets the output image could contain pixels either not set or
copied from uninitialised parts of intermediary pixmap.
2023-03-06 06:58:48 +01:00
Kim Woelders e41499a528 x11_grab: Rework clipping
Source clipping in imlib_copy_drawable_to_image() was broken and is
already dealt with in __imlib_GrabDrawableToRGBA().
Destination clipping has now been added.
2023-03-06 06:57:32 +01:00
Kim Woelders de79c704eb x11_grab: Move window/pixmap checking to separate function 2023-03-06 06:57:32 +01:00
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
imlib_create_scaled_image_from_drawable().
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()
old/legacy-imlib2#7
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).

old/legacy-imlib2#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 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