[Bf-blender-cvs] [6e4d2fa9140] master: Cleanup: add image_format.cc for functions related to ImageFormatData
Brecht Van Lommel
noreply at git.blender.org
Mon Mar 21 16:43:40 CET 2022
Commit: 6e4d2fa9140864a13356b07ffca082817822987f
Author: Brecht Van Lommel
Date: Fri Mar 11 17:50:57 2022 +0100
Branches: master
https://developer.blender.org/rB6e4d2fa9140864a13356b07ffca082817822987f
Cleanup: add image_format.cc for functions related to ImageFormatData
Also fixes missing code to read/write/free/copy color management settings
in various places. This can't be set through the UI currently, but still
should be handled consistently.
===================================================================
M source/blender/blenkernel/BKE_image.h
A source/blender/blenkernel/BKE_image_format.h
M source/blender/blenkernel/BKE_image_save.h
M source/blender/blenkernel/CMakeLists.txt
M source/blender/blenkernel/intern/dynamicpaint.c
M source/blender/blenkernel/intern/image.cc
A source/blender/blenkernel/intern/image_format.cc
M source/blender/blenkernel/intern/image_save.c
M source/blender/blenkernel/intern/node.cc
M source/blender/blenkernel/intern/ocean.c
M source/blender/blenkernel/intern/packedFile.c
M source/blender/blenkernel/intern/scene.c
M source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cc
M source/blender/compositor/operations/COM_OutputFileOperation.cc
M source/blender/editors/object/object_bake_api.c
M source/blender/editors/render/render_internal.cc
M source/blender/editors/render/render_opengl.cc
M source/blender/editors/screen/screendump.c
M source/blender/editors/space_image/image_buttons.c
M source/blender/editors/space_image/image_ops.c
M source/blender/imbuf/intern/colormanagement.c
M source/blender/io/collada/ImageExporter.cpp
M source/blender/io/usd/intern/usd_writer_material.cc
M source/blender/makesdna/DNA_scene_types.h
M source/blender/makesrna/intern/rna_image.c
M source/blender/makesrna/intern/rna_scene.c
M source/blender/nodes/composite/nodes/node_composite_output_file.cc
M source/blender/render/intern/pipeline.c
M source/blender/render/intern/render_result.c
M source/blender/windowmanager/intern/wm_operators.c
M source/creator/creator_args.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index ea0202e3b5f..7b3124cca26 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -90,7 +90,6 @@ int BKE_imbuf_write_stamp(struct Scene *scene,
/**
* \note imf->planes is ignored here, its assumed the image channels are already set.
*/
-void BKE_imbuf_write_prepare(struct ImBuf *ibuf, const struct ImageFormatData *imf);
int BKE_imbuf_write(struct ImBuf *ibuf, const char *name, const struct ImageFormatData *imf);
/**
* Same as #BKE_imbuf_write() but crappy workaround not to permanently modify _some_,
@@ -100,43 +99,6 @@ int BKE_imbuf_write_as(struct ImBuf *ibuf,
const char *name,
struct ImageFormatData *imf,
bool save_copy);
-void BKE_image_path_from_imformat(char *string,
- const char *base,
- const char *relbase,
- int frame,
- const struct ImageFormatData *im_format,
- bool use_ext,
- bool use_frames,
- const char *suffix);
-void BKE_image_path_from_imtype(char *string,
- const char *base,
- const char *relbase,
- int frame,
- char imtype,
- bool use_ext,
- bool use_frames,
- const char *suffix);
-int BKE_image_path_ensure_ext_from_imformat(char *string, const struct ImageFormatData *im_format);
-int BKE_image_path_ensure_ext_from_imtype(char *string, char imtype);
-char BKE_image_ftype_to_imtype(int ftype, const struct ImbFormatOptions *options);
-int BKE_image_imtype_to_ftype(char imtype, struct ImbFormatOptions *r_options);
-
-bool BKE_imtype_is_movie(char imtype);
-bool BKE_imtype_supports_zbuf(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,
- * keep in sync with `creator_args.c` help info.
- */
-char BKE_imtype_from_arg(const char *arg);
-
-void BKE_imformat_defaults(struct ImageFormatData *im_format);
-void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const struct ImBuf *imbuf);
/**
* Used by sequencer too.
@@ -171,10 +133,6 @@ struct RenderResult;
#define IMA_SIGNAL_USER_NEW_IMAGE 6
#define IMA_SIGNAL_COLORMANAGE 7
-#define IMA_CHAN_FLAG_BW 1
-#define IMA_CHAN_FLAG_RGB 2
-#define IMA_CHAN_FLAG_ALPHA 4
-
/**
* Checks whether there's an image buffer for given image and user.
*/
diff --git a/source/blender/blenkernel/BKE_image_format.h b/source/blender/blenkernel/BKE_image_format.h
new file mode 100644
index 00000000000..189d2db1b4f
--- /dev/null
+++ b/source/blender/blenkernel/BKE_image_format.h
@@ -0,0 +1,80 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
+
+#pragma once
+
+/** \file
+ * \ingroup bke
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct BlendDataReader;
+struct BlendWriter;
+struct ImbFormatOptions;
+struct ImageFormatData;
+struct ImBuf;
+
+/* 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 */
+
+void BKE_image_path_from_imformat(char *string,
+ const char *base,
+ const char *relbase,
+ int frame,
+ const struct ImageFormatData *im_format,
+ bool use_ext,
+ bool use_frames,
+ const char *suffix);
+void BKE_image_path_from_imtype(char *string,
+ const char *base,
+ const char *relbase,
+ int frame,
+ char imtype,
+ bool use_ext,
+ bool use_frames,
+ const char *suffix);
+int BKE_image_path_ensure_ext_from_imformat(char *string, const struct ImageFormatData *im_format);
+int BKE_image_path_ensure_ext_from_imtype(char *string, char imtype);
+
+/* File Types */
+
+#define IMA_CHAN_FLAG_BW 1
+#define IMA_CHAN_FLAG_RGB 2
+#define IMA_CHAN_FLAG_ALPHA 4
+
+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_zbuf(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,
+ * keep in sync with `creator_args.c` help info.
+ */
+char BKE_imtype_from_arg(const char *arg);
+
+/* Conversion between ImBuf settings. */
+
+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);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/blenkernel/BKE_image_save.h b/source/blender/blenkernel/BKE_image_save.h
index ea9ed7d2d26..dea1c25cd5e 100644
--- a/source/blender/blenkernel/BKE_image_save.h
+++ b/source/blender/blenkernel/BKE_image_save.h
@@ -36,6 +36,8 @@ typedef struct ImageSaveOptions {
void BKE_image_save_options_init(struct ImageSaveOptions *opts,
struct Main *bmain,
struct Scene *scene);
+void BKE_image_save_options_free(struct ImageSaveOptions *opts);
+
bool BKE_image_save(struct ReportList *reports,
struct Main *bmain,
struct Image *ima,
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 2aedd26616e..3cc65fd252b 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -156,6 +156,7 @@ set(SRC
intern/idprop_utils.c
intern/idtype.c
intern/image.cc
+ intern/image_format.cc
intern/image_partial_update.cc
intern/image_gen.c
intern/image_gpu.cc
@@ -383,6 +384,7 @@ set(SRC
BKE_idprop.hh
BKE_idtype.h
BKE_image.h
+ BKE_image_format.h
BKE_image_partial_update.hh
BKE_image_save.h
BKE_ipo.h
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index d70ab8ed606..8ec7bbea0e5 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -44,6 +44,7 @@
#include "BKE_dynamicpaint.h"
#include "BKE_effect.h"
#include "BKE_image.h"
+#include "BKE_image_format.h"
#include "BKE_lib_id.h"
#include "BKE_main.h"
#include "BKE_material.h"
diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc
index d78d508336b..51ffd3338c4 100644
--- a/source/blender/blenkernel/intern/image.cc
+++ b/source/blender/blenkernel/intern/image.cc
@@ -68,6 +68,7 @@
#include "BKE_icons.h"
#include "BKE_idtype.h"
#include "BKE_image.h"
+#include "BKE_image_format.h"
#include "BKE_lib_id.h"
#include "BKE_main.h"
#include "BKE_node.h"
@@ -1490,607 +1491,6 @@ void BKE_image_all_free_anim_ibufs(Main *bmain, int cfra)
/** \name Read and Write
* \{ */
-int BKE_image_imtype_to_ftype(const char imtype, ImbFormatOptions *r_options)
-{
- memset(r_options, 0, sizeof(*r_options));
-
- if (imtype == R_IMF_IMTYPE_TARGA) {
- return IMB_FTYPE_TGA;
- }
- if (imtype == R_IMF_IMTYPE_RAWTGA) {
- r_options->flag = RAWTGA;
- return IMB_FTYPE_TGA;
- }
- if (imtype == R_IMF_IMTYPE_IRIS) {
- return IMB_FTYPE_IMAGIC;
- }
-#ifdef WITH_HDR
- if (imtype == R_IMF_IMTYPE_RADHDR) {
- return IMB_FTYPE_RADHDR;
- }
-#endif
- if (imtype == R_IMF_IMTYPE_PNG) {
- r_options->quality = 15;
- return IMB_FTYPE_PNG;
- }
-#ifdef WITH_DDS
- if (imtype == R_IMF_IMTYPE_DDS) {
- return IMB_FTYPE_DDS;
- }
-#endif
- if (imtype == R_IMF_IMTYPE_BMP) {
- return IMB_FTYPE_BMP;
- }
-#ifdef WITH_TIFF
- if (imtype == R_IMF_IMTYPE_TIFF) {
- return IMB_FTYPE_TIF;
- }
-#endif
- if (ELEM(imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) {
- return IMB_FTYPE_OPENEXR;
- }
-#ifdef WITH_CINEON
- if (imtype == R_IMF_IMTYPE_CINEON) {
- return IMB_FTYPE_CINEON;
- }
- if (imtype == R_IMF_IMTYPE_DPX) {
- return IMB_FTYPE_DPX;
- }
-#endif
-#ifdef WITH_OPENJPEG
- if (imtype == R_IMF_IMTYPE_JP2) {
- r_options->flag |= JP2_JP2;
- r_options->quality = 90;
- return IMB_FTYPE_JP2;
- }
-#endif
-
- r_options->quality = 90;
- return IMB_FTYPE_JPG;
-}
-
-char BKE_image_ftype_to_imtype(const int ftype, const ImbFormatOptions *options)
-{
- if (ftype == IMB_FTYPE_NONE) {
- return R_IMF_IMTYPE_TARGA;
- }
- if (ftype == IMB_FTYPE_IMAGIC) {
- return R_IMF_IMTYPE_IRIS;
- }
-#ifdef WITH_HDR
- if (ftype == IMB_FTYPE_RADHDR) {
- return R_IMF_IMTYPE_RADHDR;
- }
-#endif
- if (ftype == IMB_FTYPE_PNG) {
- return R_IMF_IMTYPE_PNG;
- }
-#ifdef WITH_DDS
- if (ftype == IMB_FTYPE_DDS) {
- return R_IMF_IMTYPE_DDS;
- }
-#endif
- if (ftype == IMB_FTYPE_BMP) {
- return R_IMF_IMTYPE_BMP;
- }
-#ifdef
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list