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 */
|
2012-04-30 16:24:11 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2013-02-11 14:24:35 +01:00
|
|
|
#include "DNA_vec_types.h" /* for rcti */
|
|
|
|
|
2023-05-18 10:19:01 +02:00
|
|
|
#include "BLI_sys_types.h"
|
|
|
|
|
2024-01-19 12:48:04 +01:00
|
|
|
#include "IMB_imbuf_enums.h"
|
2023-07-10 16:33:32 +02:00
|
|
|
|
2024-01-19 12:48:04 +01:00
|
|
|
struct ColormanageCache;
|
|
|
|
struct ColorSpace;
|
|
|
|
struct GPUTexture;
|
|
|
|
struct IDProperty;
|
2020-03-02 15:20:13 +01:00
|
|
|
|
2019-02-17 22:08:12 +01:00
|
|
|
/** \file
|
|
|
|
* \ingroup imbuf
|
2003-06-06 05:21:39 +02:00
|
|
|
* \brief Contains defines and structs used throughout the imbuf module.
|
|
|
|
* \todo Clean up includes.
|
2012-04-30 16:24:11 +02:00
|
|
|
*
|
|
|
|
* Types needed for using the image buffer.
|
|
|
|
*
|
2024-02-28 02:13:20 +01:00
|
|
|
* ImBuf is external code, slightly adapted to live in the Blender
|
2023-05-24 03:21:18 +02:00
|
|
|
* context. It requires an external JPEG module, and the AVI-module
|
2012-04-30 16:24:11 +02:00
|
|
|
* (also external code) in order to function correctly.
|
|
|
|
*
|
|
|
|
* This file contains types and some constants that go with them. Most
|
|
|
|
* are self-explanatory (e.g. IS_amiga tests whether the buffer
|
|
|
|
* contains an Amiga-format file).
|
2003-06-06 05:21:39 +02:00
|
|
|
*/
|
2002-11-25 12:16:17 +01:00
|
|
|
|
2015-07-13 14:00:07 +02:00
|
|
|
#define IMB_MIPMAP_LEVELS 20
|
2023-05-03 06:13:27 +02:00
|
|
|
#define IMB_FILEPATH_SIZE 1024
|
2006-12-20 18:57:56 +01:00
|
|
|
|
2003-05-30 03:50:46 +02:00
|
|
|
/**
|
|
|
|
* \ingroup imbuf
|
2022-06-07 06:53:20 +02:00
|
|
|
* This is the abstraction of an image. ImBuf is the basic type used for all imbuf operations.
|
2003-05-30 03:50:46 +02:00
|
|
|
*
|
2005-05-25 18:19:00 +02:00
|
|
|
* Also; add new variables to the end to save pain!
|
2003-05-30 03:50:46 +02:00
|
|
|
*/
|
2015-07-13 13:58:17 +02:00
|
|
|
|
2023-05-05 01:25:45 +02:00
|
|
|
/**
|
|
|
|
* #ImBuf::foptions.flag, type specific options.
|
|
|
|
* Some formats include compression rations on some bits.
|
|
|
|
*/
|
2015-07-13 13:58:17 +02:00
|
|
|
#define OPENEXR_HALF (1 << 8)
|
|
|
|
/* careful changing this, it's used in DNA as well */
|
|
|
|
#define OPENEXR_COMPRESS (15)
|
|
|
|
|
|
|
|
#ifdef WITH_CINEON
|
|
|
|
# define CINEON_LOG (1 << 8)
|
|
|
|
# define CINEON_16BIT (1 << 7)
|
|
|
|
# define CINEON_12BIT (1 << 6)
|
|
|
|
# define CINEON_10BIT (1 << 5)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef WITH_OPENJPEG
|
|
|
|
# define JP2_12BIT (1 << 9)
|
|
|
|
# define JP2_16BIT (1 << 8)
|
|
|
|
# define JP2_YCC (1 << 7)
|
|
|
|
# define JP2_CINE (1 << 6)
|
|
|
|
# define JP2_CINE_48FPS (1 << 5)
|
|
|
|
# define JP2_JP2 (1 << 4)
|
|
|
|
# define JP2_J2K (1 << 3)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define PNG_16BIT (1 << 10)
|
|
|
|
|
|
|
|
#define RAWTGA 1
|
|
|
|
|
2023-04-12 05:22:26 +02:00
|
|
|
#define TIF_16BIT (1 << 8)
|
|
|
|
#define TIF_COMPRESS_NONE (1 << 7)
|
|
|
|
#define TIF_COMPRESS_DEFLATE (1 << 6)
|
|
|
|
#define TIF_COMPRESS_LZW (1 << 5)
|
|
|
|
#define TIF_COMPRESS_PACKBITS (1 << 4)
|
2015-07-13 13:58:17 +02:00
|
|
|
|
2024-01-19 12:48:04 +01:00
|
|
|
struct ImbFormatOptions {
|
2015-07-13 13:58:17 +02:00
|
|
|
short flag;
|
2022-09-16 10:13:19 +02:00
|
|
|
/** Quality serves dual purpose as quality number for JPEG or compression amount for PNG. */
|
2019-01-14 06:15:33 +01:00
|
|
|
char quality;
|
2024-01-19 12:48:04 +01:00
|
|
|
};
|
2015-07-13 13:58:17 +02:00
|
|
|
|
2021-12-14 05:49:31 +01:00
|
|
|
/* -------------------------------------------------------------------- */
|
2024-02-28 02:13:20 +01:00
|
|
|
/** \name ImBuf Component flags
|
2020-03-06 12:08:03 +01:00
|
|
|
* \brief These flags determine the components of an ImBuf struct.
|
|
|
|
* \{ */
|
|
|
|
|
2024-01-19 12:48:04 +01:00
|
|
|
enum eImBufFlags {
|
2020-03-06 12:08:03 +01:00
|
|
|
IB_rect = 1 << 0,
|
|
|
|
IB_test = 1 << 1,
|
|
|
|
IB_mem = 1 << 4,
|
|
|
|
IB_rectfloat = 1 << 5,
|
|
|
|
IB_multilayer = 1 << 7,
|
|
|
|
IB_metadata = 1 << 8,
|
|
|
|
IB_animdeinterlace = 1 << 9,
|
2024-02-15 14:54:57 +01:00
|
|
|
/** Do not clear image pixel buffer to zero. Without this flag, allocating
|
|
|
|
* a new ImBuf does clear the pixel data to zero (transparent black). If
|
|
|
|
* whole pixel data is overwritten after allocation, then this flag can be
|
|
|
|
* faster since it avoids a memory clear. */
|
|
|
|
IB_uninitialized_pixels = 1 << 10,
|
2022-11-24 04:31:10 +01:00
|
|
|
|
2020-03-06 12:08:03 +01:00
|
|
|
/** indicates whether image on disk have premul alpha */
|
|
|
|
IB_alphamode_premul = 1 << 12,
|
|
|
|
/** if this flag is set, alpha mode would be guessed from file */
|
|
|
|
IB_alphamode_detect = 1 << 13,
|
|
|
|
/* alpha channel is unrelated to RGB and should not affect it */
|
|
|
|
IB_alphamode_channel_packed = 1 << 14,
|
|
|
|
/** ignore alpha on load and substitute it with 1.0f */
|
|
|
|
IB_alphamode_ignore = 1 << 15,
|
|
|
|
IB_thumbnail = 1 << 16,
|
|
|
|
IB_multiview = 1 << 17,
|
|
|
|
IB_halffloat = 1 << 18,
|
2024-01-19 12:48:04 +01:00
|
|
|
};
|
2020-03-06 12:08:03 +01:00
|
|
|
|
|
|
|
/** \} */
|
2021-12-14 05:49:31 +01:00
|
|
|
|
2023-05-18 10:19:01 +02:00
|
|
|
/* -------------------------------------------------------------------- */
|
2024-02-28 02:13:20 +01:00
|
|
|
/** \name ImBuf buffer storage
|
2023-05-18 10:19:01 +02:00
|
|
|
* \{ */
|
|
|
|
|
|
|
|
/* Specialization of an ownership whenever a bare pointer is provided to the ImBuf buffers
|
|
|
|
* assignment API. */
|
2024-01-19 12:48:04 +01:00
|
|
|
enum ImBufOwnership {
|
2023-05-18 10:19:01 +02:00
|
|
|
/* The ImBuf simply shares pointer with data owned by someone else, and will not perform any
|
|
|
|
* memory management when the ImBuf frees the buffer. */
|
|
|
|
IB_DO_NOT_TAKE_OWNERSHIP = 0,
|
|
|
|
|
|
|
|
/* The ImBuf takes ownership of the buffer data, and will use MEM_freeN() to free this memory
|
|
|
|
* when the ImBuf needs to free the data. */
|
|
|
|
IB_TAKE_OWNERSHIP = 1,
|
2024-01-19 12:48:04 +01:00
|
|
|
};
|
2023-05-18 10:19:01 +02:00
|
|
|
|
2024-03-25 14:09:54 +01:00
|
|
|
struct DDSData {
|
|
|
|
/** DDS fourcc info */
|
|
|
|
unsigned int fourcc;
|
|
|
|
/** The number of mipmaps in the dds file */
|
|
|
|
unsigned int nummipmaps;
|
|
|
|
/** The compressed image data */
|
|
|
|
unsigned char *data;
|
|
|
|
/** The size of the compressed data */
|
|
|
|
unsigned int size;
|
|
|
|
/** Who owns the data buffer. */
|
|
|
|
ImBufOwnership ownership;
|
|
|
|
};
|
|
|
|
|
2023-05-23 09:19:37 +02:00
|
|
|
/* Different storage specialization.
|
|
|
|
*
|
2024-01-18 21:50:23 +01:00
|
|
|
* NOTE: Avoid direct assignments and allocations, use the buffer utilities from the IMB_imbuf.hh
|
2023-07-10 16:33:32 +02:00
|
|
|
* instead.
|
2023-05-23 09:19:37 +02:00
|
|
|
*
|
2023-07-10 16:33:32 +02:00
|
|
|
* Accessing the data pointer directly is fine and is an expected way of accessing it. */
|
2023-05-18 10:19:01 +02:00
|
|
|
|
2024-01-19 12:48:04 +01:00
|
|
|
struct ImBufByteBuffer {
|
2023-05-18 10:19:01 +02:00
|
|
|
uint8_t *data;
|
|
|
|
ImBufOwnership ownership;
|
2023-06-23 15:55:42 +02:00
|
|
|
|
2024-01-19 12:48:04 +01:00
|
|
|
ColorSpace *colorspace;
|
|
|
|
};
|
2023-05-18 10:19:01 +02:00
|
|
|
|
2024-01-19 12:48:04 +01:00
|
|
|
struct ImBufFloatBuffer {
|
2023-05-18 10:19:01 +02:00
|
|
|
float *data;
|
|
|
|
ImBufOwnership ownership;
|
2023-06-23 15:55:42 +02:00
|
|
|
|
2024-01-19 12:48:04 +01:00
|
|
|
ColorSpace *colorspace;
|
|
|
|
};
|
2023-05-18 10:19:01 +02:00
|
|
|
|
2024-01-19 12:48:04 +01:00
|
|
|
struct ImBufGPU {
|
2023-07-10 16:33:32 +02:00
|
|
|
/* Texture which corresponds to the state of the ImBug on the GPU.
|
|
|
|
*
|
|
|
|
* Allocation is supposed to happen outside of the ImBug module from a proper GPU context.
|
|
|
|
* De-referencing the ImBuf or its GPU texture can happen from any state. */
|
|
|
|
/* TODO(sergey): This should become a list of textures, to support having high-res ImBuf on GPU
|
|
|
|
* without hitting hardware limitations. */
|
2024-01-19 12:48:04 +01:00
|
|
|
GPUTexture *texture;
|
|
|
|
};
|
2023-07-10 16:33:32 +02:00
|
|
|
|
2023-05-18 10:19:01 +02:00
|
|
|
/** \} */
|
|
|
|
|
2021-12-14 05:49:31 +01:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Image Buffer
|
|
|
|
* \{ */
|
|
|
|
|
2024-01-19 12:48:04 +01:00
|
|
|
struct ImBuf {
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 17:18:04 +02:00
|
|
|
/* dimensions */
|
2019-01-14 06:15:33 +01:00
|
|
|
/** Width and Height of our image buffer.
|
|
|
|
* Should be 'unsigned int' since most formats use this.
|
2021-03-21 03:18:20 +01:00
|
|
|
* but this is problematic with texture math in `imagetexture.c`
|
2019-01-14 06:15:33 +01:00
|
|
|
* avoid problems and use int. - campbell */
|
|
|
|
int x, y;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-06-03 05:39:37 +02:00
|
|
|
/** Active amount of bits/bit-planes. */
|
2019-01-14 06:15:33 +01:00
|
|
|
unsigned char planes;
|
|
|
|
/** Number of channels in `rect_float` (0 = 4 channel default) */
|
|
|
|
int channels;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 17:18:04 +02:00
|
|
|
/* flags */
|
2019-01-14 06:15:33 +01:00
|
|
|
/** Controls which components should exist. */
|
|
|
|
int flags;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 17:18:04 +02:00
|
|
|
/* pixels */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-05-27 07:10:58 +02:00
|
|
|
/**
|
|
|
|
* Image pixel buffer (8bit representation):
|
2016-01-14 21:08:28 +01:00
|
|
|
* - color space defaults to `sRGB`.
|
|
|
|
* - alpha defaults to 'straight'.
|
|
|
|
*/
|
2023-05-18 10:19:01 +02:00
|
|
|
ImBufByteBuffer byte_buffer;
|
|
|
|
|
2023-05-27 07:10:58 +02:00
|
|
|
/**
|
|
|
|
* Image pixel buffer (float representation):
|
2016-01-14 21:08:28 +01:00
|
|
|
* - color space defaults to 'linear' (`rec709`).
|
|
|
|
* - alpha defaults to 'premul'.
|
|
|
|
* \note May need gamma correction to `sRGB` when generating 8bit representations.
|
|
|
|
* \note Formats that support higher more than 8 but channels load as floats.
|
|
|
|
*/
|
2023-05-18 10:19:01 +02:00
|
|
|
ImBufFloatBuffer float_buffer;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-07-10 16:33:32 +02:00
|
|
|
/* Image buffer on the GPU. */
|
|
|
|
ImBufGPU gpu;
|
|
|
|
|
2020-06-11 06:56:09 +02:00
|
|
|
/** Resolution in pixels per meter. Multiply by `0.0254` for DPI. */
|
2011-05-13 16:27:12 +02:00
|
|
|
double ppm[2];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 17:18:04 +02:00
|
|
|
/* parameters used by conversion between byte and float */
|
2019-01-14 06:15:33 +01:00
|
|
|
/** random dither value, for conversion from float -> byte rect */
|
|
|
|
float dither;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 17:18:04 +02:00
|
|
|
/* mipmapping */
|
2019-01-14 06:15:33 +01:00
|
|
|
/** MipMap levels, a series of halved images */
|
2024-01-19 12:48:04 +01:00
|
|
|
ImBuf *mipmap[IMB_MIPMAP_LEVELS];
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 17:18:04 +02:00
|
|
|
int miptot, miplevel;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 17:18:04 +02:00
|
|
|
/* externally used data */
|
2019-01-14 06:15:33 +01:00
|
|
|
/** reference index for ImBuf lists */
|
|
|
|
int index;
|
|
|
|
/** used to set imbuf to dirty and other stuff */
|
|
|
|
int userflags;
|
|
|
|
/** image metadata */
|
2024-01-19 12:48:04 +01:00
|
|
|
IDProperty *metadata;
|
2019-01-14 06:15:33 +01:00
|
|
|
/** temporary storage */
|
|
|
|
void *userdata;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 17:18:04 +02:00
|
|
|
/* file information */
|
2019-01-14 06:15:33 +01:00
|
|
|
/** file type we are going to save as */
|
2020-11-13 10:25:21 +01:00
|
|
|
enum eImbFileType ftype;
|
2019-01-14 06:15:33 +01:00
|
|
|
/** file format specific flags */
|
|
|
|
ImbFormatOptions foptions;
|
2023-05-03 06:13:27 +02:00
|
|
|
/** The absolute file path associated with this image. */
|
|
|
|
char filepath[IMB_FILEPATH_SIZE];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 17:18:04 +02:00
|
|
|
/* memory cache limiter */
|
2019-01-14 06:15:33 +01:00
|
|
|
/** reference counter for multiple users */
|
|
|
|
int refcounter;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 17:18:04 +02:00
|
|
|
/* some parameters to pass along for packing images */
|
2022-08-19 03:29:32 +02:00
|
|
|
/** Compressed image only used with PNG and EXR currently. */
|
2023-05-18 10:19:01 +02:00
|
|
|
ImBufByteBuffer encoded_buffer;
|
|
|
|
/** Size of data written to `encoded_buffer`. */
|
|
|
|
unsigned int encoded_size;
|
|
|
|
/** Size of `encoded_buffer` */
|
|
|
|
unsigned int encoded_buffer_size;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 12:05:07 +02:00
|
|
|
/* color management */
|
2019-01-14 06:15:33 +01:00
|
|
|
/** array of per-display display buffers dirty flags */
|
|
|
|
unsigned int *display_buffer_flags;
|
|
|
|
/** cache used by color management */
|
2024-01-19 12:48:04 +01:00
|
|
|
ColormanageCache *colormanage_cache;
|
2012-09-19 17:01:36 +02:00
|
|
|
int colormanage_flag;
|
2013-02-11 14:24:35 +01:00
|
|
|
rcti invalid_rect;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-30 06:34:34 +02:00
|
|
|
/* information for compressed textures */
|
2024-01-19 12:48:04 +01:00
|
|
|
DDSData dds_data;
|
|
|
|
};
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2003-05-30 03:50:46 +02:00
|
|
|
/**
|
2022-06-03 05:39:37 +02:00
|
|
|
* \brief userflags: Flags used internally by blender for image-buffers.
|
2003-05-30 03:50:46 +02:00
|
|
|
*/
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2019-01-14 06:15:33 +01:00
|
|
|
enum {
|
|
|
|
/** image needs to be saved is not the same as filename */
|
|
|
|
IB_BITMAPDIRTY = (1 << 1),
|
|
|
|
/** image mipmaps are invalid, need recreate */
|
|
|
|
IB_MIPMAP_INVALID = (1 << 2),
|
|
|
|
/** float buffer changed, needs recreation of byte rect */
|
|
|
|
IB_RECT_INVALID = (1 << 3),
|
|
|
|
/** either float or byte buffer changed, need to re-calculate display buffers */
|
|
|
|
IB_DISPLAY_BUFFER_INVALID = (1 << 4),
|
|
|
|
/** image buffer is persistent in the memory and should never be removed from the cache */
|
|
|
|
IB_PERSISTENT = (1 << 5),
|
|
|
|
};
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2021-12-14 05:49:31 +01:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
2024-02-28 02:13:20 +01:00
|
|
|
/** \name ImBuf Preset Profile Tags
|
2017-06-19 01:33:23 +02:00
|
|
|
*
|
2021-12-14 05:49:31 +01:00
|
|
|
* \brief Some predefined color space profiles that 8 bit imbufs can represent.
|
2017-06-19 01:33:23 +02:00
|
|
|
* \{ */
|
2021-12-14 05:49:31 +01:00
|
|
|
|
2009-07-17 04:43:15 +02:00
|
|
|
#define IB_PROFILE_NONE 0
|
|
|
|
#define IB_PROFILE_LINEAR_RGB 1
|
|
|
|
#define IB_PROFILE_SRGB 2
|
|
|
|
#define IB_PROFILE_CUSTOM 3
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2017-06-19 01:33:23 +02:00
|
|
|
/** \} */
|
|
|
|
|
2012-06-30 06:34:34 +02:00
|
|
|
/* dds */
|
2023-04-12 05:22:26 +02:00
|
|
|
#ifndef DDS_MAKEFOURCC
|
|
|
|
# define DDS_MAKEFOURCC(ch0, ch1, ch2, ch3) \
|
|
|
|
((unsigned long)(unsigned char)(ch0) | ((unsigned long)(unsigned char)(ch1) << 8) | \
|
|
|
|
((unsigned long)(unsigned char)(ch2) << 16) | ((unsigned long)(unsigned char)(ch3) << 24))
|
|
|
|
#endif /* DDS_MAKEFOURCC */
|
2012-06-30 06:34:34 +02:00
|
|
|
|
|
|
|
/*
|
2021-12-09 10:01:45 +01:00
|
|
|
* FOURCC codes for DX compressed-texture pixel formats.
|
2012-06-30 06:34:34 +02:00
|
|
|
*/
|
|
|
|
|
2023-04-12 05:22:26 +02:00
|
|
|
#define FOURCC_DDS (DDS_MAKEFOURCC('D', 'D', 'S', ' '))
|
|
|
|
#define FOURCC_DX10 (DDS_MAKEFOURCC('D', 'X', '1', '0'))
|
|
|
|
#define FOURCC_DXT1 (DDS_MAKEFOURCC('D', 'X', 'T', '1'))
|
|
|
|
#define FOURCC_DXT2 (DDS_MAKEFOURCC('D', 'X', 'T', '2'))
|
|
|
|
#define FOURCC_DXT3 (DDS_MAKEFOURCC('D', 'X', 'T', '3'))
|
|
|
|
#define FOURCC_DXT4 (DDS_MAKEFOURCC('D', 'X', 'T', '4'))
|
|
|
|
#define FOURCC_DXT5 (DDS_MAKEFOURCC('D', 'X', 'T', '5'))
|
2012-06-30 06:34:34 +02:00
|
|
|
|
2010-08-03 14:34:42 +02:00
|
|
|
extern const char *imb_ext_image[];
|
|
|
|
extern const char *imb_ext_movie[];
|
|
|
|
extern const char *imb_ext_audio[];
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2021-12-14 05:49:31 +01:00
|
|
|
/* -------------------------------------------------------------------- */
|
2024-02-28 02:13:20 +01:00
|
|
|
/** \name ImBuf Color Management Flag
|
2017-06-19 01:33:23 +02:00
|
|
|
*
|
2021-12-14 05:49:31 +01:00
|
|
|
* \brief Used with #ImBuf.colormanage_flag
|
2017-06-19 01:33:23 +02:00
|
|
|
* \{ */
|
|
|
|
|
2012-09-19 17:01:36 +02:00
|
|
|
enum {
|
2019-01-15 13:57:49 +01:00
|
|
|
IMB_COLORMANAGE_IS_DATA = (1 << 0),
|
2012-09-19 17:01:36 +02:00
|
|
|
};
|
|
|
|
|
2017-06-19 01:33:23 +02:00
|
|
|
/** \} */
|