2023-05-31 16:19:06 +02:00
|
|
|
/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2022-03-11 17:50:57 +01:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
* \ingroup bke
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct BlendDataReader;
|
|
|
|
struct BlendWriter;
|
|
|
|
struct ImbFormatOptions;
|
|
|
|
struct ImageFormatData;
|
|
|
|
struct ImBuf;
|
2022-03-11 18:21:05 +01:00
|
|
|
struct Scene;
|
2022-03-11 17:50:57 +01:00
|
|
|
|
|
|
|
/* Init/Copy/Free */
|
|
|
|
|
|
|
|
void BKE_image_format_init(struct ImageFormatData *imf, const bool render);
|
|
|
|
void BKE_image_format_copy(struct ImageFormatData *imf_dst, const struct ImageFormatData *imf_src);
|
|
|
|
void BKE_image_format_free(struct ImageFormatData *imf);
|
|
|
|
|
|
|
|
void BKE_image_format_blend_read_data(struct BlendDataReader *reader, struct ImageFormatData *imf);
|
|
|
|
void BKE_image_format_blend_write(struct BlendWriter *writer, struct ImageFormatData *imf);
|
|
|
|
|
|
|
|
/* File Paths */
|
|
|
|
|
2023-05-03 06:13:27 +02:00
|
|
|
void BKE_image_path_from_imformat(char *filepath,
|
2022-03-11 17:50:57 +01:00
|
|
|
const char *base,
|
|
|
|
const char *relbase,
|
|
|
|
int frame,
|
|
|
|
const struct ImageFormatData *im_format,
|
|
|
|
bool use_ext,
|
|
|
|
bool use_frames,
|
|
|
|
const char *suffix);
|
2023-05-03 06:13:27 +02:00
|
|
|
void BKE_image_path_from_imtype(char *filepath,
|
2022-03-11 17:50:57 +01:00
|
|
|
const char *base,
|
|
|
|
const char *relbase,
|
|
|
|
int frame,
|
|
|
|
char imtype,
|
|
|
|
bool use_ext,
|
|
|
|
bool use_frames,
|
|
|
|
const char *suffix);
|
2023-05-05 04:40:27 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The number of extensions an image may have (`.jpg`, `.jpeg` for example).
|
|
|
|
* Add 1 as the array is nil terminated.
|
|
|
|
*/
|
|
|
|
#define BKE_IMAGE_PATH_EXT_MAX 3
|
|
|
|
/**
|
|
|
|
* Fill in an array of acceptable image extensions for the image format.
|
|
|
|
*
|
|
|
|
* \note In the case a file has no valid extension,
|
|
|
|
* the first extension should be used (`r_ext[0]`).
|
|
|
|
* \return the number of extensions assigned to `r_ext`, 0 for unsupported formats.
|
|
|
|
*/
|
|
|
|
int BKE_image_path_ext_from_imformat(const struct ImageFormatData *im_format,
|
|
|
|
const char *r_ext[BKE_IMAGE_PATH_EXT_MAX]);
|
|
|
|
int BKE_image_path_ext_from_imtype(const char imtype, const char *r_ext[BKE_IMAGE_PATH_EXT_MAX]);
|
|
|
|
|
|
|
|
int BKE_image_path_ext_from_imformat_ensure(char *filepath,
|
|
|
|
size_t filepath_maxncpy,
|
2023-05-03 06:13:27 +02:00
|
|
|
const struct ImageFormatData *im_format);
|
2023-05-05 04:40:27 +02:00
|
|
|
int BKE_image_path_ext_from_imtype_ensure(char *filepath, size_t filepath_maxncpy, char imtype);
|
2022-03-11 17:50:57 +01:00
|
|
|
|
|
|
|
/* File Types */
|
|
|
|
|
|
|
|
#define IMA_CHAN_FLAG_BW 1
|
|
|
|
#define IMA_CHAN_FLAG_RGB 2
|
2022-10-03 19:56:51 +02:00
|
|
|
#define IMA_CHAN_FLAG_RGBA 4
|
2022-03-11 17:50:57 +01:00
|
|
|
|
|
|
|
char BKE_ftype_to_imtype(int ftype, const struct ImbFormatOptions *options);
|
|
|
|
int BKE_imtype_to_ftype(char imtype, struct ImbFormatOptions *r_options);
|
|
|
|
|
|
|
|
bool BKE_imtype_is_movie(char imtype);
|
|
|
|
bool BKE_imtype_supports_compress(char imtype);
|
|
|
|
bool BKE_imtype_supports_quality(char imtype);
|
|
|
|
bool BKE_imtype_requires_linear_float(char imtype);
|
|
|
|
char BKE_imtype_valid_channels(char imtype, bool write_file);
|
|
|
|
char BKE_imtype_valid_depths(char imtype);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* String is from command line `--render-format` argument,
|
2024-03-20 23:49:19 +01:00
|
|
|
* keep in sync with `creator_args.cc` help info.
|
2022-03-11 17:50:57 +01:00
|
|
|
*/
|
2022-08-23 03:05:50 +02:00
|
|
|
char BKE_imtype_from_arg(const char *imtype_arg);
|
2022-03-11 17:50:57 +01:00
|
|
|
|
2024-03-20 23:49:19 +01:00
|
|
|
/* Conversion between #ImBuf settings. */
|
2022-03-11 17:50:57 +01:00
|
|
|
|
|
|
|
void BKE_image_format_from_imbuf(struct ImageFormatData *im_format, const struct ImBuf *imbuf);
|
|
|
|
void BKE_image_format_to_imbuf(struct ImBuf *ibuf, const struct ImageFormatData *imf);
|
|
|
|
|
2022-05-13 16:03:26 +02:00
|
|
|
bool BKE_image_format_is_byte(const struct ImageFormatData *imf);
|
|
|
|
|
2022-03-11 18:21:05 +01:00
|
|
|
/* Color Management */
|
|
|
|
|
|
|
|
void BKE_image_format_color_management_copy(struct ImageFormatData *imf,
|
|
|
|
const struct ImageFormatData *imf_src);
|
|
|
|
void BKE_image_format_color_management_copy_from_scene(struct ImageFormatData *imf,
|
|
|
|
const struct Scene *scene);
|
|
|
|
|
|
|
|
/* Image Output
|
|
|
|
*
|
|
|
|
* Initialize an image format that can be used for file writing, including
|
|
|
|
* color management settings from the scene. */
|
|
|
|
|
|
|
|
void BKE_image_format_init_for_write(struct ImageFormatData *imf,
|
|
|
|
const struct Scene *scene_src,
|
|
|
|
const struct ImageFormatData *imf_src);
|
|
|
|
|
2022-03-11 17:50:57 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|