\doxysection{ecore\+\_\+evas\+\_\+buffer\+\_\+example\+\_\+01.\+c}
\hypertarget{ecore_evas_buffer_example_01_8c-example}{}\label{ecore_evas_buffer_example_01_8c-example}
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#ifdef\ HAVE\_CONFIG\_H}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ "{}config.h"{}}}
\DoxyCodeLine{\textcolor{preprocessor}{\#else}}
\DoxyCodeLine{\textcolor{preprocessor}{\#define\ EINA\_UNUSED}}
\DoxyCodeLine{\textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <\mbox{\hyperlink{Ecore__Evas_8h}{Ecore\_Evas.h}}>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <stdio.h>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#define\ WIDTH\ \ (320)}}
\DoxyCodeLine{\textcolor{preprocessor}{\#define\ HEIGHT\ (240)}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ Ecore\_Evas\ *ee;}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{comment}{/*\ support\ function\ to\ save\ scene\ as\ PPM\ image\ */}}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_scene\_save(Evas\ *canvas,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *dest)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{unsigned}\ \textcolor{keywordtype}{int}\ *pixels,\ *pixels\_end;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{int}\ width,\ height;}
\DoxyCodeLine{\ \ \ FILE\ *f;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Canvas_ga9db9974a647850d7bd49afb506c9717a}{evas\_output\_size\_get}}(canvas,\ \&width,\ \&height);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ f\ =\ fopen(dest,\ \textcolor{stringliteral}{"{}wb+"{}});}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!f)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}ERROR:\ could\ not\ open\ for\ writing\ '\%s':\ \%s\(\backslash\)n"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ dest,\ strerror(errno));}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return};}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ pixels\ =\ \mbox{\hyperlink{group__Ecore__Evas__Group_gadb3a75f7fd11a63551573373e5ab30c4}{ecore\_evas\_buffer\_pixels\_get}}(ee);}
\DoxyCodeLine{\ \ \ pixels\_end\ =\ pixels\ +\ (width\ *\ height);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{comment}{/*\ PPM\ P6\ format\ is\ dead\ simple\ to\ write:\ */}}
\DoxyCodeLine{\ \ \ fprintf(f,\ \textcolor{stringliteral}{"{}P6\(\backslash\)n\%d\ \%d\(\backslash\)n255\(\backslash\)n"{}},\ width,\ height);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{for}\ (;\ pixels\ <\ pixels\_end;\ pixels++)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ r,\ g,\ b;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ r\ =\ ((*pixels)\ \&\ 0xff0000)\ >>\ 16;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ g\ =\ ((*pixels)\ \&\ 0x00ff00)\ >>\ 8;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ b\ =\ (*pixels)\ \&\ 0x0000ff;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ fprintf(f,\ \textcolor{stringliteral}{"{}\%c\%c\%c"{}},\ r,\ g,\ b);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ fclose(f);}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}Saved\ scene\ as\ '\%s'\(\backslash\)n"{}},\ dest);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{int}}
\DoxyCodeLine{main(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ Evas\ *canvas;}
\DoxyCodeLine{\ \ \ Evas\_Object\ *bg,\ *r1,\ *r2,\ *r3;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Evas__Group_ga32ddbb6457033ad435a177eb0c4fe235}{ecore\_evas\_init}}();}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ ee\ =\ \mbox{\hyperlink{group__Ecore__Evas__Group_gab5e52f58b90c0789138f5443f02e23a2}{ecore\_evas\_buffer\_new}}(WIDTH,\ HEIGHT);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!ee)\ \textcolor{keywordflow}{goto}\ error;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ canvas\ =\ \mbox{\hyperlink{group__Ecore__Evas__Group_ga6f8d214cd55bc940d7cc62fecd8dbc06}{ecore\_evas\_get}}(ee);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ bg\ =\ \mbox{\hyperlink{group__Evas__Object__Rectangle_ga1b7a9d8e6ce240590c1734da5f3449d2}{evas\_object\_rectangle\_add}}(canvas);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_gab751e9d24c16e74af6f7c08ea5b930c2}{evas\_object\_color\_set}}(bg,\ 255,\ 255,\ 255,\ 255);\ \textcolor{comment}{/*\ white\ bg\ */}}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga335c8ee6eaeaac9710656af4f8b0db91}{evas\_object\_move}}(bg,\ 0,\ 0);\ \textcolor{comment}{/*\ at\ origin\ */}}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(bg,\ WIDTH,\ HEIGHT);\ \textcolor{comment}{/*\ covers\ full\ canvas\ */}}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(bg);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ r1\ =\ \mbox{\hyperlink{group__Evas__Object__Rectangle_ga1b7a9d8e6ce240590c1734da5f3449d2}{evas\_object\_rectangle\_add}}(canvas);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_gab751e9d24c16e74af6f7c08ea5b930c2}{evas\_object\_color\_set}}(r1,\ 255,\ 0,\ 0,\ 255);\ \textcolor{comment}{/*\ 100\%\ opaque\ red\ */}}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga335c8ee6eaeaac9710656af4f8b0db91}{evas\_object\_move}}(r1,\ 10,\ 10);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(r1,\ 100,\ 100);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(r1);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ r2\ =\ \mbox{\hyperlink{group__Evas__Object__Rectangle_ga1b7a9d8e6ce240590c1734da5f3449d2}{evas\_object\_rectangle\_add}}(canvas);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_gab751e9d24c16e74af6f7c08ea5b930c2}{evas\_object\_color\_set}}(r2,\ 0,\ 128,\ 0,\ 128);\ \textcolor{comment}{/*\ 50\%\ opaque\ green\ */}}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga335c8ee6eaeaac9710656af4f8b0db91}{evas\_object\_move}}(r2,\ 10,\ 10);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(r2,\ 50,\ 50);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(r2);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ r3\ =\ \mbox{\hyperlink{group__Evas__Object__Rectangle_ga1b7a9d8e6ce240590c1734da5f3449d2}{evas\_object\_rectangle\_add}}(canvas);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_gab751e9d24c16e74af6f7c08ea5b930c2}{evas\_object\_color\_set}}(r3,\ 0,\ 128,\ 0,\ 255);\ \textcolor{comment}{/*\ 100\%\ opaque\ dark\ green\ */}}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga335c8ee6eaeaac9710656af4f8b0db91}{evas\_object\_move}}(r3,\ 60,\ 60);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(r3,\ 50,\ 50);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(r3);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Evas__Group_ga93a1c660785fbb2ded46e2bd184e1c04}{ecore\_evas\_manual\_render}}(ee);}
\DoxyCodeLine{\ \ \ \_scene\_save(canvas,\ \textcolor{stringliteral}{"{}/tmp/evas-\/buffer-\/simple-\/render.ppm"{}});}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Evas__Group_gad3ec61f2aa03df4d3dbfd0d311e0c8dc}{ecore\_evas\_free}}(ee);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}}();}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{}
\DoxyCodeLine{error:}
\DoxyCodeLine{\ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}error:\ Requires\ at\ least\ one\ Evas\ engine\ built"{}}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}\ and\ linked\ to\ ecore-\/evas\ for\ this\ example\ to\ run"{}}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}\ properly.\(\backslash\)n"{}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}}();}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{\}}
\DoxyCodeLine{}

\end{DoxyCodeInclude}
 