4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #include <Elementary.h>
23 #include <Ecore_Evas.h>
26 #include "appcore-internal.h"
27 #include "virtual_canvas.h"
30 #define QUALITY_N_COMPRESS "quality=100 compress=1"
34 Evas *virtual_canvas_create(int w, int h)
36 Ecore_Evas *internal_ee;
39 // Create virtual canvas
40 internal_ee = ecore_evas_buffer_new(w, h);
42 _DBG("Failed to create a new canvas buffer\n");
46 ecore_evas_alpha_set(internal_ee, EINA_TRUE);
47 ecore_evas_manual_render_set(internal_ee, EINA_TRUE);
49 // Get the "Evas" object from a virtual canvas
50 internal_e = ecore_evas_get(internal_ee);
52 ecore_evas_free(internal_ee);
53 _DBG("Faield to get Evas object\n");
62 static bool _flush_data_to_file(Evas *e, char *data, const char *filename, int w, int h)
66 output = evas_object_image_add(e);
68 _DBG("Failed to create an image object\n");
72 evas_object_image_data_set(output, NULL);
73 evas_object_image_colorspace_set(output, EVAS_COLORSPACE_ARGB8888);
74 evas_object_image_alpha_set(output, EINA_TRUE);
75 evas_object_image_size_set(output, w, h);
76 evas_object_image_smooth_scale_set(output, EINA_TRUE);
77 evas_object_image_data_set(output, data);
78 evas_object_image_data_update_add(output, 0, 0, w, h);
80 if (evas_object_image_save(output, filename, NULL, QUALITY_N_COMPRESS) == EINA_FALSE) {
81 evas_object_del(output);
82 _DBG("Faild to save a captured image (%s)\n", filename);
86 evas_object_del(output);
88 if (access(filename, F_OK) != 0) {
89 _DBG("File %s is not found\n", filename);
98 bool virtual_canvas_flush_to_file(Evas *e, const char *filename, int w, int h)
101 Ecore_Evas *internal_ee;
103 internal_ee = ecore_evas_ecore_evas_get(e);
105 _DBG("Failed to get ecore evas\n");
109 ecore_evas_manual_render(internal_ee);
111 // Get a pointer of a buffer of the virtual canvas
112 data = (void *) ecore_evas_buffer_pixels_get(internal_ee);
114 _DBG("Failed to get pixel data\n");
118 return _flush_data_to_file(e, data, filename, w, h);
123 bool virtual_canvas_destroy(Evas *e)
127 ee = ecore_evas_ecore_evas_get(e);
129 _DBG("Failed to ecore evas object\n");