Blender V5.3
node_composite_blank_image.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
6#include "COM_utilities.hh"
7
9
11
13{
14 b.add_input<decl::Color>("Color"_ustr)
15 .default_value({0.0f, 0.0f, 0.0f, 1.0f})
16 .description("The color of all pixels in the image");
17 b.add_input<decl::IntVector>("Size"_ustr)
18 .dimensions(2)
19 .default_value(int2(1920, 1080))
20 .subtype(PROP_PIXEL)
21 .min(1)
22 .description("The size of the image");
23
24 b.add_output<decl::Color>("Image"_ustr)
25 .structure_type(StructureType::Dynamic)
26 .description("An image of the given size and constant color");
27}
28
29using namespace blender::compositor;
30
32 public:
34
35 void execute() override
36 {
37 const int2 size = this->get_input("Size").get_single_value_default<int2>();
38 const int2 image_size = math::max(int2(1), size);
39
40 Result &output = this->get_result("Image");
41 output.allocate_texture(Domain(image_size));
42 const Color color = this->get_input("Color").get_single_value_default<Color>();
43 if (this->context().use_gpu()) {
45 }
46 else {
47 parallel_for(output.domain().data_size,
48 [&](const int2 texel) { output.store_pixel(texel, color); });
49 }
50 }
51};
52
54{
55 return new BlankImageOperation(context, node);
56}
57
58static void node_register()
59{
60 static bke::bNodeType ntype;
61
62 cmp_node_type_base(&ntype, "CompositorNodeBlankImage"_ustr);
63 ntype.ui_name = "Blank Image";
64 ntype.ui_description = "Returns an image with the given size and constant color";
66 ntype.declare = node_declare;
68
70}
72
73} // namespace blender::nodes::node_composite_blank_image_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:478
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define output
Domain(const int2 &size)
Definition domain.cc:20
NodeOperation(Context &context, const bNode &node)
Result & get_result(StringRef identifier)
Definition operation.cc:40
Context & context() const
Definition operation.cc:57
Result & get_input(StringRef identifier) const
Definition operation.cc:35
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
ColorSceneLinear4f< eAlpha::Premultiplied > Color
Definition COM_result.hh:96
void parallel_for(const int2 range, const Function &function)
T max(const T &a, const T &b)
static void node_declare(NodeDeclarationBuilder &b)
static NodeOperation * get_compositor_operation(Context &context, const bNode &node)
void GPU_texture_clear(gpu::Texture *texture, eGPUDataFormat data_format, const void *data)
void cmp_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
Defines a node type.
Definition BKE_node.hh:265
std::string ui_description
Definition BKE_node.hh:271
NodeGetCompositorOperationFunction get_compositor_operation
Definition BKE_node.hh:379
NodeDeclareFunction declare
Definition BKE_node.hh:393