Blender V5.3
OCIO_packed_image.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#include <cstddef>
8
9#include "BLI_assert.hh"
10
11#include "intern/opencolorio.hh"
12
13namespace blender::ocio {
14
19
21 OCIO_NAMESPACE::PackedImageDesc image_desc_;
22
23 static OCIO_NAMESPACE::BitDepth convert_bit_depth(const BitDepth bit_depth)
24 {
25 switch (bit_depth) {
27 return OCIO_NAMESPACE::BIT_DEPTH_UNKNOWN;
29 return OCIO_NAMESPACE::BIT_DEPTH_F32;
30 }
32 return OCIO_NAMESPACE::BIT_DEPTH_UNKNOWN;
33 }
34
35 static BitDepth convert_bit_depth(const OCIO_NAMESPACE::BitDepth bit_depth)
36 {
37 switch (bit_depth) {
38 case OCIO_NAMESPACE::BIT_DEPTH_UNKNOWN:
40 case OCIO_NAMESPACE::BIT_DEPTH_F32:
42 default:
43 /* Other bit depths are currently not supported. */
45 }
46 }
47
48 public:
50 const size_t width,
51 const size_t height,
52 const size_t num_channels,
53 const BitDepth bit_depth,
54 const size_t chan_stride_in_bytes,
55 const size_t x_stride_in_bytes,
56 const size_t y_stride_in_bytes)
57 : image_desc_(data,
58 width,
59 height,
60 num_channels,
61 convert_bit_depth(bit_depth),
62 chan_stride_in_bytes,
63 x_stride_in_bytes,
64 y_stride_in_bytes)
65 {
66 }
67
68 size_t get_width() const
69 {
70 return image_desc_.getWidth();
71 }
72 size_t get_height() const
73 {
74 return image_desc_.getHeight();
75 }
76
77 size_t get_num_channels() const
78 {
79 return image_desc_.getNumChannels();
80 }
81
82 void *get_data() const
83 {
84 return image_desc_.getData();
85 }
86
88 {
89 return convert_bit_depth(image_desc_.getBitDepth());
90 }
91
93 {
94 return image_desc_.getChanStrideBytes();
95 }
96 size_t get_x_stride_in_bytes() const
97 {
98 return image_desc_.getXStrideBytes();
99 }
101 {
102 return image_desc_.getYStrideBytes();
103 }
104
105 operator const OCIO_NAMESPACE::PackedImageDesc &() const
106 {
107 return image_desc_;
108 }
109};
110
111} // namespace blender::ocio
#define BLI_assert_unreachable()
size_t get_chan_stride_in_bytes() const
PackedImage(void *data, const size_t width, const size_t height, const size_t num_channels, const BitDepth bit_depth, const size_t chan_stride_in_bytes, const size_t x_stride_in_bytes, const size_t y_stride_in_bytes)
BMesh const char void * data