summaryrefslogtreecommitdiff
path: root/src/examples/evas/evas_mono_image2.cs
blob: e2ae49f092ac6b1a336bf5e42b1722b2d8078e33 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;

class TestMain
{
    static int WIDTH = 320;
    static int HEIGHT = 240;


    static void Main(string[] args)
    {
        efl.All.Init();

        efl.Loop loop = new efl.LoopConcrete();

        EcoreEvas ecore_evas = new EcoreEvas();

        eina.Size2D size = new eina.Size2D();
        eina.Position2D pos = new eina.Position2D();
        
        efl.canvas.Object canvas = ecore_evas.canvas;
        canvas.SetVisible(true);

        efl.canvas.Rectangle bg = new efl.canvas.RectangleConcrete(canvas);
        bg.SetColor(255, 255, 255, 255);
        pos.X = 0;
        pos.Y = 0;
        bg.SetPosition(pos);
        size.W = WIDTH;
        size.H = HEIGHT;
        bg.SetSize(size);
        bg.SetVisible(true);

        string path = args[0];
        evas.Image logo = new evas.ImageConcrete(canvas);
        logo.SetFillAuto(true);

        // TODO add preloaded support (depends on events)

        logo.SetFile(path, null);
        size.W = WIDTH / 2;
        size.H = HEIGHT / 2;
        logo.SetSize(size);

        // TODO add a bunch of key/mouse handlers

        logo.SetVisible(true);

        int[] pixels = new int[(WIDTH/4) * (HEIGHT / 4)];
        System.Random generator = new System.Random();
        for (int i = 0; i < pixels.Length; i++) {
            pixels[i] = generator.Next();
        }

        evas.Image noise_img = new evas.ImageConcrete(canvas);
        size.W = WIDTH / 4;
        size.H = HEIGHT / 4;
        noise_img.SetSize(size);
        // FIXME Add a way to set the pixels.
        // noise_img.data_set(pixels);
        noise_img.SetFillAuto(true);
        pos.X = WIDTH * 5 / 8;
        pos.Y = HEIGHT / 8;
        noise_img.SetPosition(pos);
        noise_img.SetVisible(true);
        Console.WriteLine("Creating noise image with sizez %d, %d", WIDTH/4, HEIGHT/4);

        efl.canvas.Proxy proxy_img = new efl.canvas.ProxyConcrete(canvas);
        proxy_img.SetSource(noise_img);
        pos.X = WIDTH / 2;
        pos.Y = HEIGHT / 2;
        proxy_img.SetPosition(pos);
        size.W = WIDTH / 2;
        size.H = HEIGHT / 2;
        proxy_img.SetSize(size);
        proxy_img.SetVisible(true);

        loop.Begin();
    }
}