Commit Graph

31 Commits

Author SHA1 Message Date
Kim Woelders 15ab46d03e savers: Fix error returns
The savers did not return meaningful error codes in many cases.
2024-01-04 05:05:04 +01:00
Kim Woelders 30107247b6 Change formatting style
No tabs, more like K&R.
Also switch to indent 2.2.13.
2024-01-02 09:47:51 +01: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 c3d524924e Savers: Centralize file open/close
As done for the loaders a while back.
2023-02-04 10:49:37 +01:00
Kim Woelders 753065d5a3 loading: Centralize mmap handling
Loader interface should be stable now.
2022-07-10 12:51:06 +02:00
Kim Woelders e55208f4d6 loading: Introduce __imlib_ImageFileContextPush/Pop()
Makes dealing with nested file contexts much easier.
2022-07-10 12:50:40 +02:00
Kim Woelders 5b357a815b loading: New loader infrastructure
Old loaders will no longer work.
Should be no big deal to migrate though.
2022-07-10 12:50:40 +02:00
Kim Woelders b39d33c800 image: Change has alpha flag to separate byte
It is the only flag that should be used by the loaders
2022-07-10 12:50:40 +02:00
Kim Woelders f44e52c62d Introduce Imlib2_Loader.h - all that is needed by loaders
Note! This changes breaks loader ABI due to reordering of elements in
ImlibImage.
Loader interface will be unstable until further notice.
2022-07-10 12:50:09 +02:00
Kim Woelders 3aeceb6a7b Loaders: Remove unnecessary calls to __imlib_FreeData()
__imlib_LoadImageWrapper() does it when required so no need for
doing it in every loader.
2022-03-31 21:49:56 +02:00
Kim Woelders 18d0befc57 Use stdint types instead of DATA32 etc.
This should make things slightly more consistent and unambiguous, and
the stdint types are already used here and there (in loaders).

I'm not aware of any systems where this change makes any difference.
If there are targets out there with 64 bit ints imlib2 might now work
there and on targets with 16 bit ints it most likely still doesn't.
2022-03-26 15:54:40 +01:00
Kim Woelders 3459740001 Loader includes tweaks 2022-03-06 18:42:28 +01:00
Kim Woelders fb4fb24e44 Refactor image flags stuff
For improved grepability.
2022-02-26 09:09:25 +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 59561dcb1b Introduce ARRAY_SIZE() 2021-11-05 17:22:01 +01: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 6c2fe14b82 Move loaders to load2() 2020-02-29 18:04:34 +01:00
Kim Woelders 875bc82b49 Introduce __imlib_LoaderSetFormats() 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 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 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
Alexander Volkov 03665627db Allow to use custom memory management functions for loaded images
Summary:
... and add imlib_create_image_using_data_and_memory_function().

For example, it allows to load an image in one process and then
pass it through shared memory to another process without extra
memory copy.

Reviewers: kwo

Differential Revision: https://phab.enlightenment.org/D10222
2019-09-30 19:11:32 +02:00
Kim Woelders 09d9a95054 Remove pointless im->data checks in loaders
im->data should always be NULL when entering the load() function.

We can therefore also remove free(im->data) calls before the buffer
is allocated.
2019-09-29 18:39:56 +02:00
Kim Woelders 8fcdc4965d Centralize handling of im->format
Instead of assigning it (in different ways) in each loader, do it
centrally in __imlib_LoadImageWrapper().

And a couple of cleanups in code related to im->format.
2018-07-17 19:31:04 +02:00
Kim Woelders 868a40579a Cleanups in load() functions
When entering load we can assume that im != NULL and im->data == NULL.
2018-07-17 19:31:04 +02:00
Tobias Stoeckmann d5ebec2948 Properly release resources on error path
The code did not properly release resources in some error paths,
leading to memory leaks or possible double free issues.

If an image could not be loaded, some code paths check if width is 0
to determine if an error occurred. Therefore, always set width to 0
in such cases.
2017-03-12 09:52:02 +01:00
Kim Woelders 93e6176764 Indent. 2016-02-07 08:08:00 +01:00
FRIGN 5cabf38155 Add a Farbfeld loader
(http://tools.suckless.org/farbfeld)
2016-02-07 08:01:40 +01:00