

This example is as simple as possible. An image object will be added to the window over a white background, and set to be resizable together with the window. All the options set through the example will affect the behavior of this image.

We start with the code for creating a window and its background, and also add the code to write the path to the image that will be loaded\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{keywordtype}{int}}
\DoxyCodeLine{elm\_main(\textcolor{keywordtype}{int}\ argc\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keywordtype}{char}\ **argv\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *win,\ *image;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{char}\ buf[PATH\_MAX];}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__App_ga0cefb59efb95841232561d67e34d9909}{elm\_app\_info\_set}}(elm\_main,\ \textcolor{stringliteral}{"{}elementary"{}},\ \textcolor{stringliteral}{"{}images/plant\_01.jpg"{}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__General_ga7a05f37fd3a019da5e26c5fc91fcd937}{elm\_policy\_set}}(\mbox{\hyperlink{group__Elm__General_ggaa16f3378ecdbf660fa378402e3c5a0a9a02fadb6faada04b19d0fa42c11a8d32a}{ELM\_POLICY\_QUIT}},\ \mbox{\hyperlink{group__Elm__General_gga46af37e6ac2c406321060be827117196abbe0962d88ae12afe1a173da881f56cd}{ELM\_POLICY\_QUIT\_LAST\_WINDOW\_CLOSED}});}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ win\ =\ \mbox{\hyperlink{group__Elm__Win__Group_ga23d9d1ffa0a65a1a1dd482d570db1ba0}{elm\_win\_util\_standard\_add}}(\textcolor{stringliteral}{"{}image"{}},\ \textcolor{stringliteral}{"{}Image"{}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Win__Group_ga9a16a2f8c9fd5b6e9203ed9dcb53ea8b}{elm\_win\_autodel\_set}}(win,\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ snprintf(buf,\ \textcolor{keyword}{sizeof}(buf),\ \textcolor{stringliteral}{"{}\%s/images/plant\_01.jpg"{}},\ \mbox{\hyperlink{group__Elm__App_gab10cf98c5aa3936dfda01d6bca366d09}{elm\_app\_data\_dir\_get}}());}

\end{DoxyCodeInclude}
 Now we create the image object, and set that file to be loaded\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ image\ =\ \mbox{\hyperlink{group__Elm__Image_ga1e320bab8a343c91522d0f09b938ab4f}{elm\_image\_add}}(win);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!\mbox{\hyperlink{group__Elm__Image_gad1a96ede5f513042cef3c1dac4572f73}{elm\_image\_file\_set}}(image,\ buf,\ NULL))}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}error:\ could\ not\ load\ image\ \(\backslash\)"{}\%s\(\backslash\)"{}\(\backslash\)n"{}},\ buf);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{\ \ \ \ \ \}}

\end{DoxyCodeInclude}
 We can now go setting our options.

\mbox{\hyperlink{group__Elm__Image_ga1fad143fc34d81e888e3c5f85c6005db}{elm\+\_\+image\+\_\+no\+\_\+scale\+\_\+set()}} is used just to set this value to true (we don\textquotesingle{}t want to scale our image anyway, just resize it).

\mbox{\hyperlink{group__Elm__Image_ga6a389436a18e590fff5b6f6b81c72722}{elm\+\_\+image\+\_\+resizable\+\_\+set()}} is used to allow the image to be resized to a size smaller than the original one, but not to a size bigger than it.

\mbox{\hyperlink{group__Elm__Image_ga9b8c946f4abbcd09f0b9de0b9026505f}{elm\+\_\+image\+\_\+smooth\+\_\+set()}} will disable the smooth scaling, so the scale algorithm used to scale the image to the new object size is going to be faster, but with a lower quality.

\mbox{\hyperlink{group__Elm__Image_ga9f9afe7bc41c23f0412cba2c6d28ac65}{elm\+\_\+image\+\_\+orient\+\_\+set()}} is used to flip the image around the (1, 0) (0, 1) diagonal.

\mbox{\hyperlink{group__Elm__Image_gadd748c70384fb332aba9d0f3a9da2a50}{elm\+\_\+image\+\_\+aspect\+\_\+fixed\+\_\+set()}} is used to keep the original aspect ratio of the image, even when the window is resized to another aspect ratio.

\mbox{\hyperlink{group__Elm__Image_ga4c6c2fe6f609406329e2be2011574f94}{elm\+\_\+image\+\_\+fill\+\_\+outside\+\_\+set()}} is used to ensure that the image will fill the entire area available to it, even if keeping the aspect ratio. The image will overflow its width or height (any of them that is necessary) to the object area, instead of resizing the image down until it can fit entirely in this area.

\mbox{\hyperlink{group__Elm__Image_gaa58c91d1c9d19647608aa463c7ac3c98}{elm\+\_\+image\+\_\+editable\+\_\+set()}} is used just to cover the API, but won\textquotesingle{}t affect this example since we are not using any copy \& paste property.

This is the code for setting these options\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Image_ga1fad143fc34d81e888e3c5f85c6005db}{elm\_image\_no\_scale\_set}}(image,\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Image_ga6a389436a18e590fff5b6f6b81c72722}{elm\_image\_resizable\_set}}(image,\ \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}},\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Image_ga9b8c946f4abbcd09f0b9de0b9026505f}{elm\_image\_smooth\_set}}(image,\ \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Image_ga9f9afe7bc41c23f0412cba2c6d28ac65}{elm\_image\_orient\_set}}(image,\ \mbox{\hyperlink{group__Elm__Image_gga122509e6310e5d4aa25caa3ab0416daba86973dddb12f96b2cb7c1ed16044fcd2}{ELM\_IMAGE\_FLIP\_HORIZONTAL}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Image_gadd748c70384fb332aba9d0f3a9da2a50}{elm\_image\_aspect\_fixed\_set}}(image,\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Image_ga4c6c2fe6f609406329e2be2011574f94}{elm\_image\_fill\_outside\_set}}(image,\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Image_gaa58c91d1c9d19647608aa463c7ac3c98}{elm\_image\_editable\_set}}(image,\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}

\end{DoxyCodeInclude}
 Now some last touches in our object size hints, window and background, to display this image properly\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga9379629ad8ad2860aa786d838a4a106a}{evas\_object\_size\_hint\_weight\_set}}(image,\ \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}},\ \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Win__Group_ga505d6bd217e5ee01e82b548ec35986eb}{elm\_win\_resize\_object\_add}}(win,\ image);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(image);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(win,\ 320,\ 320);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(win);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__General_gadf2553f83e6b0b9c7fbe054019a664a1}{elm\_run}}();}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{\}}
\DoxyCodeLine{\mbox{\hyperlink{group__Elm__General_ga50fe52d513f7e89c9c770afd76de7ad9}{ELM\_MAIN}}()}

\end{DoxyCodeInclude}
 This example will look like this\+:

 
\begin{DoxyImageNoCaption}
  \mbox{\includegraphics[width=\textwidth]{screenshots/image_example_01}}
\end{DoxyImageNoCaption}
 