Blender  V3.3
Functions
metadata.c File Reference
#include <stdlib.h>
#include <string.h>
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BKE_idprop.h"
#include "DNA_ID.h"
#include "MEM_guardedalloc.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "IMB_metadata.h"

Go to the source code of this file.

Functions

void IMB_metadata_ensure (struct IDProperty **metadata)
 
void IMB_metadata_free (struct IDProperty *metadata)
 
bool IMB_metadata_get_field (struct IDProperty *metadata, const char *key, char *field, const size_t len)
 
void IMB_metadata_copy (struct ImBuf *dimb, struct ImBuf *simb)
 
void IMB_metadata_set_field (struct IDProperty *metadata, const char *key, const char *value)
 
void IMB_metadata_foreach (struct ImBuf *ibuf, IMBMetadataForeachCb callback, void *userdata)
 

Function Documentation

◆ IMB_metadata_copy()

void IMB_metadata_copy ( struct ImBuf dimb,
struct ImBuf simb 
)

◆ IMB_metadata_ensure()

void IMB_metadata_ensure ( struct IDProperty **  metadata)

The metadata is a list of key/value pairs (both char *) that can me saved in the header of several image formats. Apart from some common keys like 'Software' and 'Description' (PNG standard) we'll use keys within the Blender namespace, so should be called 'Blender::StampInfo' or 'Blender::FrameNum' etc...

The keys & values are stored in ID properties, in the group "metadata". Ensure that the metadata property is a valid IDProperty object. This is a no-op when *metadata != NULL.

Definition at line 25 of file metadata.c.

References IDP_GROUP, IDP_New(), and NULL.

Referenced by BKE_imbuf_stamp_info(), BKE_stamp_info_from_imbuf(), ibJpegImageFromCinfo(), IMB_anim_load_metadata(), imb_load_openexr(), imb_loadpng(), IMB_thumb_load_image(), and thumb_create_ex().

◆ IMB_metadata_foreach()

void IMB_metadata_foreach ( struct ImBuf ibuf,
IMBMetadataForeachCb  callback,
void userdata 
)

◆ IMB_metadata_free()

void IMB_metadata_free ( struct IDProperty metadata)

Definition at line 35 of file metadata.c.

References IDP_FreeProperty(), and NULL.

Referenced by image_get_render_result(), IMB_free_anim(), IMB_freeImBuf(), and IMB_metadata_copy().

◆ IMB_metadata_get_field()

bool IMB_metadata_get_field ( struct IDProperty metadata,
const char *  key,
char *  value,
size_t  len 
)

Read the field from the image info into the field.

Parameters
metadatathe IDProperty that contains the metadata
keythe key of the field
valuethe data in the field, first one found with key is returned, memory has to be allocated by user.
lenlength of value buffer allocated by user.
Returns
1 (true) if metadata is present and value for the key found, 0 (false) otherwise.

Definition at line 44 of file metadata.c.

References BLI_strncpy(), IDP_GetPropertyFromGroup(), IDP_String, IDP_STRING, len, NULL, and IDProperty::type.

Referenced by IMB_thumb_manage(), metadata_get_field(), and metadata_is_valid().

◆ IMB_metadata_set_field()

void IMB_metadata_set_field ( struct IDProperty metadata,
const char *  key,
const char *  value 
)

Set user data in the metadata. If the field already exists its value is overwritten, otherwise the field will be added with the given value.

Parameters
metadatathe IDProperty that contains the metadata
keythe key of the field
valuethe data to be written to the field. zero terminated string

Definition at line 73 of file metadata.c.

References BLI_assert, IDP_AddToGroup(), IDP_AssignString(), IDP_FreeFromGroup(), IDP_GetPropertyFromGroup(), IDP_NewString(), IDP_STRING, NULL, and IDProperty::type.

Referenced by ibJpegImageFromCinfo(), IMB_anim_load_metadata(), imb_load_openexr(), imb_loadpng(), IMB_thumb_load_image(), metadata_set_field(), and thumb_create_ex().