Ephoto: Add emboss filter

master
Stephen okra Houston 6 years ago
parent 66bb556e56
commit 293a821031
  1. 1
      src/bin/ephoto.h
  2. 70
      src/bin/ephoto_filters.c
  3. 17
      src/bin/ephoto_single_browser.c

@ -151,6 +151,7 @@ void ephoto_filter_posterize(Evas_Object *main, Evas_Object *image);
void ephoto_filter_sketch(Evas_Object *main, Evas_Object *image);
void ephoto_filter_invert(Evas_Object *main, Evas_Object *image);
void ephoto_filter_edge(Evas_Object *main, Evas_Object *image);
void ephoto_filter_emboss(Evas_Object *main, Evas_Object *image);
void ephoto_filter_histogram_eq(Evas_Object *main, Evas_Object *image);
/*file functions*/

@ -7,6 +7,7 @@ enum _Ephoto_Image_Filter
{
EPHOTO_IMAGE_FILTER_BLUR,
EPHOTO_IMAGE_FILTER_DITHER,
EPHOTO_IMAGE_FILTER_EMBOSS,
EPHOTO_IMAGE_FILTER_EQUALIZE,
EPHOTO_IMAGE_FILTER_GRAYSCALE,
EPHOTO_IMAGE_FILTER_INVERT,
@ -1043,6 +1044,66 @@ _sobel(void *data)
return EINA_FALSE;
}
static Eina_Bool
_emboss(void *data)
{
Ephoto_Filter *ef = data;
Evas_Coord x, y, w, h;
int i, j, passes = 0;
unsigned int *p;
float emboss[3][3] = {{1, 1, 1},
{1, -2, 1},
{-1, -1, -1}};
w = ef->w;
h = ef->h;
for (y = ef->pos; y < h; y++)
{
p = ef->im_data_new + (y * w);
for (x = 0; x < w; x++)
{
int a, r, g , b;
int aa = 0, rr = 0, gg = 0, bb = 0;
if (y > 0 && x > 0 && y < (h - 2) && x < (w - 2))
{
for (i = -1; i <= 1; i++)
{
for (j = -1; j <= 1; j++)
{
int index, pix;
index = (y + i) * w + x + j;
pix = ef->im_data[index];
bb += (int) ((pix) & 0xff) *
emboss[i+1][j+1];
gg += (int) ((pix >> 8) & 0xff) *
emboss[i+1][j+1];
rr += (int) ((pix >> 16) & 0xff) *
emboss[i+1][j+1];
}
}
}
bb += 127;
gg += 127;
rr += 127;
bb = _normalize_color(bb);
gg = _normalize_color(gg);
rr = _normalize_color(rr);
a = (*p >> 24) & 0xff;
*p = (a << 24) | (rr << 16) | (gg << 8) | bb;
p++;
}
passes++;
if (passes == 500)
{
ef->pos = y++;
return EINA_TRUE;
}
}
_idler_finishing_cb(ef, EINA_FALSE);
return EINA_FALSE;
}
static Eina_Bool
_histogram_eq(void *data)
{
@ -1258,6 +1319,15 @@ void ephoto_filter_edge(Evas_Object *main, Evas_Object *image)
ef->idler = ecore_idler_add(_blur, ef);
}
void ephoto_filter_emboss(Evas_Object *main, Evas_Object *image)
{
Ephoto_Filter *ef = _initialize_filter(EPHOTO_IMAGE_FILTER_EMBOSS,
main, image);
ef->popup = _processing(main);
ef->idler = ecore_idler_add(_emboss, ef);
}
void
ephoto_filter_histogram_eq(Evas_Object *main, Evas_Object *image)
{

@ -1256,6 +1256,21 @@ _go_edge(void *data, Evas_Object *obj EINA_UNUSED,
}
}
static void
_go_emboss(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Ephoto_Single_Browser *sb = data;
if (sb->viewer)
{
sb->editing = EINA_TRUE;
Ephoto_Viewer *v = evas_object_data_get(sb->viewer, "viewer");
ephoto_filter_emboss(sb->main, v->image);
}
}
static void
_image_changed(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
@ -1503,6 +1518,8 @@ _add_edit_menu_items(Ephoto_Single_Browser *sb, Evas_Object *menu)
_go_dither, sb);
elm_menu_item_add(menu, menu_itt, "insert-image", _("Edge Detect"),
_go_edge, sb);
elm_menu_item_add(menu, menu_itt, "insert-image", _("Emboss"),
_go_emboss, sb);
elm_menu_item_add(menu, menu_itt, "insert-image", _("Invert Colors"),
_go_invert, sb);
elm_menu_item_add(menu, menu_itt, "insert-image", _("Old Photo"),

Loading…
Cancel
Save