summaryrefslogtreecommitdiff
path: root/src/examples/evas
diff options
context:
space:
mode:
authorHermet Park <hermetpark@gmail.com>2019-05-02 16:42:25 +0900
committerHermet Park <hermetpark@gmail.com>2019-05-02 17:02:00 +0900
commit53cdf850ba0f10a4a4db3e3c7f7cf1742ca88db1 (patch)
treed77c5d31fa0038da1e88cf5314ff5319225e5d78 /src/examples/evas
parente2634eec6704170541e18df981188859c7f5794d (diff)
evas png: apply interpolation when scale down image loading.
Summary: This patch improves png quality when image uses scale-down at image loading. Since current scale-down logic just works like point sampling, image result could be wholely different, Simply, if source data is consist of continous white and black pixels, and scale down factor is 2, the sampled data would be only white, and lose all black pixels, or vice versa. The result can be unexpected by users. Even current jpeg scale-down works with interpolation. Before: {F3711651} After: {F3711652} Original: {F3711653} Reviewers: cedric, raster, #committers, kimcinoo, jsuya Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D8788
Diffstat (limited to 'src/examples/evas')
-rw-r--r--src/examples/evas/Makefile.examples1
-rw-r--r--src/examples/evas/evas-images6.c98
-rw-r--r--src/examples/evas/meson.build1
-rw-r--r--src/examples/evas/resources/images/scale_down.pngbin0 -> 1650468 bytes
4 files changed, 100 insertions, 0 deletions
diff --git a/src/examples/evas/Makefile.examples b/src/examples/evas/Makefile.examples
index 48173f91b6..7e3f7c2dd3 100644
--- a/src/examples/evas/Makefile.examples
+++ b/src/examples/evas/Makefile.examples
@@ -16,6 +16,7 @@ EXAMPLES= evas-aspect-hints \
16 evas-images3 \ 16 evas-images3 \
17 evas-images4 \ 17 evas-images4 \
18 evas-images5 \ 18 evas-images5 \
19 evas-images6 \
19 evas-init-shutdown \ 20 evas-init-shutdown \
20 evas-map-utils \ 21 evas-map-utils \
21 evas-object-manipulation \ 22 evas-object-manipulation \
diff --git a/src/examples/evas/evas-images6.c b/src/examples/evas/evas-images6.c
new file mode 100644
index 0000000000..ac09b4486e
--- /dev/null
+++ b/src/examples/evas/evas-images6.c
@@ -0,0 +1,98 @@
1/**
2 * Example of handling events for image objects in Evas.
3 *
4 * You'll need at least one engine built for it (excluding the buffer
5 * one) and the png image loader/saver also built. See stdout/stderr
6 * for output.
7 *
8 * @verbatim
9 * gcc -o evas-images6 evas-images6.c `pkg-config --libs --cflags evas ecore ecore-evas`
10 * @endverbatim
11 */
12
13#ifdef HAVE_CONFIG_H
14#include "config.h"
15#else
16#define PACKAGE_EXAMPLES_DIR "."
17#endif
18
19#include <Ecore.h>
20#include <Ecore_Evas.h>
21#include <stdio.h>
22#include <errno.h>
23#include "evas-common.h"
24
25#define WIDTH (960)
26#define HEIGHT (540)
27
28static const char *img_path = PACKAGE_EXAMPLES_DIR EVAS_IMAGE_FOLDER "/scale_down.png";
29
30struct test_data
31{
32 Ecore_Evas *ee;
33 Evas *evas;
34 Evas_Object *bg, *img;
35};
36
37static struct test_data d = {0};
38
39
40static void
41_on_destroy(Ecore_Evas *ee EINA_UNUSED)
42{
43 ecore_main_loop_quit();
44}
45
46/* Keep the example's window size in sync with the background image's size */
47static void
48_canvas_resize_cb(Ecore_Evas *ee)
49{
50 int w, h;
51
52 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
53 evas_object_resize(d.bg, w, h);
54}
55
56int
57main(void)
58{
59 if (!ecore_evas_init())
60 return EXIT_FAILURE;
61
62 /* this will give you a window with an Evas canvas under the first
63 * engine available */
64 d.ee = ecore_evas_new(NULL, 10, 10, WIDTH, HEIGHT, NULL);
65 if (!d.ee)
66 goto error;
67
68 ecore_evas_callback_destroy_set(d.ee, _on_destroy);
69 ecore_evas_callback_resize_set(d.ee, _canvas_resize_cb);
70 ecore_evas_show(d.ee);
71
72 /* the canvas pointer, de facto */
73 d.evas = ecore_evas_get(d.ee);
74
75 d.bg = evas_object_rectangle_add(d.evas);
76 evas_object_color_set(d.bg, 255, 255, 255, 255); /* white bg */
77 evas_object_move(d.bg, 0, 0); /* at canvas' origin */
78 evas_object_resize(d.bg, WIDTH, HEIGHT); /* covers full canvas */
79 evas_object_show(d.bg);
80
81 d.img = evas_object_image_filled_add(d.evas);
82 evas_object_image_file_set(d.img, img_path, NULL);
83 evas_object_image_load_scale_down_set(d.img, 2);
84 evas_object_resize(d.img, WIDTH, HEIGHT);
85 evas_object_show(d.img);
86
87 ecore_main_loop_begin();
88
89 ecore_evas_free(d.ee);
90 ecore_evas_shutdown();
91 return 0;
92
93error:
94 fprintf(stderr, "error: Requires at least one Evas engine built and linked"
95 " to ecore-evas for this example to run properly.\n");
96 ecore_evas_shutdown();
97 return -1;
98}
diff --git a/src/examples/evas/meson.build b/src/examples/evas/meson.build
index 34c8bd3463..9a9bd1fe2f 100644
--- a/src/examples/evas/meson.build
+++ b/src/examples/evas/meson.build
@@ -29,6 +29,7 @@ examples = [
29 'evas-images3', 29 'evas-images3',
30 'evas-images4', 30 'evas-images4',
31 'evas-images5', 31 'evas-images5',
32 'evas-images6',
32 'evas-images', 33 'evas-images',
33 'evas-init-shutdown', 34 'evas-init-shutdown',
34 'evas-map-aa', 35 'evas-map-aa',
diff --git a/src/examples/evas/resources/images/scale_down.png b/src/examples/evas/resources/images/scale_down.png
new file mode 100644
index 0000000000..ff4bdc4b81
--- /dev/null
+++ b/src/examples/evas/resources/images/scale_down.png
Binary files differ