General Utilities

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

Functions
General Utilities
Evas

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 english. 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...

## Detailed Description

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

## Function Documentation

const char* evas_load_error_str | ( | Evas_Load_Error | error | ) |

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

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:

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 \"%s\"\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 \"%s\"\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 \"%s\"\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 puts(commands);
55 ecore_main_loop_begin();

Here, being `valid_path` the path to a valid image and `bogus_path` a path to a file which 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.

Referenced by evas_object_image_source_unset().

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.

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.

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.

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

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.

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.

References EINA_UNUSED.

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

References eina_unicode_utf8_next_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

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

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_FALSE, EINA_INLIST_FOREACH, EINA_INLIST_GET, eina_stringshare_add(), eina_stringshare_del(), EINA_TRUE, EINA_UNICODE_EMPTY_STRING, eina_unicode_strdup(), eina_unicode_utf8_get_len(), eo_data_ref, eo_data_scope_get(), evas_event_feed_mouse_move(), evas_object_text_font_set(), EVAS_TEXT_STYLE_FAR_SHADOW, EVAS_TEXT_STYLE_FAR_SOFT_SHADOW, EVAS_TEXT_STYLE_GLOW, EVAS_TEXT_STYLE_OUTLINE, EVAS_TEXT_STYLE_OUTLINE_SHADOW, EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW, EVAS_TEXT_STYLE_SHADOW, EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM, EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT, EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT, EVAS_TEXT_STYLE_SHADOW_DIRECTION_LEFT, EVAS_TEXT_STYLE_SHADOW_DIRECTION_RIGHT, EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP, EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT, EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT, EVAS_TEXT_STYLE_SOFT_OUTLINE, and EVAS_TEXT_STYLE_SOFT_SHADOW.