kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16.git/commit/?id=9d678fc55431ea9d47c502837e8d5c64fd397b65

commit 9d678fc55431ea9d47c502837e8d5c64fd397b65
Author: Kim Woelders <k...@woelders.dk>
Date:   Sat Feb 27 18:43:11 2021 +0100

    Fix handling of imageclasses with flipped/rotated images
    
    Each modified image needs its own file to avoid getting in trouble with
    pixmap caching.
    
    The trouble in question was only seen if misc.memory_paranoia was set
    to 0 (is 1 by default).
---
 src/eimage.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
 src/eimage.h |  3 ++-
 src/iclass.c |  9 +++++----
 3 files changed, 50 insertions(+), 6 deletions(-)

diff --git a/src/eimage.c b/src/eimage.c
index e8300722..ad4f00c2 100644
--- a/src/eimage.c
+++ b/src/eimage.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004-2020 Kim Woelders
+ * Copyright (C) 2004-2021 Kim Woelders
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to
@@ -30,6 +30,7 @@
 
 #include "E.h"
 #include "eimage.h"
+#include "file.h"
 #include "xwin.h"
 
 #define IMG_CACHE_DEFAULT_SIZE          (2 * 1024 * 1024)
@@ -127,6 +128,47 @@ EImageLoad(const char *file)
    return imlib_load_image(file);
 }
 
+EImage             *
+EImageLoadOrientate(const char *file, int orientation)
+{
+   EImage             *im, *im2;
+   char                name[2048], path[4096], *s, *s2;
+
+   snprintf(name, sizeof(name), "%s", file);
+   for (s = name, s2 = NULL; *s; s++)
+     {
+       if (*s == '/')
+          *s = '.';
+       else if (*s == '.')
+          s2 = s;
+     }
+   if (s2)
+      *s2 = '\0';
+   snprintf(path, sizeof(path), "%s/cached/cfg/%s-%d.png",
+           EDirUserCache(), name, orientation);
+
+   if (!exists(path))
+     {
+       im = imlib_load_image(file);
+       if (!im)
+          return NULL;
+
+       imlib_context_set_image(im);
+       im2 = imlib_clone_image();
+       imlib_free_image();
+
+       imlib_context_set_image(im2);
+       imlib_image_orientate(orientation);
+       imlib_image_set_format("png");
+       imlib_save_image(path);
+       imlib_free_image();
+     }
+
+   im = imlib_load_image(path);
+
+   return im;
+}
+
 void
 EImageSave(EImage * im, const char *file)
 {
diff --git a/src/eimage.h b/src/eimage.h
index 32e1381b..53d59dd3 100644
--- a/src/eimage.h
+++ b/src/eimage.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004-2020 Kim Woelders
+ * Copyright (C) 2004-2021 Kim Woelders
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to
@@ -65,6 +65,7 @@ void                EImageDecache(EImage * im);
 
 void                EImageSave(EImage * im, const char *file);
 EImage             *EImageLoad(const char *file);
+EImage             *EImageLoadOrientate(const char *file, int orient);
 
 void                EImageCheckAlpha(EImage * im);
 
diff --git a/src/iclass.c b/src/iclass.c
index 822c7c89..5abd1e63 100644
--- a/src/iclass.c
+++ b/src/iclass.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various 
contributors
- * Copyright (C) 2004-2020 Kim Woelders
+ * Copyright (C) 2004-2021 Kim Woelders
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to
@@ -210,9 +210,10 @@ ImagestateRealize(ImageState * is)
      }
    if (is->real_file)
      {
-       is->im = EImageLoad(is->real_file);
-       if (is->im && is->rotate)
-          EImageOrientate(is->im, is->rotate);
+       if (is->rotate && !Conf.memory_paranoia)
+          is->im = EImageLoadOrientate(is->real_file, is->rotate);
+       else
+          is->im = EImageLoad(is->real_file);
      }
    if (!is->im)
      {

-- 


Reply via email to