kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=7a84d3472f92b934dabbc048b4498d38ff9ebcc3

commit 7a84d3472f92b934dabbc048b4498d38ff9ebcc3
Author: Kim Woelders <k...@woelders.dk>
Date:   Fri Mar 18 18:56:14 2022 +0100

    Refactor some image loading functions
---
 src/lib/Imlib2.h.in | 30 +++++++++++++++---------------
 src/lib/api.c       | 43 +++++++++++++++++++++++++------------------
 2 files changed, 40 insertions(+), 33 deletions(-)

diff --git a/src/lib/Imlib2.h.in b/src/lib/Imlib2.h.in
index b61175f..b359832 100644
--- a/src/lib/Imlib2.h.in
+++ b/src/lib/Imlib2.h.in
@@ -796,37 +796,37 @@ EAPI Imlib_Image    
imlib_load_image_immediately_without_cache(const char
                                                                *file);
 
 /**
- * Read an image from file descriptor
+ * Load an image from file with error return
  *
- * The file name @p file is only used to guess the file format.
- * The image is loaded without deferred image data decoding and without
- * looking in the cache.
+ * The image is loaded without deferred image data decoding.
  *
- * @p fd must be mmap'able (so it cannot be a pipe).
- * @p fd will be closed after calling this function.
+ * On error @p error_return is set to the detail of the error.
  *
- * @param fd            Image file descriptor
  * @param file          File name
+ * @param error_return  The returned error
  *
  * @return Image handle (NULL on failure)
  */
-EAPI Imlib_Image    imlib_load_image_fd(int fd, const char *file);
+EAPI Imlib_Image    imlib_load_image_with_error_return(const char *file,
+                                                       Imlib_Load_Error *
+                                                       error_return);
 
 /**
- * Load an image from file with error return
+ * Read an image from file descriptor
  *
- * The image is loaded without deferred image data decoding.
+ * The file name @p file is only used to guess the file format.
+ * The image is loaded without deferred image data decoding and without
+ * looking in the cache.
  *
- * On error @p error_return is set to the detail of the error.
+ * @p fd must be mmap'able (so it cannot be a pipe).
+ * @p fd will be closed after calling this function.
  *
+ * @param fd            Image file descriptor
  * @param file          File name
- * @param error_return  The returned error
  *
  * @return Image handle (NULL on failure)
  */
-EAPI Imlib_Image    imlib_load_image_with_error_return(const char *file,
-                                                       Imlib_Load_Error *
-                                                       error_return);
+EAPI Imlib_Image    imlib_load_image_fd(int fd, const char *file);
 
 /**
  * Free the current image
diff --git a/src/lib/api.c b/src/lib/api.c
index b3ee72d..9af359d 100644
--- a/src/lib/api.c
+++ b/src/lib/api.c
@@ -739,8 +739,8 @@ imlib_load_image(const char *file)
    return im;
 }
 
-EAPI                Imlib_Image
-imlib_load_image_immediately(const char *file)
+static              Imlib_Image
+_imlib_load_image_immediately(const char *file, int *err)
 {
    Imlib_Image         im;
    ImlibLoadArgs       ila = { ILA0(ctx, 1, 0) };
@@ -748,10 +748,19 @@ imlib_load_image_immediately(const char *file)
    CHECK_PARAM_POINTER_RETURN("file", file, NULL);
 
    im = __imlib_LoadImage(file, &ila);
+   *err = ila.err;
 
    return im;
 }
 
+EAPI                Imlib_Image
+imlib_load_image_immediately(const char *file)
+{
+   int                 err;
+
+   return _imlib_load_image_immediately(file, &err);
+}
+
 EAPI                Imlib_Image
 imlib_load_image_without_cache(const char *file)
 {
@@ -778,6 +787,20 @@ imlib_load_image_immediately_without_cache(const char 
*file)
    return im;
 }
 
+EAPI                Imlib_Image
+imlib_load_image_with_error_return(const char *file,
+                                   Imlib_Load_Error * error_return)
+{
+   Imlib_Image         im;
+   int                 err = 0;
+
+   im = _imlib_load_image_immediately(file, &err);
+   if (error_return)
+      *error_return = (Imlib_Load_Error) err;
+
+   return im;
+}
+
 EAPI                Imlib_Image
 imlib_load_image_fd(int fd, const char *file)
 {
@@ -801,22 +824,6 @@ imlib_load_image_fd(int fd, const char *file)
    return im;
 }
 
-EAPI                Imlib_Image
-imlib_load_image_with_error_return(const char *file,
-                                   Imlib_Load_Error * error_return)
-{
-   Imlib_Image         im;
-   ImlibLoadArgs       ila = { ILA0(ctx, 1, 0) };
-
-   CHECK_PARAM_POINTER_RETURN("file", file, NULL);
-
-   im = __imlib_LoadImage(file, &ila);
-   if (error_return)
-      *error_return = (Imlib_Load_Error) ila.err;
-
-   return im;
-}
-
 EAPI                Imlib_Image
 imlib_load_image_frame(const char *file, int frame)
 {

-- 


Reply via email to