

In this example we will have a photocam and a couple of buttons and slider to control the photocam. To avoid cluttering we\textquotesingle{}ll only show the parts of the example that relate to the photocam, the full source code can be seen \hyperlink{photocam_example_01_8c-example}{here}.

Creating a photocam is as easy as creating any other widget\+: 
\begin{DoxyCodeInclude}
   photocam = elm_photocam_add(win);

\end{DoxyCodeInclude}


A photocam is only useful if we have a image on it, so lets set a file for it to work with\+: 
\begin{DoxyCodeInclude}
   snprintf(buf, \textcolor{keyword}{sizeof}(buf), \textcolor{stringliteral}{"%s/images/insanely\_huge\_test\_image.jpg"}, 
      elm_app_data_dir_get());
   elm_photocam_file_set(photocam, buf);

\end{DoxyCodeInclude}


We now set the photocam to not bounce horizontally\+: 
\begin{DoxyCodeInclude}
   elm_scroller_bounce_set(photocam, EINA\_FALSE, EINA\_TRUE);

\end{DoxyCodeInclude}


And we want to know when the photocam has finished loading the image so\+: 
\begin{DoxyCodeInclude}
   evas\_object\_smart\_callback\_add(photocam, \textcolor{stringliteral}{"loaded,detail"}, \_bring\_in, NULL);

\end{DoxyCodeInclude}


The reason to know when the image is loaded is so that we can bring the center of the image into view\+: 
\begin{DoxyCodeInclude}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_bring\_in(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   \textcolor{keywordtype}{int} w, h;
   elm\_photocam\_image\_size\_get(obj, &w, &h);
   elm_photocam_image_region_bring_in(obj, w/2, h/2, 500, 400);
\}

\end{DoxyCodeInclude}


As mentioned we have 2 buttons in this example, the \char`\"{}\+Fit\char`\"{} one will cause the photocam to go in to a zoom mode that makes the image fit inside the photocam. Tough this has no effect on the image we also print what region was being viewed before setting the zoom mode\+: 
\begin{DoxyCodeInclude}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_fit(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   \textcolor{keywordtype}{int} x, y, w, h;
   elm\_photocam\_image\_region\_get(data, &x, &y, &w, &h);
   printf(\textcolor{stringliteral}{"region: \{%d, %d, %d, %d\}\(\backslash\)n"}, x, y, w, h);

\end{DoxyCodeInclude}
 \begin{DoxyNote}{Note}
When in fit mode our slider(explained below) won\textquotesingle{}t work.
\end{DoxyNote}
The second button(\char`\"{}\+Unfit\char`\"{}) will bring the photocam back into manual zoom mode\+: 
\begin{DoxyCodeInclude}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_unfit(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   elm\_photocam\_zoom\_mode\_set(data, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
\}

\end{DoxyCodeInclude}


Our slider controls the level of zoom of the photocam\+: 
\begin{DoxyCodeInclude}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_zoom(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   \textcolor{keywordtype}{double} z = elm\_slider\_value\_get(obj) * 8;
   elm\_photocam\_zoom\_set(data, z);
\}

\end{DoxyCodeInclude}
 \begin{DoxyNote}{Note}
It is important to note that this only works when in manual zoom mode.
\end{DoxyNote}
Our example will initially look like this\+:

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