\section{photocam\-\_\-example\-\_\-01.\-c}

\begin{DoxyCodeInclude}
\textcolor{comment}{//Compile with:}
\textcolor{comment}{//gcc -o photocam\_example\_01 photocam\_example\_01.c -g `pkg-config --cflags --libs elementary`
       -DDATA\_DIR="\(\backslash\)"<directory>\(\backslash\)""}
\textcolor{comment}{//where directory is the path where images/insanely\_huge\_test\_image.jpg can be found.}

\textcolor{preprocessor}{#include <Elementary.h>}

\textcolor{keyword}{static} \textcolor{keywordtype}{void} \_fit(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info);
\textcolor{keyword}{static} \textcolor{keywordtype}{void} \_unfit(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info);
\textcolor{keyword}{static} \textcolor{keywordtype}{void} \_zoom(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info);
\textcolor{keyword}{static} \textcolor{keywordtype}{void} \_bring\_in(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info);

EAPI\_MAIN \textcolor{keywordtype}{int}
elm\_main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} **argv)
\{
   Evas\_Object *win, *obj, *photocam;
   \textcolor{keywordtype}{char} buf[PATH\_MAX];

   elm_app_info_set(elm\_main, \textcolor{stringliteral}{"elementary"}, \textcolor{stringliteral}{"images/insanely\_huge\_test\_image.jpg"});
   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);

   win = elm_win_util_standard_add(\textcolor{stringliteral}{"photocam"}, \textcolor{stringliteral}{"Photocam"});
   elm_win_autodel_set(win, EINA\_TRUE);

   photocam = elm_photocam_add(win);
   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);
   elm_scroller_bounce_set(photocam, EINA\_FALSE, EINA\_TRUE);
   evas\_object\_smart\_callback\_add(photocam, \textcolor{stringliteral}{"loaded,detail"}, \_bring\_in, NULL);
   evas\_object\_resize(photocam, 500, 400);
   evas\_object\_show(photocam);

   obj = elm_button_add(win);
   elm\_object\_text\_set(obj, \textcolor{stringliteral}{"Fit"});
   evas\_object\_show(obj);
   evas\_object\_resize(obj, 50, 30);
   evas\_object\_move(obj, 10, 410);
   evas\_object\_smart\_callback\_add(obj, \textcolor{stringliteral}{"clicked"}, \_fit, photocam);

   obj = elm_button_add(win);
   elm\_object\_text\_set(obj, \textcolor{stringliteral}{"Unfit"});
   evas\_object\_show(obj);
   evas\_object\_resize(obj, 70, 30);
   evas\_object\_move(obj, 70, 410);
   evas\_object\_smart\_callback\_add(obj, \textcolor{stringliteral}{"clicked"}, \_unfit, photocam);

   obj = elm_slider_add(win);
   elm\_object\_text\_set(obj, \textcolor{stringliteral}{"Zoom"});
   evas\_object\_show(obj);
   evas\_object\_resize(obj, 300, 30);
   evas\_object\_move(obj, 150, 410);
   evas\_object\_smart\_callback\_add(obj, \textcolor{stringliteral}{"changed"}, \_zoom, photocam);

   evas\_object\_resize(win, 500, 440);
   evas\_object\_show(win);

   elm_run();
   elm_shutdown();

   \textcolor{keywordflow}{return} 0;
\}
ELM_MAIN()

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);
\}

\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);
   elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT);
\}

\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);
\}

\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}
 