summaryrefslogtreecommitdiff
path: root/src/bin/ephoto_color.c
diff options
context:
space:
mode:
authorStephen 'Okra' Houston <smhouston88@gmail.com>2017-08-30 09:01:07 -0500
committerStephen 'Okra' Houston <smhouston88@gmail.com>2017-08-30 09:01:07 -0500
commita705f9a62690e3135295faeeb3f13eba2ac1eb3f (patch)
treea53e31c4abe21daf25d56561ed99f7339321d117 /src/bin/ephoto_color.c
parentab43168f907cc3da747fab8297edec2b9a6515d6 (diff)
Ephoto: Ecrustify Formatting
Diffstat (limited to 'src/bin/ephoto_color.c')
-rw-r--r--src/bin/ephoto_color.c130
1 files changed, 67 insertions, 63 deletions
diff --git a/src/bin/ephoto_color.c b/src/bin/ephoto_color.c
index 15d0465..36a0f20 100644
--- a/src/bin/ephoto_color.c
+++ b/src/bin/ephoto_color.c
@@ -3,18 +3,18 @@
3typedef struct _Ephoto_Color Ephoto_Color; 3typedef struct _Ephoto_Color Ephoto_Color;
4struct _Ephoto_Color 4struct _Ephoto_Color
5{ 5{
6 Evas_Object *main; 6 Evas_Object *main;
7 Evas_Object *parent; 7 Evas_Object *parent;
8 Evas_Object *image; 8 Evas_Object *image;
9 Evas_Object *editor; 9 Evas_Object *editor;
10 Evas_Object *bslider; 10 Evas_Object *bslider;
11 Evas_Object *gslider; 11 Evas_Object *gslider;
12 Evas_Object *rslider; 12 Evas_Object *rslider;
13 Eina_List *handlers; 13 Eina_List *handlers;
14 int blue; 14 int blue;
15 int green; 15 int green;
16 int red; 16 int red;
17 Evas_Coord w, h; 17 Evas_Coord w, h;
18 unsigned int *original_im_data; 18 unsigned int *original_im_data;
19}; 19};
20 20
@@ -35,10 +35,10 @@ _ephoto_apply_color_adjustment(Ephoto_Color *eco, unsigned int *image_data, int
35 35
36 im_data = malloc(sizeof(unsigned int) * eco->w * eco->h); 36 im_data = malloc(sizeof(unsigned int) * eco->w * eco->h);
37 if (image_data) 37 if (image_data)
38 memcpy(im_data, image_data, sizeof(unsigned int) * eco->w * eco->h); 38 memcpy(im_data, image_data, sizeof(unsigned int) * eco->w * eco->h);
39 else 39 else
40 memcpy(im_data, eco->original_im_data, 40 memcpy(im_data, eco->original_im_data,
41 sizeof(unsigned int) * eco->w * eco->h); 41 sizeof(unsigned int) * eco->w * eco->h);
42 42
43 im_data_new = malloc(sizeof(unsigned int) * eco->w * eco->h); 43 im_data_new = malloc(sizeof(unsigned int) * eco->w * eco->h);
44 44
@@ -48,32 +48,35 @@ _ephoto_apply_color_adjustment(Ephoto_Color *eco, unsigned int *image_data, int
48 p2 = im_data_new + (y * eco->w); 48 p2 = im_data_new + (y * eco->w);
49 for (x = 0; x < eco->w; x++) 49 for (x = 0; x < eco->w; x++)
50 { 50 {
51 b = (int) ((*p1) & 0xff); 51 b = (int)((*p1) & 0xff);
52 g = (int) ((*p1 >> 8) & 0xff); 52 g = (int)((*p1 >> 8) & 0xff);
53 r = (int) ((*p1 >> 16) & 0xff); 53 r = (int)((*p1 >> 16) & 0xff);
54 a = (int) ((*p1 >> 24) & 0xff); 54 a = (int)((*p1 >> 24) & 0xff);
55 b = ephoto_mul_color_alpha(b, a); 55 b = ephoto_mul_color_alpha(b, a);
56 g = ephoto_mul_color_alpha(g, a); 56 g = ephoto_mul_color_alpha(g, a);
57 r = ephoto_mul_color_alpha(r, a); 57 r = ephoto_mul_color_alpha(r, a);
58 switch (color) 58 switch (color)
59 { 59 {
60 case EPHOTO_COLOR_ADJUST_RED: 60 case EPHOTO_COLOR_ADJUST_RED:
61 eco->red = adjust; 61 eco->red = adjust;
62 cc = (int) r + eco->red; 62 cc = (int)r + eco->red;
63 r = cc; 63 r = cc;
64 break; 64 break;
65 case EPHOTO_COLOR_ADJUST_BLUE: 65
66 eco->blue = adjust; 66 case EPHOTO_COLOR_ADJUST_BLUE:
67 cc = (int) b + eco->blue; 67 eco->blue = adjust;
68 b = cc; 68 cc = (int)b + eco->blue;
69 break; 69 b = cc;
70 case EPHOTO_COLOR_ADJUST_GREEN: 70 break;
71 eco->green = adjust; 71
72 cc = (int) g + eco->green; 72 case EPHOTO_COLOR_ADJUST_GREEN:
73 g = cc; 73 eco->green = adjust;
74 break; 74 cc = (int)g + eco->green;
75 default: 75 g = cc;
76 break; 76 break;
77
78 default:
79 break;
77 } 80 }
78 b = ephoto_normalize_color(b); 81 b = ephoto_normalize_color(b);
79 g = ephoto_normalize_color(g); 82 g = ephoto_normalize_color(g);
@@ -87,7 +90,7 @@ _ephoto_apply_color_adjustment(Ephoto_Color *eco, unsigned int *image_data, int
87 } 90 }
88 } 91 }
89 ephoto_single_browser_image_data_update(eco->main, eco->image, 92 ephoto_single_browser_image_data_update(eco->main, eco->image,
90 im_data_new, eco->w, eco->h); 93 im_data_new, eco->w, eco->h);
91 free(im_data); 94 free(im_data);
92 return im_data_new; 95 return im_data_new;
93} 96}
@@ -107,7 +110,7 @@ _red_slider_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
107 110
108static void 111static void
109_green_slider_changed(void *data, Evas_Object *obj, 112_green_slider_changed(void *data, Evas_Object *obj,
110 void *event_info EINA_UNUSED) 113 void *event_info EINA_UNUSED)
111{ 114{
112 Ephoto_Color *eco = data; 115 Ephoto_Color *eco = data;
113 int green; 116 int green;
@@ -121,7 +124,7 @@ _green_slider_changed(void *data, Evas_Object *obj,
121 124
122static void 125static void
123_blue_slider_changed(void *data, Evas_Object *obj, 126_blue_slider_changed(void *data, Evas_Object *obj,
124 void *event_info EINA_UNUSED) 127 void *event_info EINA_UNUSED)
125{ 128{
126 Ephoto_Color *eco = data; 129 Ephoto_Color *eco = data;
127 int blue; 130 int blue;
@@ -135,7 +138,7 @@ _blue_slider_changed(void *data, Evas_Object *obj,
135 138
136static Eina_Bool 139static Eina_Bool
137_color_reset(void *data, int type EINA_UNUSED, 140_color_reset(void *data, int type EINA_UNUSED,
138 void *event_info EINA_UNUSED) 141 void *event_info EINA_UNUSED)
139{ 142{
140 Ephoto_Color *eco = data; 143 Ephoto_Color *eco = data;
141 144
@@ -152,7 +155,7 @@ _color_reset(void *data, int type EINA_UNUSED,
152 155
153static Eina_Bool 156static Eina_Bool
154_color_apply(void *data, int type EINA_UNUSED, 157_color_apply(void *data, int type EINA_UNUSED,
155 void *event_info EINA_UNUSED) 158 void *event_info EINA_UNUSED)
156{ 159{
157 Ephoto_Color *eco = data; 160 Ephoto_Color *eco = data;
158 unsigned int *image_data; 161 unsigned int *image_data;
@@ -167,7 +170,7 @@ _color_apply(void *data, int type EINA_UNUSED,
167 else 170 else
168 { 171 {
169 image_data = 172 image_data =
170 evas_object_image_data_get(eco->image, EINA_FALSE); 173 evas_object_image_data_get(eco->image, EINA_FALSE);
171 evas_object_image_size_get(eco->image, &w, &h); 174 evas_object_image_size_get(eco->image, &w, &h);
172 ephoto_single_browser_image_data_done(eco->main, image_data, w, h); 175 ephoto_single_browser_image_data_done(eco->main, image_data, w, h);
173 } 176 }
@@ -178,7 +181,7 @@ _color_apply(void *data, int type EINA_UNUSED,
178 181
179static Eina_Bool 182static Eina_Bool
180_color_cancel(void *data, int type EINA_UNUSED, 183_color_cancel(void *data, int type EINA_UNUSED,
181 void *event_info EINA_UNUSED) 184 void *event_info EINA_UNUSED)
182{ 185{
183 Ephoto_Color *eco = data; 186 Ephoto_Color *eco = data;
184 187
@@ -197,7 +200,7 @@ _color_cancel(void *data, int type EINA_UNUSED,
197 200
198static void 201static void
199_editor_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, 202_editor_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
200 void *event_info EINA_UNUSED) 203 void *event_info EINA_UNUSED)
201{ 204{
202 Ephoto_Color *eco = data; 205 Ephoto_Color *eco = data;
203 Ecore_Event_Handler *handler; 206 Ecore_Event_Handler *handler;
@@ -227,18 +230,18 @@ ephoto_color_add(Ephoto *ephoto, Evas_Object *main, Evas_Object *parent, Evas_Ob
227 eco->parent = parent; 230 eco->parent = parent;
228 eco->image = image; 231 eco->image = image;
229 im_data = 232 im_data =
230 evas_object_image_data_get(eco->image, 233 evas_object_image_data_get(eco->image,
231 EINA_FALSE); 234 EINA_FALSE);
232 evas_object_image_size_get(eco->image, &eco->w, 235 evas_object_image_size_get(eco->image, &eco->w,
233 &eco->h); 236 &eco->h);
234 eco->original_im_data = malloc(sizeof(unsigned int) * eco->w * eco->h); 237 eco->original_im_data = malloc(sizeof(unsigned int) * eco->w * eco->h);
235 memcpy(eco->original_im_data, im_data, 238 memcpy(eco->original_im_data, im_data,
236 sizeof(unsigned int) * eco->w * eco->h); 239 sizeof(unsigned int) * eco->w * eco->h);
237 240
238 eco->editor = ephoto_editor_add(ephoto, parent, _("Adjust Color Levels"), 241 eco->editor = ephoto_editor_add(ephoto, parent, _("Adjust Color Levels"),
239 "eco", eco); 242 "eco", eco);
240 evas_object_event_callback_add(eco->editor, EVAS_CALLBACK_DEL, _editor_del, 243 evas_object_event_callback_add(eco->editor, EVAS_CALLBACK_DEL, _editor_del,
241 eco); 244 eco);
242 245
243 slider = elm_slider_add(eco->editor); 246 slider = elm_slider_add(eco->editor);
244 elm_object_text_set(slider, _("Blue")); 247 elm_object_text_set(slider, _("Blue"));
@@ -250,7 +253,7 @@ ephoto_color_add(Ephoto *ephoto, Evas_Object *main, Evas_Object *parent, Evas_Ob
250 EPHOTO_WEIGHT(slider, EVAS_HINT_EXPAND, EVAS_HINT_FILL); 253 EPHOTO_WEIGHT(slider, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
251 EPHOTO_ALIGN(slider, EVAS_HINT_FILL, 0.5); 254 EPHOTO_ALIGN(slider, EVAS_HINT_FILL, 0.5);
252 evas_object_smart_callback_add(slider, "delay,changed", 255 evas_object_smart_callback_add(slider, "delay,changed",
253 _blue_slider_changed, eco); 256 _blue_slider_changed, eco);
254 elm_box_pack_start(eco->editor, slider); 257 elm_box_pack_start(eco->editor, slider);
255 evas_object_show(slider); 258 evas_object_show(slider);
256 eco->bslider = slider; 259 eco->bslider = slider;
@@ -265,7 +268,7 @@ ephoto_color_add(Ephoto *ephoto, Evas_Object *main, Evas_Object *parent, Evas_Ob
265 EPHOTO_WEIGHT(slider, EVAS_HINT_EXPAND, EVAS_HINT_FILL); 268 EPHOTO_WEIGHT(slider, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
266 EPHOTO_ALIGN(slider, EVAS_HINT_FILL, 0.5); 269 EPHOTO_ALIGN(slider, EVAS_HINT_FILL, 0.5);
267 evas_object_smart_callback_add(slider, "delay,changed", 270 evas_object_smart_callback_add(slider, "delay,changed",
268 _green_slider_changed, eco); 271 _green_slider_changed, eco);
269 elm_box_pack_start(eco->editor, slider); 272 elm_box_pack_start(eco->editor, slider);
270 evas_object_show(slider); 273 evas_object_show(slider);
271 eco->gslider = slider; 274 eco->gslider = slider;
@@ -280,26 +283,27 @@ ephoto_color_add(Ephoto *ephoto, Evas_Object *main, Evas_Object *parent, Evas_Ob
280 EPHOTO_WEIGHT(slider, EVAS_HINT_EXPAND, EVAS_HINT_FILL); 283 EPHOTO_WEIGHT(slider, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
281 EPHOTO_ALIGN(slider, EVAS_HINT_FILL, 0.5); 284 EPHOTO_ALIGN(slider, EVAS_HINT_FILL, 0.5);
282 evas_object_smart_callback_add(slider, "delay,changed", 285 evas_object_smart_callback_add(slider, "delay,changed",
283 _red_slider_changed, eco); 286 _red_slider_changed, eco);
284 elm_box_pack_start(eco->editor, slider); 287 elm_box_pack_start(eco->editor, slider);
285 evas_object_show(slider); 288 evas_object_show(slider);
286 eco->rslider = slider; 289 eco->rslider = slider;
287 290
288 eco->handlers = 291 eco->handlers =
289 eina_list_append(eco->handlers, 292 eina_list_append(eco->handlers,
290 ecore_event_handler_add(EPHOTO_EVENT_EDITOR_RESET, 293 ecore_event_handler_add(EPHOTO_EVENT_EDITOR_RESET,
291 _color_reset, eco)); 294 _color_reset, eco));
292 eco->handlers = 295 eco->handlers =
293 eina_list_append(eco->handlers, 296 eina_list_append(eco->handlers,
294 ecore_event_handler_add(EPHOTO_EVENT_EDITOR_APPLY, 297 ecore_event_handler_add(EPHOTO_EVENT_EDITOR_APPLY,
295 _color_apply, eco)); 298 _color_apply, eco));
296 eco->handlers = 299 eco->handlers =
297 eina_list_append(eco->handlers, 300 eina_list_append(eco->handlers,
298 ecore_event_handler_add(EPHOTO_EVENT_EDITOR_CANCEL, 301 ecore_event_handler_add(EPHOTO_EVENT_EDITOR_CANCEL,
299 _color_cancel, eco)); 302 _color_cancel, eco));
300 303
301 return; 304 return;
302 305
303 error: 306error:
304 return; 307 return;
305} 308}
309