Hi guys,
This patch adds support for video cropping in emotion, if anyone's
interested. You give it the number of pixels you want to crop on each
size (relative to the original size of the video)
We use it to remove black bars from a video or do a video wall with
multiple screens, it works fine even with our low power machines.
Regards
Hugo Camboulive
commit bc58e3bfc736cd6f84144457d6726a6029d602d8
Author: Hugo Camboulive <[email protected]>
Date: Tue May 11 09:11:24 2010 +0200
Add support for crop into emotion. (bug 750)
diff --git a/src/lib/Emotion.h b/src/lib/Emotion.h
index 929b30a..7710e23 100644
--- a/src/lib/Emotion.h
+++ b/src/lib/Emotion.h
@@ -174,6 +174,8 @@ EAPI void emotion_object_vis_set (Evas_Object *obj, Emotio
EAPI Emotion_Vis emotion_object_vis_get (const Evas_Object *obj);
EAPI Eina_Bool emotion_object_vis_supported (const Evas_Object *obj, Emotion_Vis visualization);
+EAPI void emotion_object_crop_set(Evas_Object *obj, int a, int b, int c, int d);
+EAPI void emotion_object_crop_get(Evas_Object *obj, int *a, int *b, int *c, int *d);
#ifdef __cplusplus
}
#endif
diff --git a/src/lib/emotion_smart.c b/src/lib/emotion_smart.c
index 9d8681e..b1c82eb 100644
--- a/src/lib/emotion_smart.c
+++ b/src/lib/emotion_smart.c
@@ -61,6 +61,13 @@ struct _Smart_Data
int button_num;
int button;
} spu;
+ struct {
+ int a; /* left */
+ int b; /* top */
+ int c; /* right */
+ int d; /* bottom */
+ Evas_Object *clipper;
+ } crop;
Emotion_Module_Options module_options;
};
@@ -285,6 +292,30 @@ emotion_object_init(Evas_Object *obj, const char *module_filename)
}
EAPI void
+emotion_object_crop_set(Evas_Object *obj, int a, int b, int c, int d)
+{
+ Smart_Data *sd;
+
+ E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
+ sd->crop.a = a;
+ sd->crop.b = b;
+ sd->crop.c = c;
+ sd->crop.d = d;
+}
+
+EAPI void
+emotion_object_crop_get(Evas_Object *obj, int *a, int *b, int *c, int *d)
+{
+ Smart_Data *sd;
+
+ E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
+ *a = sd->crop.a;
+ *b = sd->crop.b;
+ *c = sd->crop.c;
+ *d = sd->crop.d;
+}
+
+EAPI void
emotion_object_file_set(Evas_Object *obj, const char *file)
{
Smart_Data *sd;
@@ -438,6 +469,8 @@ emotion_object_size_get(const Evas_Object *obj, int *iw, int *ih)
if (ih) *ih = 0;
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
evas_object_image_size_get(sd->obj, iw, ih);
+ *iw -= (sd->crop.a + sd->crop.c);
+ *ih -= (sd->crop.b + sd->crop.d);
}
EAPI void
@@ -1323,13 +1356,17 @@ _smart_add(Evas_Object * obj)
sd = calloc(1, sizeof(Smart_Data));
if (!sd) return;
sd->obj = evas_object_image_add(evas_object_evas_get(obj));
+ sd->crop.clipper = evas_object_rectangle_add(evas_object_evas_get(obj));
+ evas_object_color_set(sd->crop.clipper, 255, 255, 255, 255);
evas_object_event_callback_add(sd->obj, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move, sd);
evas_object_event_callback_add(sd->obj, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, sd);
evas_object_image_pixels_get_callback_set(sd->obj, _pixels_get, sd);
evas_object_smart_member_add(sd->obj, obj);
+ evas_object_smart_member_add(sd->crop.clipper, obj);
sd->ratio = 1.0;
sd->spu.button = -1;
evas_object_image_alpha_set(sd->obj, 0);
+ evas_object_clip_set(sd->obj, sd->crop.clipper);
pixel = evas_object_image_data_get(sd->obj, 1);
if (pixel)
{
@@ -1349,6 +1386,7 @@ _smart_del(Evas_Object * obj)
if (sd->video) sd->module->file_close(sd->video);
_emotion_module_close(sd->module, sd->video);
evas_object_del(sd->obj);
+ evas_object_del(sd->crop.clipper);
free(sd->file);
free(sd->module_name);
if (sd->job) ecore_job_del(sd->job);
@@ -1366,7 +1404,15 @@ _smart_move(Evas_Object * obj, Evas_Coord x, Evas_Coord y)
sd = evas_object_smart_data_get(obj);
if (!sd) return;
- evas_object_move(sd->obj, x, y);
+
+ int vid_w, vid_h, w, h;
+ double scale_w, scale_h;
+ sd->module->video_data_size_get(sd->video, &vid_w, &vid_h);
+ evas_object_geometry_get(sd->obj, NULL, NULL, &w, &h);
+ scale_w = (double)w / (double)(vid_w - sd->crop.a - sd->crop.c);
+ scale_h = (double)h / (double)(vid_h - sd->crop.b - sd->crop.d);
+ evas_object_move(sd->crop.clipper, x, y);
+ evas_object_move(sd->obj, x - sd->crop.a * scale_w, y - sd->crop.b * scale_h);
}
static void
@@ -1376,8 +1422,20 @@ _smart_resize(Evas_Object * obj, Evas_Coord w, Evas_Coord h)
sd = evas_object_smart_data_get(obj);
if (!sd) return;
- evas_object_image_fill_set(sd->obj, 0, 0, w, h);
- evas_object_resize(sd->obj, w, h);
+
+ double scale_w, scale_h;
+ int vid_w, vid_h;
+ int x, y;
+
+ sd->module->video_data_size_get(sd->video, &vid_w, &vid_h);
+ evas_object_geometry_get(sd->crop.clipper, &x, &y, NULL, NULL);
+ scale_w = (double)w / (double)(vid_w - sd->crop.a - sd->crop.c);
+ scale_h = (double)h / (double)(vid_h - sd->crop.b - sd->crop.d);
+
+ evas_object_image_fill_set(sd->obj, 0, 0, vid_w * scale_w, vid_h * scale_h);
+ evas_object_resize(sd->obj, vid_w * scale_w, vid_h * scale_h);
+ evas_object_move(sd->obj, x - sd->crop.a * scale_w, y - sd->crop.b * scale_h);
+ evas_object_resize(sd->crop.clipper, w, h);
}
static void
@@ -1388,7 +1446,7 @@ _smart_show(Evas_Object * obj)
sd = evas_object_smart_data_get(obj);
if (!sd) return;
evas_object_show(sd->obj);
-
+ evas_object_show(sd->crop.clipper);
}
static void
@@ -1399,6 +1457,7 @@ _smart_hide(Evas_Object * obj)
sd = evas_object_smart_data_get(obj);
if (!sd) return;
evas_object_hide(sd->obj);
+ evas_object_hide(sd->crop.clipper);
}
static void
@@ -1409,6 +1468,7 @@ _smart_color_set(Evas_Object * obj, int r, int g, int b, int a)
sd = evas_object_smart_data_get(obj);
if (!sd) return;
evas_object_color_set(sd->obj, r, g, b, a);
+ evas_object_color_set(sd->crop.clipper, r, g, b, a);
}
static void
@@ -1418,7 +1478,7 @@ _smart_clip_set(Evas_Object * obj, Evas_Object * clip)
sd = evas_object_smart_data_get(obj);
if (!sd) return;
- evas_object_clip_set(sd->obj, clip);
+ evas_object_clip_set(sd->crop.clipper, clip);
}
static void
@@ -1428,5 +1488,5 @@ _smart_clip_unset(Evas_Object * obj)
sd = evas_object_smart_data_get(obj);
if (!sd) return;
- evas_object_clip_unset(sd->obj);
+ evas_object_clip_unset(sd->crop.clipper);
}
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel