\hypertarget{ecore_evas_buffer_example_02_8c-example}{\section{ecore\+\_\+evas\+\_\+buffer\+\_\+example\+\_\+02.\+c}
}

\begin{DoxyCodeInclude}

\textcolor{preprocessor}{#ifdef HAVE\_CONFIG\_H}

\textcolor{preprocessor}{#include "config.h"}
\textcolor{preprocessor}{#else}
\textcolor{preprocessor}{#define EINA\_UNUSED}
\textcolor{preprocessor}{#define PACKAGE\_EXAMPLES\_DIR "."}
\textcolor{preprocessor}{#endif}

\textcolor{preprocessor}{#include <Ecore.h>}
\textcolor{preprocessor}{#include <\hyperlink{Ecore__Evas_8h}{Ecore\_Evas.h}>}
\textcolor{preprocessor}{#include <stdio.h>}

\textcolor{preprocessor}{#define WIDTH  (320)}
\textcolor{preprocessor}{#define HEIGHT (240)}

\textcolor{keyword}{static} Ecore\_Evas *ee;
\textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char} *border\_img\_path = PACKAGE\_EXAMPLES\_DIR \textcolor{stringliteral}{"/red.png"};

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_on\_destroy(Ecore\_Evas *ee\_ \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED})
\{
   \hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}();
\}

\textcolor{keywordtype}{int}
main(\textcolor{keywordtype}{void})
\{
   \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas} *canvas, *sub\_canvas;
   \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *bg, *r0, *r1, *r2, *r3; \textcolor{comment}{/* "sub" canvas objects */}
   \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *border, *img; \textcolor{comment}{/* canvas objects */}
   Ecore\_Evas *sub\_ee;

   \hyperlink{group__Ecore__Evas__Group_ga32ddbb6457033ad435a177eb0c4fe235}{ecore\_evas\_init}();

   \textcolor{comment}{/* this will give you a window with an Evas canvas under the first}
\textcolor{comment}{    * engine available */}
   ee = \hyperlink{group__Ecore__Evas__Group_gac7f2cdbcb79635c34317c1183dd04cb0}{ecore\_evas\_new}(NULL, 0, 0, WIDTH, HEIGHT, NULL);
   \textcolor{keywordflow}{if} (!ee) \textcolor{keywordflow}{goto} \hyperlink{namespaceefl_1_1eina_1_1log__level_a0eec9fe47d243634f680b56a7d768ec7}{error};

   \hyperlink{group__Ecore__Evas__Group_ga63abcee3b625bd6410fe8eb46b2a5d9c}{ecore\_evas\_size\_min\_set}(ee, WIDTH, HEIGHT);
   \hyperlink{group__Ecore__Evas__Group_gac9ad3e25ab3f2bea8be726d24df62902}{ecore\_evas\_size\_max\_set}(ee, WIDTH, HEIGHT);

   \hyperlink{group__Ecore__Evas__Group_ga3d478e975e2101b9b821ef24baf3dd9e}{ecore\_evas\_callback\_delete\_request\_set}(ee, \_on\_destroy);
   \hyperlink{group__Ecore__Evas__Group_ga3b2832e0373bbafae2bb7143618535c1}{ecore\_evas\_title\_set}(ee, \textcolor{stringliteral}{"Ecore\_Evas buffer (image) example"});
   \hyperlink{group__Ecore__Evas__Group_ga4953047ff97d4f1b0d75a7d513d4f317}{ecore\_evas\_show}(ee);

   canvas = \hyperlink{group__Ecore__Evas__Group_ga75a7cc694b6069e78df47dab0b0f2d20}{ecore\_evas\_get}(ee);

   bg = \hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}(canvas);
   \hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}(bg, 255, 255, 255, 255); \textcolor{comment}{/* white bg */}
   evas\_object\_move(bg, 0, 0); \textcolor{comment}{/* at origin */}
   evas\_object\_resize(bg, WIDTH, HEIGHT); \textcolor{comment}{/* covers full canvas */}
   \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(bg);

   \textcolor{comment}{/* this is a border around the image containing a scene of another}
\textcolor{comment}{    * canvas */}
   border = \hyperlink{group__Evas__Object__Image_ga0e8cb83d31d02bf583c75925b7cd14d7}{evas\_object\_image\_filled\_add}(canvas);
   \hyperlink{group__Evas__Object__Image_gac27fd0ceabe5f56607b7a86d71577df1}{evas\_object\_image\_file\_set}(border, border\_img\_path, NULL);
   evas\_object\_image\_border\_set(border, 3, 3, 3, 3);
   evas\_object\_image\_border\_center\_fill\_set(border, \hyperlink{Evas__Common_8h_a4a05f0fd82f51c6b330e349457cdc7e2a2ad856ac6aab5e2659c3a584a37aec70}{EVAS\_BORDER\_FILL\_NONE});

   evas\_object\_move(border, WIDTH / 6, HEIGHT / 6);
   evas\_object\_resize(border, (2 * WIDTH) / 3, (2 * HEIGHT) / 3);
   \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(border);

   img = \hyperlink{group__Ecore__Evas__Group_ga94ab8c823c98ba58a6a61ce8aaebe32e}{ecore\_evas\_object\_image\_new}(ee);
   evas\_object\_image\_filled\_set(img, \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE});
   evas\_object\_image\_size\_set(
     img, ((2 * WIDTH) / 3) - 6, ((2 * HEIGHT) / 3) - 6);
   sub\_ee = \hyperlink{group__Ecore__Evas__Group_ga70c5492c4d2086b2a38d52fd4a281c65}{ecore\_evas\_object\_ecore\_evas\_get}(img);
   sub\_canvas = \hyperlink{group__Ecore__Evas__Group_ga31d4f9dd1586c8ce2680cf9f3d891f3c}{ecore\_evas\_object\_evas\_get}(img);

   evas\_object\_move(img, (WIDTH / 6) + 3, (HEIGHT / 6) + 3);

   \textcolor{comment}{/* apply the same size on both! */}
   evas\_object\_resize(img, ((2 * WIDTH) / 3) - 6, ((2 * HEIGHT) / 3) - 6);
   \hyperlink{group__Ecore__Evas__Group_ga3109b574eca21cd8b57a749c362dba3e}{ecore\_evas\_resize}(sub\_ee, ((2 * WIDTH) / 3) - 6, ((2 * HEIGHT) / 3) - 6);

   r0 = \hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}(sub\_canvas);
   \hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}(r0, 0, 0, 0, 255); \textcolor{comment}{/* 100% opaque black bg */}
   evas\_object\_move(r0, 0, 0);
   evas\_object\_resize(r0, ((2 * WIDTH) / 3) - 6, ((2 * HEIGHT) / 3) - 6);
   \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(r0);
   
   r1 = \hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}(sub\_canvas);
   \hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}(r1, 255, 0, 0, 255); \textcolor{comment}{/* 100% opaque red */}
   evas\_object\_move(r1, 10, 10);
   evas\_object\_resize(r1, 100, 100);
   \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(r1);

   r2 = \hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}(sub\_canvas);
   \hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}(r2, 0, 128, 0, 128); \textcolor{comment}{/* 50% opaque green */}
   evas\_object\_move(r2, 10, 10);
   evas\_object\_resize(r2, 50, 50);
   \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(r2);

   r3 = \hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}(sub\_canvas);
   \hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}(r3, 0, 128, 0, 255); \textcolor{comment}{/* 100% opaque dark green */}
   evas\_object\_move(r3, 60, 60);
   evas\_object\_resize(r3, 50, 50);
   \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(r3);

   \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(img);
   \hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}();

   \hyperlink{group__Ecore__Evas__Group_gad3ec61f2aa03df4d3dbfd0d311e0c8dc}{ecore\_evas\_free}(ee);
   \hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}();

   \textcolor{keywordflow}{return} 0;

\hyperlink{namespaceefl_1_1eina_1_1log__level_a0eec9fe47d243634f680b56a7d768ec7}{error}:
   fprintf(stderr, \textcolor{stringliteral}{"You got to have at least one Evas engine built"}
                   \textcolor{stringliteral}{" and linked up to ecore-evas for this example to run"}
                   \textcolor{stringliteral}{" properly.\(\backslash\)n"});
   \hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}();
   \textcolor{keywordflow}{return} -1;
\}

\end{DoxyCodeInclude}
 