General Utilities

- Main Page
- Related Pages
- Modules
- Data Structures
- Files
- Examples

Functions
General Utilities
Evas

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

## Functions
EVAS_API 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.
EVAS_API 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.
EVAS_API 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.
EVAS_API void | evas_color_argb_premul (int a, int *r, int *g, int *b)
| Pre-multiplies a rgb triplet by an alpha factor.
EVAS_API void | evas_color_argb_unpremul (int a, int *r, int *g, int *b)
| Undo pre-multiplication of a rgb triplet by an alpha factor.
EVAS_API void | evas_data_argb_premul (unsigned int *data, unsigned int len)
| Pre-multiplies data by an alpha factor.
EVAS_API void | evas_data_argb_unpremul (unsigned int *data, unsigned int len)
| Undo pre-multiplication data by an alpha factor.
EVAS_API int | evas_string_char_next_get (const char *str, int pos, int *decoded)
| Gets the next character in the string.
EVAS_API int | evas_string_char_prev_get (const char *str, int pos, int *decoded)
| Gets the previous character in the string.
EVAS_API int | evas_string_char_len_get (const char *str)
| Get the length in characters of the string.
EVAS_API Evas_BiDi_Direction | evas_language_direction_get (void)
| Get language direction.
EVAS_API void | evas_language_reinit (void)
| Reinitialize language from the environment.

## Detailed Description

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

## Function Documentation

## ◆ evas_load_error_str()

EVAS_API 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

  error | the 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);
err = evas_object_image_load_error_get(d.img1);
if (err != EVAS_LOAD_ERROR_NONE)
{
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);
evas_object_show(d.img1);
evas_object_focus_set(d.bg, EINA_TRUE);
evas_object_event_callback_add(
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_image_border_center_fill_set(d.border, EVAS_BORDER_FILL_NONE);
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);
err = evas_object_image_load_error_get(d.img2);
if (err != EVAS_LOAD_ERROR_NONE)
{
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);
evas_object_show(d.img2);
}
puts(commands);
ecore_main_loop_begin();
EVAS_CALLBACK_KEY_DOWN
@ EVAS_CALLBACK_KEY_DOWN
Key Press Event.
Definition: Evas_Common.h:430
ecore_main_loop_begin
void ecore_main_loop_begin(void)
Runs the application main loop.
Definition: ecore_main.c:1311
EINA_TRUE
#define EINA_TRUE
boolean value TRUE (numerical value 1)
Definition: eina_types.h:539
EVAS_LOAD_ERROR_NONE
@ EVAS_LOAD_ERROR_NONE
No error on load.
Definition: Evas_Loader.h:141
evas_object_show
EVAS_API void evas_object_show(Evas_Object *eo_obj)
Makes the given Evas object visible.
Definition: evas_object_main.c:1814
evas_object_event_callback_add
EVAS_API void evas_object_event_callback_add(Evas_Object *eo_obj, Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data)
Add (register) a callback function to a given Evas object event.
Definition: evas_callbacks.c:478
evas_object_move
EVAS_API void evas_object_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
Move the given Evas object to the given location inside its canvas' viewport.
Definition: evas_object_main.c:1171
evas_object_focus_set
EVAS_API void evas_object_focus_set(Efl_Canvas_Object *obj, Eina_Bool focus)
Indicates that this object is the keyboard event receiver on its canvas.
Definition: efl_canvas_object_eo.legacy.c:39
evas_object_resize
EVAS_API void evas_object_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
Changes the size of the given Evas object.
Definition: evas_object_main.c:1236
evas_object_image_border_set
EVAS_API void evas_object_image_border_set(Evas_Object *obj, int l, int r, int t, int b)
Dimensions of this image's border, a region that does not scale with the center area.
Definition: evas_image_legacy.c:117
evas_object_image_fill_set
EVAS_API void evas_object_image_fill_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
Set how to fill an image object's drawing rectangle given the (real) image bound to it.
Definition: evas_image_legacy.c:57
evas_object_image_load_error_get
EVAS_API Evas_Load_Error evas_object_image_load_error_get(const Evas_Object *obj)
Retrieves a number representing any error that occurred during the last loading of the given image ob...
Definition: evas_image_legacy.c:400
evas_object_image_border_center_fill_set
EVAS_API void evas_object_image_border_center_fill_set(Evas_Object *obj, Evas_Border_Fill_Mode fill)
Specifies how the center part of the object (not the borders) should be drawn when EFL is rendering i...
Definition: evas_image_legacy.c:145
evas_object_image_add
EVAS_API Evas_Object * evas_object_image_add(Evas *eo_e)
Creates a new image object on the given Evas e canvas.
Definition: evas_image_legacy.c:25
evas_object_image_file_set
EVAS_API void evas_object_image_file_set(Evas_Object *obj, const char *file, const char *key)
Set the source file from where an image object must fetch the real image data (it may be an Eet file,...
Definition: evas_image_legacy.c:194
evas_object_image_filled_add
EVAS_API Evas_Object * evas_object_image_filled_add(Evas *eo_e)
Creates a new image object that automatically scales its bound image to the object's area,...
Definition: evas_image_legacy.c:35
EVAS_BORDER_FILL_NONE
@ EVAS_BORDER_FILL_NONE
Image's center region is not to be rendered.
Definition: Evas_Legacy.h:5721
evas_load_error_str
EVAS_API 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.
Definition: evas_main.c:974

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()

EVAS_API 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

  h | The Hue component of the color.
  s | The Saturation component of the color.
  v | The Value component of the color.
  r | The Red component of the color.
  g | The Green component of the color.
  b | The Blue component of the color.

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

## ◆ evas_color_rgb_to_hsv()

EVAS_API 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

  r | The Red component of the color.
  g | The Green component of the color.
  b | The Blue component of the color.
  h | The Hue component of the color.
  s | The Saturation component of the color.
  v | The Value component of the color.

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

## ◆ evas_color_argb_premul()

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

Pre-multiplies a rgb triplet by an alpha factor.

Parameters

  a | The alpha factor.
  r | The Red component of the color.
  g | The Green component of the color.
  b | The 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()

EVAS_API 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

  a | The alpha factor.
  r | The Red component of the color.
  g | The Green component of the color.
  b | The 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()

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

Pre-multiplies data by an alpha factor.

Parameters

  data | The data value.
  len | The length value.

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

## ◆ evas_data_argb_unpremul()

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

Undo pre-multiplication data by an alpha factor.

Parameters

  data | The data value.
  len | The 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()

EVAS_API 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

  str | The UTF-8 string
  pos | The byte index where to start
  decoded | Address where to store the decoded code point. Optional.

Returns
  The byte index of the next character

Referenced by elm_entry_filter_accept_set().

## ◆ evas_string_char_prev_get()

EVAS_API 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

  str | The UTF-8 string
  pos | The byte index where to start
  decoded | Address 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()

EVAS_API int evas_string_char_len_get | ( | const char * | str | ) |

Get the length in characters of the string.

Parameters

  str | The 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_API Evas_BiDi_Direction evas_language_direction_get | ( | void |  | ) |

Get language direction.

Since
  1.20

## ◆ evas_language_reinit()

EVAS_API 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().