Clarisse 5.0 SP8 SDK  5.0.5.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
ImageMap Class Reference

This class represents a mimap level of an ImageCanvas.
A map contains a set of channels, each containing color data. Standard channels (like color ones, Z) are directly accessible using an ID (see KnownChannels). Other (custom) channels need to be accessed by name.
An ImageMap has no notion of its boundaries. The visible part of the map is defined by parent ImageCanvas's canvas. That's the reason why most of the function take a region as parameter, so they know how which data they should work on. More...

Inheritance diagram for ImageMap:
ResourceData EventObject CoreCustomData CoreBaseObject CoreBaseType

Classes

struct  Data
 
struct  Stats
 
struct  Stats.tile_count
 

Public Types

enum  KnownChannels {
  CHANNEL_LUMINANCE = 0,
  CHANNEL_R,
  CHANNEL_G,
  CHANNEL_B,
  CHANNEL_A,
  CHANNEL_Z,
  CHANNEL_MAX,
  CHANNEL_COUNT = CHANNEL_MAX,
  CHANNEL_CUSTOM = CHANNEL_MAX
}
 
typedef void(* GetBilinearColorCallBack )(const Data &, const float &, const float &, GMathVec4f &, const ImagePixel::RepeatMode &, const ImagePixel::RepeatMode &)
 
typedef const GMathVec4f(* GetColorCallBack )(const Data &, const int &, const int &, const ImagePixel::RepeatMode &, const ImagePixel::RepeatMode &)
 
typedef void(* ConvertColorCallBack )(unsigned char *outputBuffer, const float &colorValue)
 

Public Member Functions

 ImageMap (const int &tile_size=DEFAULT_TILE_SIZE)
 Default constructor.
 
 ImageMap (const ImageMap &src, bool copy_data=true, const GMathVec4i *region=0)
 Initialize an image map using the configuration of another image.
 
ImageMapChanneladd_channel (const CoreString &name, const ImagePixel::BitDepth &bdepth, const ImagePixel::BitType &bit_type)
 Adds a channel, if it doesn't already exists.
 
void add_channel (ImageMapChannel *channel, const unsigned int &channel_index)
 Adds a channelto the current map.
Warning: this is a check free function that requires a fully configured ImageMapChannel.
 
const CoreVector
< ImageMapChannel * > & 
get_channels () const
 Returns the list of channels.
 
void set_auto_check_uniformity (const bool &flag)
 Enable/disable auto check uniformity.
 
const bool & get_auto_check_uniformity () const
 Returns auto check uniformity status.
 
ImageMapChannelget_channel (const int id) const
 Returns a pointer to the requested channel. Return value may be null!
 
unsigned int get_custom_channel_count () const
 Returns the number of custom channels in the image.
 
unsigned int get_channel_index_by_name (const CoreString &name) const
 Returns the index of the requested channel. Returns -1 if the channel name was not found.
 
ImageMapChannelget_channel_by_name (const CoreString &name) const
 Returns the channel matching the requested name. Returns null if the channel name was not found.
 
ImageMapChannelget_red_channel () const
 Returns ta pointer to the red channel. May be null.
 
ImageMapChannelget_green_channel () const
 Returns ta pointer to the green channel. May be null.
 
ImageMapChannelget_blue_channel () const
 Returns ta pointer to the blue channel. May be null.
 
ImageMapChannelget_alpha_channel () const
 Returns ta pointer to the alpha channel. May be null.
 
ImageMapChannelget_luminance_channel () const
 Returns ta pointer to the luminance channel. May be null.
 
void set_depth (ImagePixel::Depth depth, ImagePixel::BitDepth bit_depth, ImagePixel::BitType bit_type)
 Set image data format:
 
const ImagePixel::Depth & get_depth () const
 Returns the image depth.
 
const ImagePixel::BitDepth & get_bit_depth () const
 Returns the pixel bit depth.
 
const ImagePixel::BitType & get_bit_type () const
 Returns the pixel bit type.
 
const ImagePixel::RepeatMode & get_u_repeat_mode () const
 Returns the horizontal repeat mode.
 
const ImagePixel::RepeatMode & get_v_repeat_mode () const
 Returns the vertical repeat mode.
 
void set_repeat_mode (const ImagePixel::RepeatMode &u_mode, const ImagePixel::RepeatMode &v_mode)
 Sets the repeat modes.
 
const unsigned int & get_channel_count () const
 Returns the number of channels stored.
 
const unsigned int & get_tile_size () const
 Returns the size of a tile. ( size = width = height )
 
void get_sorted_tiles (const GMathVec4i &region, CoreArray< ImageMapTileHandle > *sorted_tiles, unsigned int &items_count, bool allow_empty=true) const
 Returns a sorted list of tiles pointers for the specified region.
 
void get_sorted_tiles (const GMathVec4i &region, CoreArray< ImageMapTileHandle > *sorted_tiles, unsigned int &items_count, bool allow_empty)
 Returns a list of tiles for the specified region. Non-const version of the function above.
 
bool get_dirty_tiles (const GMathVec4i &region, CoreArray< ImageMapTileHandle > *sorted_tiles, CoreArray< bool > &dirtiness_flag, unsigned int &items_count)
 Returns a list of dirty tiles for the specified region.
 
void get_clean_tiles (const GMathVec4i &region, CoreArray< ImageMapTileHandle > *tiles, unsigned int &items_count)
 Returns a list of clean tiles for the specified region.
 
unsigned int get_dirty_pixel_count (const GMathVec4i &region)
 
bool is_luminance_alpha () const
 Returns whether the image has a Luminance and an alpha channel.
 
bool is_rgb () const
 Returns whether the image has RGB but no alpha channel.
 
bool is_rgba () const
 Returns whether the image has RGB and an alpha channel.
 
bool has_alpha () const
 Returns whether the image has an alpha channel.
 
bool has_one_clean_tile () const
 Returns whether the image has at least one clean tile.
 
void set_one_clean_tile () const
 Tell the image at least one tile is clean.
 
void remove_all_channels ()
 Remove all the channels that are in the map.
 
void reset ()
 Resets the image. All parameters are set to 0. Channels are removed.
 
void finalize (ImageEvalContext &context, const GMathVec4i &region, const bool &set_clean=true, const bool &force_mono_thread=false)
 Tidy the image after a render so it can be evaluated through a texture.
 
void compute_image_edges (ImageEvalContext &context, const GMathVec4i &region)
 Computes an extra line of pixels on the edge of an image so the texture evaluation works properly.
 
void get_pixel_nearest (ImageEvalContext &context, const MapEvalCtx &eval_ctx, float x, float y, const GMathVec4i &canvas, GMathVec4f &color, const ImagePixel::RepeatMode &x_mode=ImagePixel::DEFAULT, const ImagePixel::RepeatMode &y_mode=ImagePixel::DEFAULT) const
 Returns the value of the pixel at the given coordinates.
 
void get_pixel_bilinear (ImageEvalContext &context, const MapEvalCtx &eval_ctx, const float &x, const float &y, const GMathVec4i &canvas, GMathVec4f &color, const ImagePixel::RepeatMode &x_mode=ImagePixel::DEFAULT, const ImagePixel::RepeatMode &y_mode=ImagePixel::DEFAULT) const
 Returns the value of the pixel at the given coordinates, using bilinear filtering.
 
void create_buffer_rgba (ImageEvalContext &context, const GMathVec4i &region, float *out_buffer, unsigned int channel_size, const ImagePixel::RepeatMode &x_mode, const ImagePixel::RepeatMode &y_mode) const
 Creates a buffer of floats that contains the color values of the RGBA channels of the image for the specified region.
 
void get_rgba_channels (ImageMapChannels *channels_vector) const
 Get the RGBA channels of the image.
 
void fill_from_buffer_rgba (const GMathVec4i &region, float *in_buffer, bool process_region_edges=true)
 Fill the image using the float buffer given as parameter.
 
void fill_channels_from_buffer (const GMathVec4i &region, unsigned int &channel_count, float *in_buffer, bool process_region_edges=true)
 Fill the first channels of the image using the data given as parameter.
 
void fill_clean_data (const ImageMap &src, const GMathVec4i &region)
 Copy the data from the clean tiles of the source image map.
 
void set_data (const unsigned char *data, const unsigned int &data_size, const GMathVec4i &canvas, const char *name) const
 Fill a channel using the data passed as parameter.
 
void set_data (const float *data, const unsigned int &data_size, const GMathVec4i &canvas, const KnownChannels index) const
 Fill a channel using the float buffer passed as parameter.
 
void make_half (ImageEvalContext &context, ImageMap &up_image, const GMathVec4i &region) const
 Computes a half-sized mipmap from another ImageMap.
 
void invalidate_all ()
 Invalidates all channels.
 
void invalidate_channels (const CoreVector< CoreString > &channel_names)
 Invalidates the specified channels.
 
void copy_channel_list (const ImageMap &src)
 Initialise the list of channels of the current ImageMap using another ImageMap.
 
void update_custom_channels (const CoreVector< CoreString > &to_remove, const CoreVector< CoreString > &to_add)
 Updates the list of channels in the image.
 
void dirty_border (const GMathVec4i &region)
 Dirty all the tiles of all channels that intersect the region.
 
void on_update_visible (const GMathBbox2i &old_region, const GMathBbox2i &new_region)
 Updates the image channels after the visible part of the region has been modified.
 
virtual size_t get_memory_size () const override
 Get the amount of memory occupied by the resource.
 
void get_stats (Stats &stats) const
 
void move_data (const int &offset_x, const int &offset_y)
 Shift the data of the image.
 
void copy_data (const ImageMap &src, int offset_x, int offset_y, const GMathVec4i *region=0)
 Copy data from another ImageMap.
 
void create_tiles (const GMathVec4i &region, bool visible_only=false)
 Creates tiles for the specified region in all channels.
 
void fill_rgba_from_channels (const ImageMap &src, const CoreBasicArray< CoreString > &channel_names, int offset_x, int offset_y, const GMathVec4i *region)
 Fill the RGBA channels of the current image using data from the specified channels of the source image.
 
void get_bounding_box (GMathBbox2i &bbox) const
 Compute the bounding box of the data actually stored in the image.
 
GMathBbox2i get_bounding_box () const
 
void get_tiles_bounding_box (GMathBbox2i &bbox) const
 Compute the bounding box of the tiles instancianted in the image.
 
void set_bounding_box (const GMathBbox2i &bbox)
 Sets the bounding box of the data actually stored in the image.
 
void process_visible (ImageMapCtx &ctx, ImageChannelProcess_callback process, void *user_data=0, const GMathVec4i *region=0)
 Apply a process on the visible channels of the image.
 
void blit_visible (const ImageMap &source, const GMathVec4i &region, const ImagePixel::BlitMode &mode=ImagePixel::BLIT_MODE_REPLACE)
 Copy data from the visible channels.
 
void blit (const ImageMap &source, const GMathVec4i &region, const ImagePixel::BlitMode &mode=ImagePixel::BLIT_MODE_REPLACE)
 Copies the content of a tile from source to destination using the specified copy mode. (deprecated)
 
bool blit_bucket_aligned (const ImageMap &source, const GMathVec4i &region, const ImagePixel::BlitMode &mode=ImagePixel::BLIT_MODE_REPLACE)
 Copies the content of a tile from source to destination using the specified copy mode.
 
const unsigned int get_theoric_tile_count () const
 Returns the theoric number of tiles per channel the image can contain, ie, how many tiles we would have if the bounding box was filled with data.
 
void create_data (const GMathVec4i &region, const ImagePixel::Depth &depth, const ImagePixel::BitDepth &bit_depth, const ImagePixel::BitType &bit_type, const int &tile_size)
 Sets up image parameters and creates channels and.
 
void create_rgba_channels (const GMathVec4i &region)
 Creates R,G,B,A channels and the tiles for the specified region if they don't exist.
 
void fill_from (const ImageMap &src, const GMathVec4i &src_data_region, const GMathVec4i &dest_data_region, AppBase *app)
 Fills the image using the content of the source image.
 
void init (const ImagePixel::Depth &depth, const ImagePixel::BitDepth &bit_depth, const ImagePixel::BitType &bit_type, const int &tile_size)
 Sets image parameters.
 
- Public Member Functions inherited from ResourceData
 ResourceData (const ResourceData &other)
 
ResourceImportDataget_import_data () const
 
void set_import_data (ResourceImportData *data)
 
virtual Core128BitHashKey get_hash_key () const
 Get the hash key of the resource.
 
virtual bool is_serializable () const
 Tell if the resource can be serialized or not.
 
virtual void * serialize (size_t &serial_size) const
 Serialize the resource data.
 
virtual bool deserialize (void *serial, const size_t &serial_size)
 Deserialize the resource data.
 
void advert_memory_changed () const
 Adverts that the memory usage of the resource has changed.
 
bool is_protected () const
 
- Public Member Functions inherited from EventObject
 EventObject ()
 Constructor.
 
 EventObject (const EventObject &src)
 Copy Constructor.
 
virtual ~EventObject () override
 Destructor.
 
void connect (EventObject &sender, const CoreString &event_id, EventInfoMethod event_cb, void *data=0)
 Connects this to an object to listen to a specific event.
 
void connect (EventObject &sender, EventInfoMethod event_cb, void *data=0)
 Connects this to an object to listen any of its events.
 
bool disconnect (EventObject &sender, const CoreString &event_id, EventInfoMethod event_cb, void *data=0)
 
bool disconnect_all (EventObject &sender)
 Disconnects from all objects sender was listening on.
 
void disconnect_all ()
 Disconnects from all objects we were listening on.
 
void remove_all_connection ()
 Disconnects object from other objects it is listening to, and also disconnects all objects listening to it.
 
void raise_event (const CoreString &event_id) const
 sends an event
 
void raise_event (const EventInfo &event_info) const
 sends an event
 
bool is_connected (EventObject &sender, const CoreString &event_id, void *data)
 
void set_mute (const bool &mute)
 Asks for object muting. This will increase or decrease the muting counter. Unmuting may not be immediat since it will happen only when counter reaches 0.
 
bool is_mute () const
 Returns if object is muted.
 
CoreArray< EventObject * > get_senders () const
 
unsigned int get_sender_count () const
 
unsigned int get_receiver_count () const
 
void connect (EventObject &sender, const CoreString &event_id, EventMethod event_cb, void *data=0)
 Connects this to an object to listen to a specific event.
 
void connect (EventObject &sender, EventMethod event_cb, void *data=0)
 Connects this to an object to listen any of its events.
 
bool disconnect (EventObject &sender, const CoreString &event_id, EventMethod event_cb, void *data=0)
 Disconnects this from an object for a specific event.
 
- Public Member Functions inherited from CoreCustomData
 CoreCustomData (const CoreCustomData &src)
 
void add_custom_data (void *key, const bool &data)
 
void add_custom_data (void *key, const int &data)
 
void add_custom_data (void *key, const unsigned int &data)
 
void add_custom_data (void *key, const char *data)
 
void add_custom_data (void *key, const CoreString &data)
 
void add_custom_data (void *key, const double &data)
 
void add_custom_data (void *key, void *data)
 
void remove_custom_data (void *key)
 
void remove_all_custom_data ()
 
void set_custom_data (void *key, const bool &data)
 
void set_custom_data (void *key, const int &data)
 
void set_custom_data (void *key, const unsigned int &data)
 
void set_custom_data (void *key, const double &data)
 
void set_custom_data (void *key, const char *data)
 
void set_custom_data (void *key, const CoreString &data)
 
void set_custom_data (void *key, void *data)
 
void get_custom_data (void *key, bool &data) const
 
void get_custom_data (void *key, int &data) const
 
void get_custom_data (void *key, unsigned int &data) const
 
void get_custom_data (void *key, double &data) const
 
void get_custom_data (void *key, CoreString &data) const
 
void get_custom_data (void *key, void *&data) const
 
- Public Member Functions inherited from CoreBaseObject
bool is_kindof (const CoreBaseObject &object) const
 
CoreString get_class_info_name () const
 
const unsigned long & get_class_info_id () const
 
virtual bool is_kindof (const CoreClassInfo &cinfo) const
 
virtual const CoreClassInfoget_class_info () const
 
template<class T >
T * cast ()
 
template<class T >
const T * cast () const
 
- Public Member Functions inherited from CoreBaseType
bool is_kindof (const CoreClassInfo &cinfo) const
 

Static Public Member Functions

static ImageMapget_default_imagemap (GMathVec4i &region, ImagePixel::RepeatMode u_mode=ImagePixel::RESET, ImagePixel::RepeatMode v_mode=ImagePixel::RESET)
 Returns a pointer to a default ImageMap, which contains a 512*512 RGBA opaque test image.
 

Friends

class ImageCanvas
 
class ImageIO
 

Detailed Description

This class represents a mimap level of an ImageCanvas.
A map contains a set of channels, each containing color data. Standard channels (like color ones, Z) are directly accessible using an ID (see KnownChannels). Other (custom) channels need to be accessed by name.
An ImageMap has no notion of its boundaries. The visible part of the map is defined by parent ImageCanvas's canvas. That's the reason why most of the function take a region as parameter, so they know how which data they should work on.


Class Documentation

struct ImageMap::Data
Class Members
bool auto_check_uniformity
BitDepth bit_depth
BitType bit_type
CoreVector< ImageMapChannel * > channels
Depth depth
ImageMapChannel ** known_channels
CoreAtomic32 m_has_one_clean_tile
unsigned int tile_size
RepeatMode u_repeat_mode
RepeatMode v_repeat_mode
struct ImageMap::Stats
Class Members
unsigned int channel_count
float mem_usage_mb
struct Stats tile_count
struct ImageMap::Stats.tile_count
Class Members
unsigned int total
unsigned int total_occupied
unsigned int total_occupied_with_buffer

Constructor & Destructor Documentation

ImageMap::ImageMap ( const ImageMap src,
bool  copy_data = true,
const GMathVec4i *  region = 0 
)
explicit

Initialize an image map using the configuration of another image.

Parameters
srcSource image
copy_datacopy data from channels on/off
regionpart of the image to copy

Member Function Documentation

void ImageMap::blit ( const ImageMap source,
const GMathVec4i &  region,
const ImagePixel::BlitMode &  mode = ImagePixel::BLIT_MODE_REPLACE 
)

Copies the content of a tile from source to destination using the specified copy mode. (deprecated)

Parameters
sourceSource image
regionPortion of the channel to copy
modeCopy mode.
Note
Iterates on all channels
bool ImageMap::blit_bucket_aligned ( const ImageMap source,
const GMathVec4i &  region,
const ImagePixel::BlitMode &  mode = ImagePixel::BLIT_MODE_REPLACE 
)

Copies the content of a tile from source to destination using the specified copy mode.

Parameters
sourceSource image
regionPortion of the channel to copy
modeCopy mode.
Note
Iterates on all channels
void ImageMap::blit_visible ( const ImageMap source,
const GMathVec4i &  region,
const ImagePixel::BlitMode &  mode = ImagePixel::BLIT_MODE_REPLACE 
)

Copy data from the visible channels.

Parameters
regionpart of the image to copy
modecopy mode to use

void ImageMap::compute_image_edges ( ImageEvalContext context,
const GMathVec4i &  region 
)

Computes an extra line of pixels on the edge of an image so the texture evaluation works properly.

Note
This function will fill the image edges depending on repeat mode.
void ImageMap::copy_data ( const ImageMap src,
int  offset_x,
int  offset_y,
const GMathVec4i *  region = 0 
)

Copy data from another ImageMap.

Parameters
srcSource image.
offset_x,offset_yOffsets data during the copy.
regionIf not null, only the specified region will be copied.
void ImageMap::create_buffer_rgba ( ImageEvalContext context,
const GMathVec4i &  region,
float *  out_buffer,
unsigned int  channel_size,
const ImagePixel::RepeatMode &  x_mode,
const ImagePixel::RepeatMode &  y_mode 
) const

Creates a buffer of floats that contains the color values of the RGBA channels of the image for the specified region.

Parameters
regionPart of the image to extract
out_bufferThis buffer will be filled with data from the channels. Its size must be at least channel_size * 4.
channel_sizeoffset to jump from one channel to the other in the buffer. Must be at least region[2] * region[3]
x_mode,y_moderepeat mode to use if the region is outside of the Image canvas.
Note
The buffer is not interlaced. It will contains all Red values, then Green, etc... If the alpha channel doesn't exist, the part of the buffer for the alpha data will be filled with '1's.
If the image is Luminance only, R, G, B parts of the buffer will contain the same data.
  • Red data is found at out_buffer[0].
  • Green data is found at out_buffer[channel_size].
  • Blue data is found at out_buffer[channel_size * 2].
  • Alpha data is found at out_buffer[channel_size * 3].
void ImageMap::create_rgba_channels ( const GMathVec4i &  region)

Creates R,G,B,A channels and the tiles for the specified region if they don't exist.

Note
Tiles are not created if the channel already exists.
void ImageMap::create_tiles ( const GMathVec4i &  region,
bool  visible_only = false 
)

Creates tiles for the specified region in all channels.

Parameters
visible_onlyif set to true, tile are created only for RGBA and Luminance channels, if they exist.
void ImageMap::dirty_border ( const GMathVec4i &  region)

Dirty all the tiles of all channels that intersect the region.

void ImageMap::fill_channels_from_buffer ( const GMathVec4i &  region,
unsigned int &  channel_count,
float *  in_buffer,
bool  process_region_edges = true 
)

Fill the first channels of the image using the data given as parameter.

Parameters
regionRegion of the image to fill.
channel_countNumber of channels to fill
in_bufferData buffer. Can be of any data type.
process_region_edgesEnable/disable the edge processing needed to bilinear filtering.
Note
The size of the data buffer must be : region[2] * region[3] * channel_count.
The data buffer must be linear (not interlaced):
  • Red data is found at in_buffer[0].
  • Green data is found at in_buffer[region_size].
  • Blue data is found at in_buffer[region_size * 2].
  • Alpha data is found at in_buffer[region_size * 3].
void ImageMap::fill_from ( const ImageMap src,
const GMathVec4i &  src_data_region,
const GMathVec4i &  dest_data_region,
AppBase app 
)

Fills the image using the content of the source image.

Parameters
sourceSource image
src_data_regionregion of the source image in which data will be read
dest_data_regionregion of the destination image in which data will be written. The dest region will be filled with extra data using the EDGE repeat mode if bigger that the source data region.
Note
Data format of the source image is ignored. After the copy. Existing channels in the destination channel are removed before the copy.
void ImageMap::fill_from_buffer_rgba ( const GMathVec4i &  region,
float *  in_buffer,
bool  process_region_edges = true 
)

Fill the image using the float buffer given as parameter.

Parameters
regionRegion of the image to fill.
in_bufferData buffer.
process_region_edgesEnable/disable the edge processing needed to bilinear filtering.
Note
This function will take into account its current parameters, and:
  • ignore the alpha values in the buffer if it doesn't have an alpha channel.
  • convert the RGB values to Luminance if needed.
If the image doesn't have an alpha channel, the input data buffer can contain only RGB values.
The size of the data buffer must be : region[2] * region[3] * 4 (3 if no alpha).
The data buffer must be linear (not interlaced): Red data is found at in_buffer[0].
Green data is found at in_buffer[region_size].
Blue data is found at in_buffer[region_size * 2].
Alpha data is found at in_buffer[region_size * 3]. (if applicable)
void ImageMap::fill_rgba_from_channels ( const ImageMap src,
const CoreBasicArray< CoreString > &  channel_names,
int  offset_x,
int  offset_y,
const GMathVec4i *  region 
)

Fill the RGBA channels of the current image using data from the specified channels of the source image.

Parameters
srcThe ImageMap to copy data from.
channel_namesnames of the channels of the source image to copy.
offset_x,offset_yoffset to apply during the copy
regionregion to copy. If null, the whole image is copied.
Note
Use this function to redirect data of custom channels (Aovs) to RGBA.
void ImageMap::get_bounding_box ( GMathBbox2i &  bbox) const

Compute the bounding box of the data actually stored in the image.

Note
The bounding box does not delimitate the image, it's an hint to know which parts of the image has actually been filled.
void ImageMap::get_clean_tiles ( const GMathVec4i &  region,
CoreArray< ImageMapTileHandle > *  tiles,
unsigned int &  items_count 
)

Returns a list of clean tiles for the specified region.

Parameters
[in]regionRegion of the image that will be used.
[out]sorted_tilesArray of CoreArray. The size of the array must be at least 4 (number of channels that are used).
[out]items_countnumber of tiles in each array.
Note
The function works like get_sorted_tiles, with only one differences: tiles will not never be created.
const ImagePixel::Depth& ImageMap::get_depth ( ) const
inline

Returns the image depth.

Note
Only valid for visible channels. Z and custom channels are not taken into account.
bool ImageMap::get_dirty_tiles ( const GMathVec4i &  region,
CoreArray< ImageMapTileHandle > *  sorted_tiles,
CoreArray< bool > &  dirtiness_flag,
unsigned int &  items_count 
)

Returns a list of dirty tiles for the specified region.

Parameters
[in]regionRegion of the image that will be used.
[out]sorted_tilesArray of CoreArray. The size of the array must be at least 4 (number of channels that are used).
[out]dirtiness_flagThis array indicates whether or not a dirty tile exists at each spot.
[out]items_countnumber of tiles in each array.
Note
The function works like get_sorted_tiles, but with some differences:
Tiles are always created if they don't exist. An empty cell means the tile at this spot is clean.
dirtiness_flag[i] will be set to true if at list one CoreArray have a tile set at index i. (ie one channel has a dirty tile at this spot)
size_t ImageMap::get_memory_size ( void  ) const
overridevirtual

Get the amount of memory occupied by the resource.

Returns an estimate in bytes of the data allocated by the object.

Reimplemented from ResourceData.

void ImageMap::get_pixel_bilinear ( ImageEvalContext context,
const MapEvalCtx eval_ctx,
const float &  x,
const float &  y,
const GMathVec4i &  canvas,
GMathVec4f &  color,
const ImagePixel::RepeatMode &  x_mode = ImagePixel::DEFAULT,
const ImagePixel::RepeatMode &  y_mode = ImagePixel::DEFAULT 
) const

Returns the value of the pixel at the given coordinates, using bilinear filtering.

Parameters
eval_ctxStructure containing all the parameters needed to compute the pixel color.
x,yCoordinates of the pixel to evaluates in the ImageMap.
canvasCurrent working region
[out]colorReturned value
x_mode,y_modeRepeat mode to use if the pixel is on the edge of the canvas.
void ImageMap::get_pixel_nearest ( ImageEvalContext context,
const MapEvalCtx eval_ctx,
float  x,
float  y,
const GMathVec4i &  canvas,
GMathVec4f &  color,
const ImagePixel::RepeatMode &  x_mode = ImagePixel::DEFAULT,
const ImagePixel::RepeatMode &  y_mode = ImagePixel::DEFAULT 
) const

Returns the value of the pixel at the given coordinates.

Parameters
contextContext used for caching purposes
eval_ctxStructure containing all the parameters needed to compute the pixel color.
x,yCoordinates of the pixel to evaluates in the ImageMap.
canvasCurrent working region
[out]colorReturned value
x_mode,y_modeRepeat mode to use if the pixel is on the edge of the canvas.
void ImageMap::get_rgba_channels ( ImageMapChannels channels_vector) const

Get the RGBA channels of the image.

Parameters
channels_vectorVector that will contain the channels of RGBA
Note
Get all Red values, then Green, etc... If the alpha channel doesn't exist, the channel alpha will be empty.
If the image is Luminance only, R, G, B channels will contain the same data.
  • Red data is found at channels_vector[0].
  • Green data is found at channels_vector[1].
  • Blue data is found at channels_vector[2].
  • Alpha data is found at channels_vector[3].
void ImageMap::get_sorted_tiles ( const GMathVec4i &  region,
CoreArray< ImageMapTileHandle > *  sorted_tiles,
unsigned int &  items_count,
bool  allow_empty = true 
) const

Returns a sorted list of tiles pointers for the specified region.

Parameters
[in]regionRegion of the image that will be used.
[out]sorted_tilesArray of CoreArray. The size of the array must be at least 4 (number of channels that are used).
[out]items_countnumber of tiles in each array.
[in]allow_emptyif set to false, tiles will be created if needed (if no tile exists at a particular spot).
If set to true, some cells of the arrays may be null.
Note
Each CoreArray contains the tiles of the region for one channel and are resized to match the number of tiles that may be contained in the specified region. Then for each tile of each channel, we compute the index of the tile in the output array using the tile's coordinates => all i-th tiles of every CoreArray have the same coordinates.
void ImageMap::make_half ( ImageEvalContext context,
ImageMap up_image,
const GMathVec4i &  region 
) const

Computes a half-sized mipmap from another ImageMap.

Parameters
contextPyramid context used for caching
up_imageHigher level mipmap that will be evaluated
regionRegion to compute, for the current mipmap level
void ImageMap::move_data ( const int &  offset_x,
const int &  offset_y 
)

Shift the data of the image.

void ImageMap::on_update_visible ( const GMathBbox2i &  old_region,
const GMathBbox2i &  new_region 
)

Updates the image channels after the visible part of the region has been modified.

Note
This function is used by the render region feature to make sure that the parts of the image are correctly set before rendering. Tiles outside the region are cleared and set to clean, tiles inside or cutting the region are set to dirty, so they are recomputed in the next render.

void ImageMap::process_visible ( ImageMapCtx ctx,
ImageChannelProcess_callback  process,
void *  user_data = 0,
const GMathVec4i *  region = 0 
)

Apply a process on the visible channels of the image.

Parameters
processfunction callback that will be called on each pixel
user_datacustom data that can be used to store parameters
regionpart of the image the process will be applied on.

void ImageMap::set_auto_check_uniformity ( const bool &  flag)
inline

Enable/disable auto check uniformity.

Note
If enabled, tiles will be automatically parsed after being updated to check if they have an uniform color, to save memory
void ImageMap::set_bounding_box ( const GMathBbox2i &  bbox)

Sets the bounding box of the data actually stored in the image.

Note
The bounding box does not delimitate the image, it's an hint to know which parts of the image has actually been filled.
void ImageMap::set_data ( const unsigned char *  data,
const unsigned int &  data_size,
const GMathVec4i &  canvas,
const char *  name 
) const

Fill a channel using the data passed as parameter.

Parameters
datainput buffer
data_sizesize of the input buffer, in bytes
canvasregion to fill
namename of the channel to write into.
Note
data can contain anything (char, half, float, int...). No conversion is done.
void ImageMap::set_data ( const float *  data,
const unsigned int &  data_size,
const GMathVec4i &  canvas,
const KnownChannels  index 
) const

Fill a channel using the float buffer passed as parameter.

Parameters
datainput buffer
data_sizesize of the input buffer, in bytes
canvasregion to fill
indexindex of the channel to write into.
void ImageMap::set_depth ( ImagePixel::Depth  depth,
ImagePixel::BitDepth  bit_depth,
ImagePixel::BitType  bit_type 
)
inline

Set image data format:

Parameters
depthnumber of visible channels
bit_depthsize of single pixel
bit_typetype of pixels
void ImageMap::update_custom_channels ( const CoreVector< CoreString > &  to_remove,
const CoreVector< CoreString > &  to_add 
)

Updates the list of channels in the image.

Parameters
to_removethese channels will be removed if they exists
to_removethese channels will be added if they don't.