2faff3cc022734de5fc9fc693d088efe765885f0
[maemo-efl] / trunk / epsilon / debian / patches / 02_epsilon_thumb_canola.diff
1 diff -upNr epsilon/src/lib/Epsilon.c epsilon.new/src/lib/Epsilon.c
2 --- epsilon/src/lib/Epsilon.c   2008-03-06 10:50:30.000000000 -0300
3 +++ epsilon.new/src/lib/Epsilon.c       2008-05-08 13:53:26.000000000 -0300
4 @@ -23,6 +23,9 @@
5  #ifdef HAVE_EPEG_H
6  #include <Epeg.h>
7  #endif
8 +#define THUMB_HEIGHT_CANOLA 96
9 +#define THUMB_WIDTH_CANOLA 192
10 +#define THUMB_SIZE_CANOLA 192
11  #define THUMB_SIZE_NORMAL 128
12  #define THUMB_SIZE_LARGE 256
13  #define THUMB_SIZE_FAIL -1
14 @@ -38,9 +41,11 @@
15  
16  static char *PATH_DIR_LARGE = NULL;
17  static char *PATH_DIR_NORMAL = NULL;
18 +static char *PATH_DIR_CANOLA = NULL;
19  static char *PATH_DIR_FAIL = NULL;
20  static unsigned LEN_DIR_LARGE = 0;
21  static unsigned LEN_DIR_NORMAL = 0;
22 +static unsigned LEN_DIR_CANOLA = 0;
23  static unsigned LEN_DIR_FAIL = 0;
24  
25  
26 @@ -153,6 +158,11 @@ epsilon_init (void)
27       PATH_DIR_NORMAL = strdup(buf);
28       LEN_DIR_NORMAL = strlen(buf);
29    }
30 +  if (!PATH_DIR_CANOLA) {
31 +     strncpy(buf + base_len, "/canola", PATH_MAX - base_len);
32 +     PATH_DIR_CANOLA = strdup(buf);
33 +     LEN_DIR_CANOLA = strlen(buf);
34 +  }
35    if (!PATH_DIR_FAIL) {
36       strncpy(buf + base_len, "/fail/epsilon", PATH_MAX - base_len);
37       PATH_DIR_FAIL = strdup(buf);
38 @@ -161,6 +171,7 @@ epsilon_init (void)
39  
40    ecore_file_mkpath(PATH_DIR_LARGE);
41    ecore_file_mkpath(PATH_DIR_NORMAL);
42 +  ecore_file_mkpath(PATH_DIR_CANOLA);
43    ecore_file_mkpath(PATH_DIR_FAIL);
44  
45    plugins_mime = ecore_hash_new(ecore_str_hash, ecore_str_compare);
46 @@ -446,6 +457,11 @@ _epsilon_file_name(unsigned thumb_size, 
47         dir = PATH_DIR_NORMAL;
48         dir_len = LEN_DIR_NORMAL;
49       }
50 +   else if (thumb_size == THUMB_SIZE_CANOLA)
51 +     {
52 +       dir = PATH_DIR_CANOLA;
53 +       dir_len = LEN_DIR_CANOLA;
54 +     }
55     else
56       {
57         dir = PATH_DIR_FAIL;
58 @@ -575,15 +591,16 @@ epsilon_generate (Epsilon * e)
59        _epsilon_file_name(e->tw, e->hash, "jpg", outfile, sizeof(outfile));
60        epeg_thumbnail_comments_get (im, &info);
61        epeg_size_get (im, &iw, &ih);
62 -      if (iw > ih)
63 +      /* XXX - hack to force fixed height in case of tw != th (canola) */
64 +      if (iw > ih && tw == th)
65         {
66 -         th = e->th * ((double) ih / (double) iw);
67 -          if (th < 1) th = 1;
68 +         th = ((unsigned long) e->tw * ih) / iw;
69 +         if (th < 1) th = 1;
70         }
71        else
72         {
73 -         tw = e->tw * ((double) iw / (double) ih);
74 -          if (tw < 1) tw = 1;
75 +         tw = ((unsigned long) e->th *  iw) / ih;
76 +         if (tw < 1) tw = 1;
77         }
78        epeg_decode_size_set (im, tw, th);
79        epeg_quality_set (im, 100);
80 @@ -695,18 +712,19 @@ epsilon_generate (Epsilon * e)
81  #ifdef HAVE_PNG_H
82      if (tmp)
83        {
84 -       iw = imlib_image_get_width ();
85 -       ih = imlib_image_get_height ();
86 -       if (iw > ih)
87 -         {
88 -           th = e->th * ((double) ih / (double) iw);
89 -          if (th < 1) th = 1;
90 -         }
91 -       else
92 -         {
93 -           tw = e->tw * ((double) iw / (double) ih);
94 -          if (tw < 1) tw = 1;
95 -         }
96 +        iw = imlib_image_get_width ();
97 +        ih = imlib_image_get_height ();
98 +        /* XXX - hack to force fixed height in case of tw != th (canola) */
99 +        if (iw > ih && tw == th)
100 +          {
101 +            th = ((unsigned long) e->tw * ih) / iw;
102 +            if (th < 1) th = 1;
103 +          }
104 +            else
105 +          {
106 +            tw = ((unsigned long) e->th *  iw) / ih;
107 +            if (tw < 1) tw = 1;
108 +          }
109         imlib_context_set_cliprect (0, 0, tw, th);
110         if ((src = imlib_create_cropped_scaled_image (0, 0, iw, ih, tw, th)))
111           {
112 @@ -749,7 +767,11 @@ epsilon_thumb_size(Epsilon *e, Epsilon_T
113         e->tw = THUMB_SIZE_LARGE;
114         e->th = THUMB_SIZE_LARGE;
115         break;
116 -     }   
117 +      case EPSILON_THUMB_CANOLA:
118 +       e->tw = THUMB_WIDTH_CANOLA;
119 +       e->th = THUMB_HEIGHT_CANOLA;
120 +    break;
121 +     }
122  }
123  
124  
125 diff -upNr epsilon/src/lib/Epsilon.h epsilon.new/src/lib/Epsilon.h
126 --- epsilon/src/lib/Epsilon.h   2008-03-06 10:50:30.000000000 -0300
127 +++ epsilon.new/src/lib/Epsilon.h       2008-05-08 13:53:26.000000000 -0300
128 @@ -58,7 +58,8 @@ typedef struct _Epsilon_Info Epsilon_Inf
129  enum _Epsilon_Thumb_Size
130  {
131     EPSILON_THUMB_NORMAL,
132 -   EPSILON_THUMB_LARGE
133 +   EPSILON_THUMB_LARGE,
134 +   EPSILON_THUMB_CANOLA
135  };
136  
137  typedef enum _Epsilon_Thumb_Size Epsilon_Thumb_Size;
138 diff -upNr epsilon/src/lib/epsilon_thumb.c epsilon.new/src/lib/epsilon_thumb.c
139 --- epsilon/src/lib/epsilon_thumb.c     2008-03-06 10:50:30.000000000 -0300
140 +++ epsilon.new/src/lib/epsilon_thumb.c 2008-05-08 13:53:26.000000000 -0300
141 @@ -218,6 +218,9 @@ epsilon_cb_server_data(void *data, int t
142         if (e->server != epsilon_server)
143                 return 1;
144  
145 +       if (!(e && e->data))
146 +               return 1;
147 +
148         msg = e->data;
149         Epsilon_Request *thumb;
150  
151 diff -upNr epsilon/src/lib/exiftags/canon.c epsilon.new/src/lib/exiftags/canon.c
152 --- epsilon/src/lib/exiftags/canon.c    2008-03-06 10:50:30.000000000 -0300
153 +++ epsilon.new/src/lib/exiftags/canon.c        2008-05-08 13:53:26.000000000 -0300
154 @@ -52,7 +52,7 @@
155  struct ccstm {
156         int32_t val;
157         struct descrip *table;
158 -       const char descr[];
159 +       const char *descr;
160  };
161  
162