}
}
-static void cropped_resize_cb(void *data, Evas *e, Evas_Object *obj, void *ei)
-{
- Evas_Coord w;
- Evas_Coord h;
- int part_w;
- int part_h;
-
- /* grab image size */
- part_w = (int)evas_object_data_get(obj, "part_w");
- part_h = (int)evas_object_data_get(obj, "part_h");
- w = (int)evas_object_data_get(obj, "w");
- h = (int)evas_object_data_get(obj, "h");
-
- /* grab base object dimensions */
- evas_object_resize(obj, part_w, part_h);
- evas_object_image_fill_set(obj, 0, 0, part_w, part_h);
-
- DbgPrint("Cropped: %dx%d - %dx%d, ImageSize(%dx%d)\n", (w - part_w) / 2, (h - part_h) / 2, part_w, part_h, w, h);
-}
-
PUBLIC int script_update_image(void *_h, Evas *e, const char *id, const char *part, const char *path, const char *option)
{
struct info *handle = _h;
return -EFAULT;
}
+ evas_object_image_preload(img, EINA_FALSE);
parse_image_option(option, &img_opt);
evas_object_image_load_orientation_set(img, img_opt.orient);
evas_object_image_file_set(img, path, NULL);
-
err = evas_object_image_load_error_get(img);
if (err != EVAS_LOAD_ERROR_NONE) {
ErrPrint("Load error: %s\n", evas_load_error_str(err));
if (img_opt.fill == FILL_OVER_SIZE) {
Evas_Coord part_w;
Evas_Coord part_h;
+ double fw;
+ double fh;
if (img_opt.width >= 0 && img_opt.height >= 0) {
- part_w = img_opt.width;// * scale_get();
- part_h = img_opt.height;// * scale_get();
+ part_w = img_opt.width * scale_get();
+ part_h = img_opt.height * scale_get();
} else {
edje_object_part_geometry_get(edje, part, NULL, NULL, &part_w, &part_h);
}
- evas_object_data_set(img, "part_w", (void *)part_w);
- evas_object_data_set(img, "part_h", (void *)part_h);
DbgPrint("Original %dx%d (part: %dx%d)\n", w, h, part_w, part_h);
- if (w < part_w || h < part_h) {
- Evas_Coord tmp_w;
- Evas_Coord tmp_h;
- tmp_w = part_w - w;
- tmp_h = part_h - h;
+ if (part_w > w || part_h > h) {
+ fw = (double)part_w / (double)w;
+ fh = (double)part_h / (double)h;
- if (tmp_w > tmp_h) {
- DbgPrint("Before: (h = %d * %d / %d)\n", part_w, h, w);
- h = (int)((double)part_h * (double)w / (double)part_w);
+ if (fw > fh) {
w = part_w;
- DbgPrint("Size: %dx%d\n", w, h);
+ h = (double)h * fw;
} else {
- DbgPrint("Before: (w = %d * %d / %d)\n", part_h, w, h);
- w = (int)((double)part_w * (double)h / (double)w);
h = part_h;
- DbgPrint("Size: %dx%d\n", w, h);
+ w = (double)w * fh;
}
}
+ DbgPrint("Size: %dx%d\n", w, h);
+ evas_object_data_set(img, "part_w", (void *)part_w);
+ evas_object_data_set(img, "part_h", (void *)part_h);
evas_object_data_set(img, "w", (void *)w);
evas_object_data_set(img, "h", (void *)h);
+
evas_object_image_load_size_set(img, w, h);
evas_object_image_load_region_set(img, (w - part_w) / 2, (h - part_h) / 2, part_w, part_h);
+ evas_object_image_fill_set(img, 0, 0, part_w, part_h);
evas_object_image_reload(img);
- evas_object_event_callback_add(img, EVAS_CALLBACK_RESIZE, cropped_resize_cb, NULL);
} else {
evas_object_image_fill_set(img, 0, 0, w, h);
evas_object_size_hint_fill_set(img, EVAS_HINT_FILL, EVAS_HINT_FILL);