__evas_free_p(canvas);
}
-static int __save_to_png(const char *path, unsigned char *buf,
- int width, int height)
+struct save_to_png_args {
+ const char *path;
+ unsigned char *buf;
+ int width;
+ int height;
+};
+
+static void* __save_to_png(void *data)
{
- int ret = -1, err;
+ struct save_to_png_args *png_args = data;
+ int *ret = malloc(sizeof(int));
+ int err;
Evas *ev = NULL;
Evas_Object *img;
rtld_default_set_once(__evas_object_image_add_p,
"evas_object_image_add");
- ev = create_canvas(width, height);
+ *ret = -1;
+ ev = create_canvas(png_args->width, png_args->height);
if (unlikely(ev == NULL)) {
PRINTERR("failed to create canvas");
- return -1;
+ return (void *)ret;
}
// make image buffer
//image buffer set
__evas_object_image_data_set_p(img, NULL);
- __evas_object_image_size_set_p(img, width, height);
- __evas_object_image_data_set_p(img, buf);
+ __evas_object_image_size_set_p(img, png_args->width, png_args->height);
+ __evas_object_image_data_set_p(img, png_args->buf);
// resize image
- if (height > MAX_HEIGHT) {
- width = width * MAX_HEIGHT / height;
- height = MAX_HEIGHT;
- __evas_object_resize_p(img, width, height);
- __evas_object_image_fill_set_p(img, 0, 0, width, height);
+ if (png_args->height > MAX_HEIGHT) {
+ png_args->width = png_args->width * MAX_HEIGHT / png_args->height;
+ png_args->height = MAX_HEIGHT;
+ __evas_object_resize_p(img, png_args->width, png_args->height);
+ __evas_object_image_fill_set_p(img, 0, 0, png_args->width, png_args->height);
}
- __evas_object_image_data_update_add_p(img, 0, 0, width, height);
+ __evas_object_image_data_update_add_p(img, 0, 0, png_args->width, png_args->height);
//save image to png file
- err = __evas_object_image_save_p(img, path, NULL, "compress=5");
+ err = __evas_object_image_save_p(img, png_args->path, NULL, "compress=5");
if (err != 0)
- ret = 0;
+ *ret = 0;
out_canvas:
destroy_canvas(ev);
- return ret;
+ return (void *)ret;
}
static struct efl_data *__edata = NULL;
static int checked4padding;
static int padding;
int width, height;
+ struct save_to_png_args *png_args;
+ int *ret_ptr;
+
+ static void* (*__ecore_main_loop_thread_safe_call_sync_p)(Ecore_Data_Cb callback,
+ void *data);
+ rtld_default_set_once(__ecore_main_loop_thread_safe_call_sync_p,
+ "ecore_main_loop_thread_safe_call_sync");
data = __wayland_init();
if (!data) {
}
}
- ret = __save_to_png(path, tsuri.planes[plane_idx].ptr,
- width, height);
+ png_args = malloc(sizeof(struct save_to_png_args));
+ png_args->path = (char *)path;
+ png_args->buf = tsuri.planes[plane_idx].ptr;
+ png_args->width = width;
+ png_args->height = height;
+
+ ret_ptr = (int *)__ecore_main_loop_thread_safe_call_sync_p(__save_to_png, png_args);
+ ret = *ret_ptr;
+
+ free(png_args);
+ free(ret_ptr);
wrong_padding:
tbm_surface_unmap(t_surface);