Functions
General Utilities

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

Functions

const char * evas_load_error_str (Evas_Load_Error error)
 Converts the given Evas image load error code into a string describing it in human-readable text. More...
 
void evas_color_hsv_to_rgb (float h, float s, float v, int *r, int *g, int *b)
 Convert a given color from HSV to RGB format. More...
 
void evas_color_rgb_to_hsv (int r, int g, int b, float *h, float *s, float *v)
 Convert a given color from RGB to HSV format. More...
 
void evas_color_argb_premul (int a, int *r, int *g, int *b)
 Pre-multiplies a rgb triplet by an alpha factor. More...
 
void evas_color_argb_unpremul (int a, int *r, int *g, int *b)
 Undo pre-multiplication of a rgb triplet by an alpha factor. More...
 
void evas_data_argb_premul (unsigned int *data, unsigned int len)
 Pre-multiplies data by an alpha factor. More...
 
void evas_data_argb_unpremul (unsigned int *data, unsigned int len)
 Undo pre-multiplication data by an alpha factor. More...
 
int evas_string_char_next_get (const char *str, int pos, int *decoded)
 Gets the next character in the string. More...
 
int evas_string_char_prev_get (const char *str, int pos, int *decoded)
 Gets the previous character in the string. More...
 
int evas_string_char_len_get (const char *str)
 Get the length in characters of the string. More...
 
Evas_BiDi_Direction evas_language_direction_get (void)
 Get language direction. More...
 
void evas_language_reinit (void)
 Reinitialize language from the environment. More...
 

Detailed Description

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

Function Documentation

◆ evas_load_error_str()

const char* evas_load_error_str ( Evas_Load_Error  error)

Converts the given Evas image load error code into a string describing it in human-readable text.

Parameters
errorthe error code, a value in Evas_Load_Error.
Returns
Always returns a valid string. If the given error is not supported, "Unknown error" is returned.

Mostly evas_object_image_file_set() would be the function setting that error value afterwards, but also evas_object_image_load(), 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:

d.img1 = evas_object_image_add(d.evas);
evas_object_image_file_set(d.img1, valid_path, NULL);
{
fprintf(stderr, "could not load image '%s'. error string is \"%s\"\n",
valid_path, evas_load_error_str(err));
}
else
{
printf("loaded image '%s' with succes! error string is \"%s\"\n",
valid_path, evas_load_error_str(err));
evas_object_move(d.img1, 3, 3);
evas_object_image_fill_set(d.img1, 0, 0, WIDTH / 2, HEIGHT / 2);
evas_object_resize(d.img1, WIDTH / 2, HEIGHT / 2);
d.bg, EVAS_CALLBACK_KEY_DOWN, _on_keydown, NULL);
}
/* this is a border around the image above, here just to emphasize
* its geometry */
d.border = evas_object_image_filled_add(d.evas);
evas_object_image_file_set(d.border, border_img_path, NULL);
evas_object_image_border_set(d.border, 3, 3, 3, 3);
evas_object_move(d.border, 0, 0);
evas_object_resize(d.border, (WIDTH / 2) + 6, (HEIGHT / 2) + 6);
evas_object_show(d.border);
/* image loading will fail for this one -- unless one cheats and
* puts a valid image on that path */
d.img2 = evas_object_image_add(d.evas);
evas_object_image_file_set(d.img2, bogus_path, NULL);
{
fprintf(stderr, "could not load image '%s': error string is \"%s\"\n",
bogus_path, evas_load_error_str(err));
}
else
{
evas_object_move(d.img2, WIDTH / 2, HEIGHT / 2);
evas_object_image_fill_set(d.img2, 0, 0, WIDTH / 2, HEIGHT / 2);
evas_object_resize(d.img2, WIDTH / 2, HEIGHT / 2);
}
puts(commands);

Here, being valid_path the path to a valid image and bogus_path a path to a file that does not exist, the two outputs of evas_load_error_str() would be (if no other errors occur): "No error on load" and "File (or file path) does not exist", respectively. See the full example.

References EVAS_LOAD_ERROR_CORRUPT_FILE, EVAS_LOAD_ERROR_DOES_NOT_EXIST, EVAS_LOAD_ERROR_GENERIC, EVAS_LOAD_ERROR_NONE, EVAS_LOAD_ERROR_PERMISSION_DENIED, EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED, and EVAS_LOAD_ERROR_UNKNOWN_FORMAT.

Referenced by elm_image_memfile_set().

◆ evas_color_hsv_to_rgb()

void evas_color_hsv_to_rgb ( float  h,
float  s,
float  v,
int *  r,
int *  g,
int *  b 
)

Convert a given color from HSV to RGB format.

Parameters
hThe Hue component of the color.
sThe Saturation component of the color.
vThe Value component of the color.
rThe Red component of the color.
gThe Green component of the color.
bThe Blue component of the color.

This function converts a given color in HSV color format to RGB color format.

◆ evas_color_rgb_to_hsv()

void evas_color_rgb_to_hsv ( int  r,
int  g,
int  b,
float *  h,
float *  s,
float *  v 
)

Convert a given color from RGB to HSV format.

Parameters
rThe Red component of the color.
gThe Green component of the color.
bThe Blue component of the color.
hThe Hue component of the color.
sThe Saturation component of the color.
vThe Value component of the color.

This function converts a given color in RGB color format to HSV color format.

◆ evas_color_argb_premul()

void evas_color_argb_premul ( int  a,
int *  r,
int *  g,
int *  b 
)

Pre-multiplies a rgb triplet by an alpha factor.

Parameters
aThe alpha factor.
rThe Red component of the color.
gThe Green component of the color.
bThe Blue component of the color.

This function pre-multiplies a given rgb triplet by an alpha factor. Alpha factor is used to define transparency.

◆ evas_color_argb_unpremul()

void evas_color_argb_unpremul ( int  a,
int *  r,
int *  g,
int *  b 
)

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

Parameters
aThe alpha factor.
rThe Red component of the color.
gThe Green component of the color.
bThe Blue component of the color.

This function undoes pre-multiplication a given rbg triplet by an alpha factor. Alpha factor is used to define transparency.

See also
evas_color_argb_premul().

◆ evas_data_argb_premul()

void evas_data_argb_premul ( unsigned int *  data,
unsigned int  len 
)

Pre-multiplies data by an alpha factor.

Parameters
dataThe data value.
lenThe length value.

This function pre-multiplies a given data by an alpha factor. Alpha factor is used to define transparency.

◆ evas_data_argb_unpremul()

void evas_data_argb_unpremul ( unsigned int *  data,
unsigned int  len 
)

Undo pre-multiplication data by an alpha factor.

Parameters
dataThe data value.
lenThe length value.

This function undoes pre-multiplication of a given data by an alpha factor. Alpha factor is used to define transparency.

◆ evas_string_char_next_get()

int evas_string_char_next_get ( const char *  str,
int  pos,
int *  decoded 
)

Gets the next character in the string.

Given the UTF-8 string in str, and starting byte position in pos, this function will place in decoded the decoded code point at pos and return the byte index for the next character in the string.

The only boundary check done is that 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.

Parameters
strThe UTF-8 string
posThe byte index where to start
decodedAddress where to store the decoded code point. Optional.
Returns
The byte index of the next character

References eina_unicode_utf8_next_get().

Referenced by elm_entry_filter_accept_set().

◆ evas_string_char_prev_get()

int evas_string_char_prev_get ( const char *  str,
int  pos,
int *  decoded 
)

Gets the previous character in the string.

Given the UTF-8 string in str, and starting byte position in pos, this function will place in decoded the decoded code point at pos and return the byte index for the previous character in the string.

The only boundary check done is that 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.

Parameters
strThe UTF-8 string
posThe byte index where to start
decodedAddress where to store the decoded code point. Optional.
Returns
The byte index of the previous character

References eina_unicode_utf8_get_prev().

◆ evas_string_char_len_get()

int evas_string_char_len_get ( const char *  str)

Get the length in characters of the string.

Parameters
strThe string to get the length of.
Returns
The length in characters (not bytes)

References eina_unicode_utf8_get_len().

Referenced by elm_entry_filter_limit_size().

◆ evas_language_direction_get()

Evas_BiDi_Direction evas_language_direction_get ( void  )

Get language direction.

Since
1.20

◆ evas_language_reinit()

void evas_language_reinit ( void  )

Reinitialize language from the environment.

The locale can change while a process is running. This call tells evas to reload the locale from the environment like it does on start.

Since
1.18

Referenced by elm_language_set().