Blender V4.3
format_hdr.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#include "IMB_filetype.hh"
12#include "IMB_imbuf_types.hh"
13
14OIIO_NAMESPACE_USING
15using namespace blender::imbuf;
16
17bool imb_is_a_hdr(const uchar *mem, size_t size)
18{
19 return imb_oiio_check(mem, size, "hdr");
20}
21
22ImBuf *imb_load_hdr(const uchar *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
23{
24 ImageSpec config, spec;
25
26 ReadContext ctx{mem, size, "hdr", IMB_FTYPE_RADHDR, flags};
27
28 /* Always create ImBufs with a 4th alpha channel despite the format only supporting 3. */
29 ctx.use_all_planes = true;
30
31 ImBuf *ibuf = imb_oiio_read(ctx, config, colorspace, spec);
32 if (ibuf) {
33 if (flags & IB_alphamode_detect) {
35 }
36 if (flags & IB_rect) {
38 }
39 }
40
41 return ibuf;
42}
43
44bool imb_save_hdr(ImBuf *ibuf, const char *filepath, int flags)
45{
46 const int file_channels = 3;
47 const TypeDesc data_format = TypeDesc::FLOAT;
48
49 WriteContext ctx = imb_create_write_context("hdr", ibuf, flags);
50 ImageSpec file_spec = imb_create_write_spec(ctx, file_channels, data_format);
51
52 return imb_oiio_write(ctx, filepath, file_spec);
53}
unsigned char uchar
void IMB_rect_from_float(ImBuf *ibuf)
Definition divers.cc:694
#define IM_MAX_SPACE
Definition IMB_imbuf.hh:49
@ IMB_FTYPE_RADHDR
Contains defines and structs used throughout the imbuf module.
@ IB_alphamode_premul
@ IB_alphamode_detect
@ IB_rect
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
ImBuf * imb_load_hdr(const uchar *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
Definition format_hdr.cc:22
bool imb_save_hdr(ImBuf *ibuf, const char *filepath, int flags)
Definition format_hdr.cc:44
bool imb_is_a_hdr(const uchar *mem, size_t size)
Definition format_hdr.cc:17
bool imb_oiio_write(const WriteContext &ctx, const char *filepath, const ImageSpec &file_spec)
WriteContext imb_create_write_context(const char *file_format, ImBuf *ibuf, int flags, bool prefer_float)
ImBuf * imb_oiio_read(const ReadContext &ctx, const ImageSpec &config, char colorspace[IM_MAX_SPACE], ImageSpec &r_newspec)
bool imb_oiio_check(const uchar *mem, size_t mem_size, const char *file_format)
ImageSpec imb_create_write_spec(const WriteContext &ctx, int file_channels, TypeDesc data_format)
long long TypeDesc