Etk
Main Page Object Hierarchy Data Structures Related Pages
Etk

Etk_Image


Detailed Description

An Etk_Image is a widget that can load and display an image from various sources.

image.png
The image can be loaded from several sources: image files (png, jpg, and the other formats supported by evas), edje files (edj), stock-icons, data pixels or given Evas objects.

Object Hierarchy:
  • Etk_Object
    • Etk_Widget
      • Etk_Image
Properties:
  • "source": The source of the image (file, edje, stock, Evas object or pixel data)
    • Type: Integer (Etk_Image_Source)
    • Access: Read Only
    • Default Value: ETK_IMAGE_FILE
  • "file": The path of the loaded file (path to the image-file or to the edje-file, or NULL if the image is not loaded from a file)
    • Type: String (char *)
    • Access: Read/Write
    • Default Value: NULL
  • "key": The name of the loaded key: it corresponds to the loaded edje-group if the image is loaded from an Edje-file, or to the key corresponding to the image if it is loaded from an Eet-file. Otherwise it is set to NULL
    • Type: String (char *)
    • Access: Read/Write
    • Default Value: NULL
  • "stock-id": The stock ID used by the image. It is set to ETK_STOCK_NO_STOCK if the image is not a stock-icon
    • Type: Integer
    • Access: Read/Write
    • Default Value: ETK_STOCK_NO_STOCK
  • "stock-size": The size of the stock-icon used by the image. It is set to ETK_STOCK_MEDIUM if the image is not a stock-icon
    • Type: Integer
    • Access: Read/Write
    • Default Value: ETK_STOCK_MEDIUM
  • "evas-object": A pointer to the Evas object corresponding to the image. You must be careful if you manipulate it directly (do not call an Edje function on an Evas image object)
    • Type: Pointer (Evas_Object *)
    • Access: Read/Write
    • Default Value: NULL
  • "keep-aspect": Whether of not the image keeps its aspect ratio when it is resized
    • Type: Boolean
    • Access: Read/Write
    • Default Value: ETK_TRUE
  • "aspect-ratio": The aspect-ratio of the image. If it is set to 0.0, Etk calculates it automatically
    • Type: Double
    • Access: Read/Write
    • Default Value: 0.0


Data Structures

struct  Etk_Image
 [Widget] A widget that can load and display an image More...

Defines

#define ETK_IMAGE_TYPE   (etk_image_type_get())
#define ETK_IMAGE(obj)   (ETK_OBJECT_CAST((obj), ETK_IMAGE_TYPE, Etk_Image))
#define ETK_IS_IMAGE(obj)   (ETK_OBJECT_CHECK_TYPE((obj), ETK_IMAGE_TYPE))

Enumerations

enum  Etk_Image_Source {
  ETK_IMAGE_FILE,
  ETK_IMAGE_EDJE,
  ETK_IMAGE_STOCK,
  ETK_IMAGE_EVAS_OBJECT,
  ETK_IMAGE_DATA
}
 The different sources that an Etk_Image can use. More...

Functions

Etk_Widget * etk_image_new (void)
 Creates a new empty image.
Etk_Widget * etk_image_new_from_file (const char *filename, const char *key)
 Creates a new image and loads the image from an image file.
Etk_Widget * etk_image_new_from_edje (const char *filename, const char *group)
 Creates a new image and loads the image from an edje-file.
Etk_Widget * etk_image_new_from_stock (Etk_Stock_Id stock_id, Etk_Stock_Size stock_size)
 Creates a new image and loads the image corresponding to the stock id.
Etk_Widget * etk_image_new_from_evas_object (Evas_Object *evas_object)
 Creates a new image from the given evas object.
Etk_Widget * etk_image_new_from_data (int width, int height, void *data, Etk_Bool copy)
 Creates a new image from the given pixel data.
void etk_image_set_from_file (Etk_Image *image, const char *filename, const char *key)
 Loads the image from a file.
void etk_image_file_get (Etk_Image *image, char **filename, char **key)
 Gets the path to the file used by the image.
void etk_image_set_from_edje (Etk_Image *image, const char *filename, const char *group)
 Loads the image from an edje file.
void etk_image_edje_get (Etk_Image *image, char **filename, char **group)
 Gets the filename and the group of the edje-object used for the image.
void etk_image_set_from_stock (Etk_Image *image, Etk_Stock_Id stock_id, Etk_Stock_Size stock_size)
 Loads the image corresponding to the given stock-id.
void etk_image_stock_get (Etk_Image *image, Etk_Stock_Id *stock_id, Etk_Stock_Size *stock_size)
 Gets the stock-id and the stock-size used by the image.
void etk_image_set_from_evas_object (Etk_Image *image, Evas_Object *evas_object)
 Loads the image from an Evas object.
Evas_Object * etk_image_evas_object_get (Etk_Image *image)
 Gets the Evas object used by the image. You can call this function even if you have not explicitly set the Evas object used by this image. For example, if you have loaded the image from a file, this function will return the corresponding Evas image object. You should just be careful by manipulating it (don't use Edje functions on an image object for example).
void etk_image_set_from_data (Etk_Image *image, int width, int height, void *data, Etk_Bool copy)
 Sets the pixels of the image.
void * etk_image_data_get (Etk_Image *image, Etk_Bool for_writing)
 Gets a pointer to the image pixels. This function only works if the image has been loaded from a file or if you have explicitely set its pixels with etk_image_set_from_data().
Etk_Image_Source etk_image_source_get (Etk_Image *image)
 Gets the source of the image (file, edje-file, stock, Evas object or pixel data).
void etk_image_update (Etk_Image *image)
 Updates all the pixels of the image (to be called after you have modified the pixel buffer for example). Same as etk_image_update_rect(image, 0, 0, image_width, image_height).
void etk_image_update_rect (Etk_Image *image, int x, int y, int w, int h)
 Updates a rectangle of the pixels of the image (to be called after you have modified the pixel buffer for example). It only has effect on image loaded from a pixel buffer.
void etk_image_copy (Etk_Image *dest_image, Etk_Image *src_image)
 Copies the image src_image to dest_image.
void etk_image_size_get (Etk_Image *image, int *width, int *height)
 Gets the native size of the image. If the image is loaded from a file or from given pixels, it returns the native size of the image. If the image is loaded from an Edje file or a stock-id, it returns the minimum size of the Edje object (a stock image is an Edje object). Otherwise, the returned size is 0x0.
void etk_image_keep_aspect_set (Etk_Image *image, Etk_Bool keep_aspect)
 Sets if the image should keep its aspect ratio when it is resized.
Etk_Bool etk_image_keep_aspect_get (Etk_Image *image)
 Gets whether the image keeps its aspect ratio when it is resized.
void etk_image_aspect_ratio_set (Etk_Image *image, double aspect_ratio)
 Sets (forces) the aspect ratio of the image. You can use this function for example to set the aspect-ratio when you set the image from an Evas object with etk_image_set_from_evas_object().
double etk_image_aspect_ratio_get (Etk_Image *image)
 Gets the aspect ratio you set to the image. If no aspect ratio has been set, it will return 0.0. To know the native aspect ratio, call etk_image_size_get() to get the native size of the image and calculate the aspect ratio from these values.


Define Documentation

#define ETK_IMAGE_TYPE   (etk_image_type_get())

Gets the type of an image

#define ETK_IMAGE ( obj   )     (ETK_OBJECT_CAST((obj), ETK_IMAGE_TYPE, Etk_Image))

Casts the object to an Etk_Image

#define ETK_IS_IMAGE ( obj   )     (ETK_OBJECT_CHECK_TYPE((obj), ETK_IMAGE_TYPE))

Check if the object is an Etk_Image


Enumeration Type Documentation

enum Etk_Image_Source

The different sources that an Etk_Image can use.

Enumerator:
ETK_IMAGE_FILE  The image is loaded from an image file
ETK_IMAGE_EDJE  The image is loaded from an Edje file
ETK_IMAGE_STOCK  The image is loaded from a stock id
ETK_IMAGE_EVAS_OBJECT  The image shows an existing Evas Object
ETK_IMAGE_DATA  The image uses pixel data given by the user


Function Documentation

Etk_Widget * etk_image_new ( void   ) 

Creates a new empty image.

Returns:
Returns the new image widget

Etk_Widget * etk_image_new_from_file ( const char *  filename,
const char *  key 
)

Creates a new image and loads the image from an image file.

Parameters:
filename the path of the file to load
key the key to load (only used if the file is an Eet file, otherwise you can set it to NULL)
Returns:
Returns the new image widget

Etk_Widget * etk_image_new_from_edje ( const char *  filename,
const char *  group 
)

Creates a new image and loads the image from an edje-file.

Parameters:
filename the name of the edje-file to load
group the name of the edje-group to load
Returns:
Returns the new image widget

Etk_Widget * etk_image_new_from_stock ( Etk_Stock_Id  stock_id,
Etk_Stock_Size  stock_size 
)

Creates a new image and loads the image corresponding to the stock id.

Parameters:
stock_id the stock id corresponding to the image
stock_size the size of the image to load
Returns:
Returns the new image widget

Etk_Widget * etk_image_new_from_evas_object ( Evas_Object *  evas_object  ) 

Creates a new image from the given evas object.

Parameters:
evas_object the evas object to use for the image
Returns:
Returns the new image widget

Etk_Widget * etk_image_new_from_data ( int  width,
int  height,
void *  data,
Etk_Bool  copy 
)

Creates a new image from the given pixel data.

Parameters:
width the width of the image
height the height of the image
data a pointer to the pixels: the pixels have to be stored in the premul'ed ARGB format
copy whether the pixels should be copied or not. If you decide not to copy the pixels, you have to make sure the memory area where the pixels are stored is valid during all the lifetime of the image
Returns:
Returns the new image widget

void etk_image_set_from_file ( Etk_Image *  image,
const char *  filename,
const char *  key 
)

Loads the image from a file.

Parameters:
image an image
filename the path to the file to load
key the key to load (only used if the file is an Eet file, otherwise you can set it to NULL)

void etk_image_file_get ( Etk_Image *  image,
char **  filename,
char **  key 
)

Gets the path to the file used by the image.

Parameters:
image an image
filename the location where to store the path to the loaded file
key the location where to store the key of the loaded image (NULL if the file is not loaded from an Eet file)

void etk_image_set_from_edje ( Etk_Image *  image,
const char *  filename,
const char *  group 
)

Loads the image from an edje file.

Parameters:
image an image
filename the path to the edje-file to load
group the name of the edje-group to load

void etk_image_edje_get ( Etk_Image *  image,
char **  filename,
char **  group 
)

Gets the filename and the group of the edje-object used for the image.

Parameters:
image an image
filename the location to store the path to the edje-file used
group the location to store the name of the edje-group used

void etk_image_set_from_stock ( Etk_Image *  image,
Etk_Stock_Id  stock_id,
Etk_Stock_Size  stock_size 
)

Loads the image corresponding to the given stock-id.

Parameters:
image an image
stock_id the stock-id corresponding to the icon to load
stock_size the size of the stock-icon

void etk_image_stock_get ( Etk_Image *  image,
Etk_Stock_Id *  stock_id,
Etk_Stock_Size *  stock_size 
)

Gets the stock-id and the stock-size used by the image.

Parameters:
image an image
stock_id the location where to store the stock id used by the image
stock_size the location where to store the stock size used by the image

void etk_image_set_from_evas_object ( Etk_Image *  image,
Evas_Object *  evas_object 
)

Loads the image from an Evas object.

Parameters:
image an image
evas_object the Evas object to use. The object can be anything (image, edje object, emotion object, ...)

Evas_Object * etk_image_evas_object_get ( Etk_Image *  image  ) 

Gets the Evas object used by the image. You can call this function even if you have not explicitly set the Evas object used by this image. For example, if you have loaded the image from a file, this function will return the corresponding Evas image object. You should just be careful by manipulating it (don't use Edje functions on an image object for example).

Parameters:
image an image
Returns:
Returns the Evas object of the image

void etk_image_set_from_data ( Etk_Image *  image,
int  width,
int  height,
void *  data,
Etk_Bool  copy 
)

Sets the pixels of the image.

Parameters:
image an image
width the width of the image
height the height of the image
data a pointer to the pixels: the pixels have to be stored in the premul'ed ARGB format
copy whether the pixels should be copied or not. If you decide not to copy the pixels, you have to make sure the memory area where the pixels are stored is valid during all the lifetime of the image
Returns:
Returns the new image widget

void * etk_image_data_get ( Etk_Image *  image,
Etk_Bool  for_writing 
)

Gets a pointer to the image pixels. This function only works if the image has been loaded from a file or if you have explicitely set its pixels with etk_image_set_from_data().

Parameters:
image an image
for_writing whether or not you want to be able to modify the pixels of the image. If so, call etk_image_update() once you have finished.
Returns:
Returns a pointer to the location of the pixels (stored in premul'ed ARGB format)
Note:
If the image is loaded from a file, it has to be realized. Otherwise it will return NULL

Etk_Image_Source etk_image_source_get ( Etk_Image *  image  ) 

Gets the source of the image (file, edje-file, stock, Evas object or pixel data).

Parameters:
image an image
Returns:
Returns the source of the image

void etk_image_update ( Etk_Image *  image  ) 

Updates all the pixels of the image (to be called after you have modified the pixel buffer for example). Same as etk_image_update_rect(image, 0, 0, image_width, image_height).

Parameters:
image an image

void etk_image_update_rect ( Etk_Image *  image,
int  x,
int  y,
int  w,
int  h 
)

Updates a rectangle of the pixels of the image (to be called after you have modified the pixel buffer for example). It only has effect on image loaded from a pixel buffer.

Parameters:
image an image
x the x position of the top-left corner of the rectangle to update
y the y position of the top-left corner of the rectangle to update
w the width of the rectangle to update
h the height of the rectangle to update

void etk_image_copy ( Etk_Image *  dest_image,
Etk_Image *  src_image 
)

Copies the image src_image to dest_image.

Parameters:
dest_image the destination image
src_image the image to copy
Note:
If src_image is an edje image, the current state of the edje animation won't be copied

void etk_image_size_get ( Etk_Image *  image,
int *  width,
int *  height 
)

Gets the native size of the image. If the image is loaded from a file or from given pixels, it returns the native size of the image. If the image is loaded from an Edje file or a stock-id, it returns the minimum size of the Edje object (a stock image is an Edje object). Otherwise, the returned size is 0x0.

Parameters:
image an image
width the location where to set the native width of the image
height the location where to set the native height of the image

void etk_image_keep_aspect_set ( Etk_Image *  image,
Etk_Bool  keep_aspect 
)

Sets if the image should keep its aspect ratio when it is resized.

Parameters:
image an image
keep_aspect if keep_aspect is ETK_TRUE, the image will keep its aspect ratio when it is resized

Etk_Bool etk_image_keep_aspect_get ( Etk_Image *  image  ) 

Gets whether the image keeps its aspect ratio when it is resized.

Parameters:
image an image
Returns:
Returns ETK_TRUE if the image keeps its aspect ratio when it is resized

void etk_image_aspect_ratio_set ( Etk_Image *  image,
double  aspect_ratio 
)

Sets (forces) the aspect ratio of the image. You can use this function for example to set the aspect-ratio when you set the image from an Evas object with etk_image_set_from_evas_object().

Parameters:
image an image
aspect_ratio the aspect ratio to set, or 0.0 to make Etk calculates automatically the aspect ratio

double etk_image_aspect_ratio_get ( Etk_Image *  image  ) 

Gets the aspect ratio you set to the image. If no aspect ratio has been set, it will return 0.0. To know the native aspect ratio, call etk_image_size_get() to get the native size of the image and calculate the aspect ratio from these values.

Parameters:
image an image
Returns:
Returns the aspect ratio you set to the image, or 0.0 if no aspect ratio has been set