\hypertarget{group__Evas__Utils}{\section{General Utilities}
\label{group__Evas__Utils}\index{General Utilities@{General Utilities}}
}


Some functions that are handy but are not specific of canvas or objects.  


\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
const char $\ast$ \hyperlink{group__Evas__Utils_gaca3384642e5ebb32cfeab24c760c739a}{evas\+\_\+load\+\_\+error\+\_\+str} (Evas\+\_\+\+Load\+\_\+\+Error error)
\begin{DoxyCompactList}\small\item\em Converts the given Evas image load error code into a string describing it in english. \end{DoxyCompactList}\item 
void \hyperlink{group__Evas__Utils_ga143f983570c36917783a6b1a3b341bf5}{evas\+\_\+color\+\_\+hsv\+\_\+to\+\_\+rgb} (float h, float s, float v, int $\ast$r, int $\ast$g, int $\ast$b)
\begin{DoxyCompactList}\small\item\em Convert a given color from H\+S\+V to R\+G\+B format. \end{DoxyCompactList}\item 
void \hyperlink{group__Evas__Utils_gaa8711329d10e34fc8a3221598afe7a91}{evas\+\_\+color\+\_\+rgb\+\_\+to\+\_\+hsv} (int r, int g, int b, float $\ast$h, float $\ast$s, float $\ast$v)
\begin{DoxyCompactList}\small\item\em Convert a given color from R\+G\+B to H\+S\+V format. \end{DoxyCompactList}\item 
void \hyperlink{group__Evas__Utils_gac02bf3973675ae7591b9f34deef1554f}{evas\+\_\+color\+\_\+argb\+\_\+premul} (int a, int $\ast$r, int $\ast$g, int $\ast$b)
\begin{DoxyCompactList}\small\item\em Pre-\/multiplies a rgb triplet by an alpha factor. \end{DoxyCompactList}\item 
void \hyperlink{group__Evas__Utils_ga862abed1097a429dd439fbe08813cd9d}{evas\+\_\+color\+\_\+argb\+\_\+unpremul} (int a, int $\ast$r, int $\ast$g, int $\ast$b)
\begin{DoxyCompactList}\small\item\em Undo pre-\/multiplication of a rgb triplet by an alpha factor. \end{DoxyCompactList}\item 
void \hyperlink{group__Evas__Utils_ga6728112a26090165c5e4a1a6bf71ffb1}{evas\+\_\+data\+\_\+argb\+\_\+premul} (unsigned int $\ast$data, unsigned int len)
\begin{DoxyCompactList}\small\item\em Pre-\/multiplies data by an alpha factor. \end{DoxyCompactList}\item 
void \hyperlink{group__Evas__Utils_gafdab034f277f25c3cd0195f4e7fbb38d}{evas\+\_\+data\+\_\+argb\+\_\+unpremul} (unsigned int $\ast$data, unsigned int len)
\begin{DoxyCompactList}\small\item\em Undo pre-\/multiplication data by an alpha factor. \end{DoxyCompactList}\item 
int \hyperlink{group__Evas__Utils_ga044cd250a33c2d994b2c5d3d31e3f413}{evas\+\_\+string\+\_\+char\+\_\+next\+\_\+get} (const char $\ast$str, int pos, int $\ast$decoded)
\begin{DoxyCompactList}\small\item\em Gets the next character in the string. \end{DoxyCompactList}\item 
int \hyperlink{group__Evas__Utils_gab7c9b92ab4ccb14a3391f1fa884bae24}{evas\+\_\+string\+\_\+char\+\_\+prev\+\_\+get} (const char $\ast$str, int pos, int $\ast$decoded)
\begin{DoxyCompactList}\small\item\em Gets the previous character in the string. \end{DoxyCompactList}\item 
int \hyperlink{group__Evas__Utils_gadfcfcae8546f2d7f6c14c5e1b17b8446}{evas\+\_\+string\+\_\+char\+\_\+len\+\_\+get} (const char $\ast$str)
\begin{DoxyCompactList}\small\item\em Get the length in characters of the string. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Some functions that are handy but are not specific of canvas or objects. 



\subsection{Function Documentation}
\hypertarget{group__Evas__Utils_gaca3384642e5ebb32cfeab24c760c739a}{\index{General Utilities@{General Utilities}!evas\+\_\+load\+\_\+error\+\_\+str@{evas\+\_\+load\+\_\+error\+\_\+str}}
\index{evas\+\_\+load\+\_\+error\+\_\+str@{evas\+\_\+load\+\_\+error\+\_\+str}!General Utilities@{General Utilities}}
\subsubsection[{evas\+\_\+load\+\_\+error\+\_\+str}]{\setlength{\rightskip}{0pt plus 5cm}const char$\ast$ evas\+\_\+load\+\_\+error\+\_\+str (
\begin{DoxyParamCaption}
\item[{Evas\+\_\+\+Load\+\_\+\+Error}]{error}
\end{DoxyParamCaption}
)}}\label{group__Evas__Utils_gaca3384642e5ebb32cfeab24c760c739a}


Converts the given Evas image load error code into a string describing it in english. 


\begin{DoxyParams}{Parameters}
{\em error} & the error code, a value in \+::\+Evas\+\_\+\+Load\+\_\+\+Error. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Always returns a valid string. If the given {\ttfamily error} is not supported, {\ttfamily \char`\"{}\+Unknown error\char`\"{}} is returned.
\end{DoxyReturn}
Mostly \hyperlink{group__Evas__Object__Image_gac27fd0ceabe5f56607b7a86d71577df1}{evas\+\_\+object\+\_\+image\+\_\+file\+\_\+set()} would be the function setting that error value afterwards, but also evas\+\_\+object\+\_\+image\+\_\+load(), \hyperlink{group__Evas__Object__Image_ga8bd6201d1b5c5f0e65600b491c6557e4}{evas\+\_\+object\+\_\+image\+\_\+save()}, evas\+\_\+object\+\_\+image\+\_\+data\+\_\+get(), evas\+\_\+object\+\_\+image\+\_\+data\+\_\+convert(), evas\+\_\+object\+\_\+image\+\_\+pixels\+\_\+import() and evas\+\_\+object\+\_\+image\+\_\+is\+\_\+inside(). This function is meant to be used in conjunction with evas\+\_\+object\+\_\+image\+\_\+load\+\_\+error\+\_\+get(), as in\+:

Example code\+:  
\begin{DoxyCodeInclude}
1    d.img1 = evas\_object\_image\_add(d.evas);
2    evas\_object\_image\_file\_set(d.img1, valid\_path, NULL);
3    err = evas\_object\_image\_load\_error\_get(d.img1);
4    if (err != EVAS\_LOAD\_ERROR\_NONE)
5      \{
6         fprintf(stderr, "could not load image '%s'. error string is \(\backslash\)"%s\(\backslash\)"\(\backslash\)n",
7                 valid\_path, evas\_load\_error\_str(err));
8      \}
9    else
10      \{
11         fprintf(stdout,
12                 "loaded image '%s' with succes! error string is \(\backslash\)"%s\(\backslash\)"\(\backslash\)n",
13                 valid\_path, evas\_load\_error\_str(err));
14 
15         evas\_object\_move(d.img1, 3, 3);
16         evas\_object\_image\_fill\_set(d.img1, 0, 0, WIDTH / 2, HEIGHT / 2);
17         evas\_object\_resize(d.img1, WIDTH / 2, HEIGHT / 2);
18         evas\_object\_show(d.img1);
19 
20         evas\_object\_focus\_set(d.bg, EINA\_TRUE);
21         evas\_object\_event\_callback\_add(
22           d.bg, EVAS\_CALLBACK\_KEY\_DOWN, \_on\_keydown, NULL);
23      \}
24 
25    /* this is a border around the image above, here just to emphasize
26     * its geometry */
27    d.border = evas\_object\_image\_filled\_add(d.evas);
28    evas\_object\_image\_file\_set(d.border, border\_img\_path, NULL);
29    evas\_object\_image\_border\_set(d.border, 3, 3, 3, 3);
30    evas\_object\_image\_border\_center\_fill\_set(d.border, EVAS\_BORDER\_FILL\_NONE);
31 
32    evas\_object\_move(d.border, 0, 0);
33    evas\_object\_resize(d.border, (WIDTH / 2) + 6, (HEIGHT / 2) + 6);
34    evas\_object\_show(d.border);
35 
36    /* image loading will fail for this one -- unless one cheats and
37     * puts a valid image on that path */
38    d.img2 = evas\_object\_image\_add(d.evas);
39    evas\_object\_image\_file\_set(d.img2, bogus\_path, NULL);
40    err = evas\_object\_image\_load\_error\_get(d.img2);
41    if (err != EVAS\_LOAD\_ERROR\_NONE)
42      \{
43         fprintf(stderr, "could not load image '%s': error string is \(\backslash\)"%s\(\backslash\)"\(\backslash\)n",
44                 bogus\_path, evas\_load\_error\_str(err));
45      \}
46    else
47      \{
48         evas\_object\_move(d.img2, WIDTH / 2, HEIGHT / 2);
49         evas\_object\_image\_fill\_set(d.img2, 0, 0, WIDTH / 2, HEIGHT / 2);
50         evas\_object\_resize(d.img2, WIDTH / 2, HEIGHT / 2);
51         evas\_object\_show(d.img2);
52      \}
53 
54    fprintf(stdout, commands);
55    ecore\_main\_loop\_begin();

\end{DoxyCodeInclude}


Here, being {\ttfamily valid\+\_\+path} the path to a valid image and {\ttfamily bogus\+\_\+path} a path to a file which does not exist, the two outputs of \hyperlink{group__Evas__Utils_gaca3384642e5ebb32cfeab24c760c739a}{evas\+\_\+load\+\_\+error\+\_\+str()} would be (if no other errors occur)\+: {\ttfamily \char`\"{}\+No error on load\char`\"{}} and {\ttfamily \char`\"{}\+File (or file path) does
not exist\char`\"{}}, respectively. See the full \hyperlink{Example_Evas_Images}{example}. \hypertarget{group__Evas__Utils_ga143f983570c36917783a6b1a3b341bf5}{\index{General Utilities@{General Utilities}!evas\+\_\+color\+\_\+hsv\+\_\+to\+\_\+rgb@{evas\+\_\+color\+\_\+hsv\+\_\+to\+\_\+rgb}}
\index{evas\+\_\+color\+\_\+hsv\+\_\+to\+\_\+rgb@{evas\+\_\+color\+\_\+hsv\+\_\+to\+\_\+rgb}!General Utilities@{General Utilities}}
\subsubsection[{evas\+\_\+color\+\_\+hsv\+\_\+to\+\_\+rgb}]{\setlength{\rightskip}{0pt plus 5cm}void evas\+\_\+color\+\_\+hsv\+\_\+to\+\_\+rgb (
\begin{DoxyParamCaption}
\item[{float}]{h, }
\item[{float}]{s, }
\item[{float}]{v, }
\item[{int $\ast$}]{r, }
\item[{int $\ast$}]{g, }
\item[{int $\ast$}]{b}
\end{DoxyParamCaption}
)}}\label{group__Evas__Utils_ga143f983570c36917783a6b1a3b341bf5}


Convert a given color from H\+S\+V to R\+G\+B format. 


\begin{DoxyParams}{Parameters}
{\em h} & The Hue component of the color. \\
\hline
{\em s} & The Saturation component of the color. \\
\hline
{\em v} & The Value component of the color. \\
\hline
{\em r} & The Red component of the color. \\
\hline
{\em g} & The Green component of the color. \\
\hline
{\em b} & The Blue component of the color.\\
\hline
\end{DoxyParams}
This function converts a given color in H\+S\+V color format to R\+G\+B color format. \hypertarget{group__Evas__Utils_gaa8711329d10e34fc8a3221598afe7a91}{\index{General Utilities@{General Utilities}!evas\+\_\+color\+\_\+rgb\+\_\+to\+\_\+hsv@{evas\+\_\+color\+\_\+rgb\+\_\+to\+\_\+hsv}}
\index{evas\+\_\+color\+\_\+rgb\+\_\+to\+\_\+hsv@{evas\+\_\+color\+\_\+rgb\+\_\+to\+\_\+hsv}!General Utilities@{General Utilities}}
\subsubsection[{evas\+\_\+color\+\_\+rgb\+\_\+to\+\_\+hsv}]{\setlength{\rightskip}{0pt plus 5cm}void evas\+\_\+color\+\_\+rgb\+\_\+to\+\_\+hsv (
\begin{DoxyParamCaption}
\item[{int}]{r, }
\item[{int}]{g, }
\item[{int}]{b, }
\item[{float $\ast$}]{h, }
\item[{float $\ast$}]{s, }
\item[{float $\ast$}]{v}
\end{DoxyParamCaption}
)}}\label{group__Evas__Utils_gaa8711329d10e34fc8a3221598afe7a91}


Convert a given color from R\+G\+B to H\+S\+V format. 


\begin{DoxyParams}{Parameters}
{\em r} & The Red component of the color. \\
\hline
{\em g} & The Green component of the color. \\
\hline
{\em b} & The Blue component of the color. \\
\hline
{\em h} & The Hue component of the color. \\
\hline
{\em s} & The Saturation component of the color. \\
\hline
{\em v} & The Value component of the color.\\
\hline
\end{DoxyParams}
This function converts a given color in R\+G\+B color format to H\+S\+V color format. \hypertarget{group__Evas__Utils_gac02bf3973675ae7591b9f34deef1554f}{\index{General Utilities@{General Utilities}!evas\+\_\+color\+\_\+argb\+\_\+premul@{evas\+\_\+color\+\_\+argb\+\_\+premul}}
\index{evas\+\_\+color\+\_\+argb\+\_\+premul@{evas\+\_\+color\+\_\+argb\+\_\+premul}!General Utilities@{General Utilities}}
\subsubsection[{evas\+\_\+color\+\_\+argb\+\_\+premul}]{\setlength{\rightskip}{0pt plus 5cm}void evas\+\_\+color\+\_\+argb\+\_\+premul (
\begin{DoxyParamCaption}
\item[{int}]{a, }
\item[{int $\ast$}]{r, }
\item[{int $\ast$}]{g, }
\item[{int $\ast$}]{b}
\end{DoxyParamCaption}
)}}\label{group__Evas__Utils_gac02bf3973675ae7591b9f34deef1554f}


Pre-\/multiplies a rgb triplet by an alpha factor. 


\begin{DoxyParams}{Parameters}
{\em a} & The alpha factor. \\
\hline
{\em r} & The Red component of the color. \\
\hline
{\em g} & The Green component of the color. \\
\hline
{\em b} & The Blue component of the color.\\
\hline
\end{DoxyParams}
This function pre-\/multiplies a given rgb triplet by an alpha factor. Alpha factor is used to define transparency. \hypertarget{group__Evas__Utils_ga862abed1097a429dd439fbe08813cd9d}{\index{General Utilities@{General Utilities}!evas\+\_\+color\+\_\+argb\+\_\+unpremul@{evas\+\_\+color\+\_\+argb\+\_\+unpremul}}
\index{evas\+\_\+color\+\_\+argb\+\_\+unpremul@{evas\+\_\+color\+\_\+argb\+\_\+unpremul}!General Utilities@{General Utilities}}
\subsubsection[{evas\+\_\+color\+\_\+argb\+\_\+unpremul}]{\setlength{\rightskip}{0pt plus 5cm}void evas\+\_\+color\+\_\+argb\+\_\+unpremul (
\begin{DoxyParamCaption}
\item[{int}]{a, }
\item[{int $\ast$}]{r, }
\item[{int $\ast$}]{g, }
\item[{int $\ast$}]{b}
\end{DoxyParamCaption}
)}}\label{group__Evas__Utils_ga862abed1097a429dd439fbe08813cd9d}


Undo pre-\/multiplication of a rgb triplet by an alpha factor. 


\begin{DoxyParams}{Parameters}
{\em a} & The alpha factor. \\
\hline
{\em r} & The Red component of the color. \\
\hline
{\em g} & The Green component of the color. \\
\hline
{\em b} & The Blue component of the color.\\
\hline
\end{DoxyParams}
This function undoes pre-\/multiplication a given rbg triplet by an alpha factor. Alpha factor is used to define transparency.

\begin{DoxySeeAlso}{See also}
\hyperlink{group__Evas__Utils_gac02bf3973675ae7591b9f34deef1554f}{evas\+\_\+color\+\_\+argb\+\_\+premul()}. 
\end{DoxySeeAlso}
\hypertarget{group__Evas__Utils_ga6728112a26090165c5e4a1a6bf71ffb1}{\index{General Utilities@{General Utilities}!evas\+\_\+data\+\_\+argb\+\_\+premul@{evas\+\_\+data\+\_\+argb\+\_\+premul}}
\index{evas\+\_\+data\+\_\+argb\+\_\+premul@{evas\+\_\+data\+\_\+argb\+\_\+premul}!General Utilities@{General Utilities}}
\subsubsection[{evas\+\_\+data\+\_\+argb\+\_\+premul}]{\setlength{\rightskip}{0pt plus 5cm}void evas\+\_\+data\+\_\+argb\+\_\+premul (
\begin{DoxyParamCaption}
\item[{unsigned int $\ast$}]{data, }
\item[{unsigned int}]{len}
\end{DoxyParamCaption}
)}}\label{group__Evas__Utils_ga6728112a26090165c5e4a1a6bf71ffb1}


Pre-\/multiplies data by an alpha factor. 


\begin{DoxyParams}{Parameters}
{\em data} & The data value. \\
\hline
{\em len} & The length value.\\
\hline
\end{DoxyParams}
This function pre-\/multiplies a given data by an alpha factor. Alpha factor is used to define transparency. \hypertarget{group__Evas__Utils_gafdab034f277f25c3cd0195f4e7fbb38d}{\index{General Utilities@{General Utilities}!evas\+\_\+data\+\_\+argb\+\_\+unpremul@{evas\+\_\+data\+\_\+argb\+\_\+unpremul}}
\index{evas\+\_\+data\+\_\+argb\+\_\+unpremul@{evas\+\_\+data\+\_\+argb\+\_\+unpremul}!General Utilities@{General Utilities}}
\subsubsection[{evas\+\_\+data\+\_\+argb\+\_\+unpremul}]{\setlength{\rightskip}{0pt plus 5cm}void evas\+\_\+data\+\_\+argb\+\_\+unpremul (
\begin{DoxyParamCaption}
\item[{unsigned int $\ast$}]{data, }
\item[{unsigned int}]{len}
\end{DoxyParamCaption}
)}}\label{group__Evas__Utils_gafdab034f277f25c3cd0195f4e7fbb38d}


Undo pre-\/multiplication data by an alpha factor. 


\begin{DoxyParams}{Parameters}
{\em data} & The data value. \\
\hline
{\em len} & The length value.\\
\hline
\end{DoxyParams}
This function undoes pre-\/multiplication of a given data by an alpha factor. Alpha factor is used to define transparency. \hypertarget{group__Evas__Utils_ga044cd250a33c2d994b2c5d3d31e3f413}{\index{General Utilities@{General Utilities}!evas\+\_\+string\+\_\+char\+\_\+next\+\_\+get@{evas\+\_\+string\+\_\+char\+\_\+next\+\_\+get}}
\index{evas\+\_\+string\+\_\+char\+\_\+next\+\_\+get@{evas\+\_\+string\+\_\+char\+\_\+next\+\_\+get}!General Utilities@{General Utilities}}
\subsubsection[{evas\+\_\+string\+\_\+char\+\_\+next\+\_\+get}]{\setlength{\rightskip}{0pt plus 5cm}int evas\+\_\+string\+\_\+char\+\_\+next\+\_\+get (
\begin{DoxyParamCaption}
\item[{const char $\ast$}]{str, }
\item[{int}]{pos, }
\item[{int $\ast$}]{decoded}
\end{DoxyParamCaption}
)}}\label{group__Evas__Utils_ga044cd250a33c2d994b2c5d3d31e3f413}


Gets the next character in the string. 

Given the U\+T\+F-\/8 string in {\ttfamily str}, and starting byte position in {\ttfamily pos}, this function will place in {\ttfamily decoded} the decoded code point at {\ttfamily pos} and return the byte index for the next character in the string.

The only boundary check done is that {\ttfamily pos} must be $>$= 0. Other than that, no checks are performed, so passing an index value that's not within the length of the string will result in undefined behavior.


\begin{DoxyParams}{Parameters}
{\em str} & The U\+T\+F-\/8 string \\
\hline
{\em pos} & The byte index where to start \\
\hline
{\em decoded} & Address where to store the decoded code point. Optional.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The byte index of the next character 
\end{DoxyReturn}


References eina\+\_\+unicode\+\_\+utf8\+\_\+next\+\_\+get().

\hypertarget{group__Evas__Utils_gab7c9b92ab4ccb14a3391f1fa884bae24}{\index{General Utilities@{General Utilities}!evas\+\_\+string\+\_\+char\+\_\+prev\+\_\+get@{evas\+\_\+string\+\_\+char\+\_\+prev\+\_\+get}}
\index{evas\+\_\+string\+\_\+char\+\_\+prev\+\_\+get@{evas\+\_\+string\+\_\+char\+\_\+prev\+\_\+get}!General Utilities@{General Utilities}}
\subsubsection[{evas\+\_\+string\+\_\+char\+\_\+prev\+\_\+get}]{\setlength{\rightskip}{0pt plus 5cm}int evas\+\_\+string\+\_\+char\+\_\+prev\+\_\+get (
\begin{DoxyParamCaption}
\item[{const char $\ast$}]{str, }
\item[{int}]{pos, }
\item[{int $\ast$}]{decoded}
\end{DoxyParamCaption}
)}}\label{group__Evas__Utils_gab7c9b92ab4ccb14a3391f1fa884bae24}


Gets the previous character in the string. 

Given the U\+T\+F-\/8 string in {\ttfamily str}, and starting byte position in {\ttfamily pos}, this function will place in {\ttfamily decoded} the decoded code point at {\ttfamily pos} and return the byte index for the previous character in the string.

The only boundary check done is that {\ttfamily pos} must be $>$= 1. Other than that, no checks are performed, so passing an index value that's not within the length of the string will result in undefined behavior.


\begin{DoxyParams}{Parameters}
{\em str} & The U\+T\+F-\/8 string \\
\hline
{\em pos} & The byte index where to start \\
\hline
{\em decoded} & Address where to store the decoded code point. Optional.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The byte index of the previous character 
\end{DoxyReturn}


References eina\+\_\+unicode\+\_\+utf8\+\_\+get\+\_\+prev().

\hypertarget{group__Evas__Utils_gadfcfcae8546f2d7f6c14c5e1b17b8446}{\index{General Utilities@{General Utilities}!evas\+\_\+string\+\_\+char\+\_\+len\+\_\+get@{evas\+\_\+string\+\_\+char\+\_\+len\+\_\+get}}
\index{evas\+\_\+string\+\_\+char\+\_\+len\+\_\+get@{evas\+\_\+string\+\_\+char\+\_\+len\+\_\+get}!General Utilities@{General Utilities}}
\subsubsection[{evas\+\_\+string\+\_\+char\+\_\+len\+\_\+get}]{\setlength{\rightskip}{0pt plus 5cm}int evas\+\_\+string\+\_\+char\+\_\+len\+\_\+get (
\begin{DoxyParamCaption}
\item[{const char $\ast$}]{str}
\end{DoxyParamCaption}
)}}\label{group__Evas__Utils_gadfcfcae8546f2d7f6c14c5e1b17b8446}


Get the length in characters of the string. 


\begin{DoxyParams}{Parameters}
{\em str} & The string to get the length of. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The length in characters (not bytes) 
\end{DoxyReturn}


References eina\+\_\+unicode\+\_\+utf8\+\_\+get\+\_\+len().

