summaryrefslogtreecommitdiff
path: root/main.c
blob: d0382f71895b233fcba820fc74cdb6e2a326f406 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <elementary-1/Elementary.h>
#include "Embiance.h"

#define WIDTH 640
#define HEIGHT 480

int main(int argc, char **argv)
{
    Evas *evas;
    Evas_Object *win, *bg, *image, *txt;
    l_int32 *r, *g, *b;
    unsigned int ncolors_found;

    if (argc != 2)
    {
        printf("%s some_image_file\n", argv[0]);
        return EXIT_FAILURE;
    }
    elm_init(argc, argv);

    elm_policy_set(ELM_POLICY_QUIT_LAST_WINDOW_CLOSED, EINA_TRUE);

    win = elm_win_add(NULL, "embiance", ELM_WIN_BASIC);
    elm_win_title_set(win, "Embiance test");
    elm_win_autodel_set(win, EINA_TRUE);
    evas_object_resize(win, WIDTH, HEIGHT);
    evas_object_show(win);

    bg = elm_bg_add(win);
    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
    elm_win_resize_object_add(win, bg);
    evas_object_show(bg);

    evas = evas_object_evas_get(win);

    image = evas_object_image_filled_add(evas);
    evas_object_show(image);
    evas_object_image_file_set(image, argv[1], NULL);
    evas_object_size_hint_aspect_set(image, EVAS_ASPECT_CONTROL_BOTH, 1, 1);
    evas_object_resize(image, (WIDTH - 150), HEIGHT);
    evas_object_move(image, 150, 0);

    /*ncolors_found = evas_object_image_frequent_colors_get_histo(image, 3, &r, &g, &b);*/
    ncolors_found = evas_object_image_frequent_colors_get_median_cut(image, 3, &r, &g, &b);

    elm_bg_color_set(bg, r[0], g[0], b[0]);

    txt = evas_object_text_add(evas);
    evas_object_text_font_set(txt, "DejaVu Sans", 24);
    evas_object_color_set(txt, r[1], g[1], b[1], 255);
    evas_object_text_text_set(txt, "Color 2...");
    evas_object_show(txt);

    txt = evas_object_text_add(evas);
    evas_object_text_font_set(txt, "DejaVu Sans", 18);
    evas_object_color_set(txt, r[2], g[2], b[2], 255);
    evas_object_text_text_set(txt, "Color 3...");
    evas_object_move(txt, 0, 100);
    evas_object_show(txt);

    elm_run();
    elm_shutdown();

    free(r), free(g), free(b);

    return 0;
}