2023-08-15 16:20:26 +02:00
|
|
|
/* SPDX-FileCopyrightText: 2005 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2007-09-02 19:25:03 +02:00
|
|
|
|
2019-02-17 22:08:12 +01:00
|
|
|
/** \file
|
|
|
|
* \ingroup imbuf
|
2011-02-27 21:23:21 +01:00
|
|
|
*/
|
|
|
|
|
2012-02-17 19:59:41 +01:00
|
|
|
#pragma once
|
2007-09-02 19:25:03 +02:00
|
|
|
|
2020-03-02 15:20:13 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2018-04-05 16:27:15 +02:00
|
|
|
struct IDProperty;
|
2019-01-28 11:08:24 +01:00
|
|
|
struct ImBuf;
|
|
|
|
struct anim;
|
2007-09-02 19:25:03 +02:00
|
|
|
|
2019-11-24 15:14:39 +01:00
|
|
|
/**
|
|
|
|
* The metadata is a list of key/value pairs (both char *) that can me
|
2012-03-09 19:28:30 +01:00
|
|
|
* saved in the header of several image formats.
|
|
|
|
* Apart from some common keys like
|
2021-02-05 06:23:34 +01:00
|
|
|
* 'Software' and 'Description' (PNG standard) we'll use keys within the
|
2012-03-09 19:28:30 +01:00
|
|
|
* Blender namespace, so should be called 'Blender::StampInfo' or 'Blender::FrameNum'
|
|
|
|
* etc...
|
2018-04-05 16:27:15 +02:00
|
|
|
*
|
|
|
|
* The keys & values are stored in ID properties, in the group "metadata".
|
2012-03-09 19:28:30 +01:00
|
|
|
*/
|
2007-09-02 19:25:03 +02:00
|
|
|
|
2019-11-24 15:14:39 +01:00
|
|
|
/**
|
|
|
|
* Ensure that the metadata property is a valid #IDProperty object.
|
2018-04-05 16:27:15 +02:00
|
|
|
* This is a no-op when *metadata != NULL.
|
|
|
|
*/
|
|
|
|
void IMB_metadata_ensure(struct IDProperty **metadata);
|
|
|
|
void IMB_metadata_free(struct IDProperty *metadata);
|
2007-09-02 19:25:03 +02:00
|
|
|
|
2019-11-24 15:14:39 +01:00
|
|
|
/**
|
|
|
|
* Read the field from the image info into the field.
|
|
|
|
* \param metadata: the #IDProperty that contains the metadata
|
2019-02-17 22:08:12 +01:00
|
|
|
* \param key: the key of the field
|
|
|
|
* \param value: the data in the field, first one found with key is returned,
|
2023-05-13 09:34:23 +02:00
|
|
|
* memory has to be allocated by user.
|
2019-02-17 22:08:12 +01:00
|
|
|
* \param len: length of value buffer allocated by user.
|
2019-11-24 15:14:39 +01:00
|
|
|
* \return 1 (true) if metadata is present and value for the key found, 0 (false) otherwise.
|
2018-04-05 16:27:15 +02:00
|
|
|
*/
|
2023-05-13 09:34:23 +02:00
|
|
|
bool IMB_metadata_get_field(struct IDProperty *metadata,
|
|
|
|
const char *key,
|
|
|
|
char *value,
|
|
|
|
size_t value_maxncpy);
|
2007-09-02 19:25:03 +02:00
|
|
|
|
2019-11-24 15:14:39 +01:00
|
|
|
/**
|
|
|
|
* Set user data in the metadata.
|
2018-04-05 16:27:15 +02:00
|
|
|
* If the field already exists its value is overwritten, otherwise the field
|
|
|
|
* will be added with the given value.
|
2019-11-24 15:14:39 +01:00
|
|
|
* \param metadata: the #IDProperty that contains the metadata
|
2019-02-17 22:08:12 +01:00
|
|
|
* \param key: the key of the field
|
|
|
|
* \param value: the data to be written to the field. zero terminated string
|
2007-09-02 19:25:03 +02:00
|
|
|
*/
|
2018-04-05 16:27:15 +02:00
|
|
|
void IMB_metadata_set_field(struct IDProperty *metadata, const char *key, const char *value);
|
2007-09-02 19:25:03 +02:00
|
|
|
|
2018-04-05 16:27:15 +02:00
|
|
|
void IMB_metadata_copy(struct ImBuf *dimb, struct ImBuf *simb);
|
2018-04-05 16:34:36 +02:00
|
|
|
struct IDProperty *IMB_anim_load_metadata(struct anim *anim);
|
2007-09-02 19:25:03 +02:00
|
|
|
|
2019-02-06 11:49:41 +01:00
|
|
|
/* Invoke callback for every value stored in the metadata. */
|
|
|
|
typedef void (*IMBMetadataForeachCb)(const char *field, const char *value, void *userdata);
|
|
|
|
void IMB_metadata_foreach(struct ImBuf *ibuf, IMBMetadataForeachCb callback, void *userdata);
|
|
|
|
|
2020-03-02 15:20:13 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|