Blender V5.0
rna_image.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
8
9#include <cstdlib>
10
11#include "DNA_image_types.h"
12#include "DNA_scene_types.h"
13
14#include "BLT_translation.hh"
15
16#include "RNA_define.hh"
17#include "RNA_enum_types.hh"
18
19#include "rna_internal.hh"
20
21#include "WM_api.hh"
22#include "WM_types.hh"
23
25 {IMA_GENTYPE_BLANK, "BLANK", 0, "Blank", "Generate a blank image"},
26 {IMA_GENTYPE_GRID, "UV_GRID", 0, "UV Grid", "Generated grid to test UV mappings"},
28 "COLOR_GRID",
29 0,
30 "Color Grid",
31 "Generated improved UV grid to test UV mappings"},
32 {0, nullptr, 0, nullptr, nullptr},
33};
34
36 {IMA_SRC_FILE, "FILE", 0, "Single Image", "Single image file"},
37 {IMA_SRC_SEQUENCE, "SEQUENCE", 0, "Image Sequence", "Multiple image files, as a sequence"},
38 {IMA_SRC_MOVIE, "MOVIE", 0, "Movie", "Movie file"},
39 {IMA_SRC_GENERATED, "GENERATED", 0, "Generated", "Generated image"},
40 {IMA_SRC_VIEWER, "VIEWER", 0, "Viewer", "Compositing node viewer"},
41 {IMA_SRC_TILED, "TILED", 0, "UDIM Tiles", "Tiled UDIM image texture"},
42 {0, nullptr, 0, nullptr, nullptr},
43};
44
45#ifdef RNA_RUNTIME
46
47# include <algorithm>
48# include <fmt/format.h>
49
50# include "BLI_math_base.h"
51# include "BLI_math_vector.h"
52
53# include "BKE_global.hh"
54# include "BKE_image.hh"
55# include "BKE_image_format.hh"
56# include "BKE_lib_id.hh"
57# include "BKE_main.hh"
58# include "BKE_main_invariants.hh"
60# include "BKE_screen.hh"
61
62# include "GPU_texture.hh"
63
64# include "IMB_imbuf.hh"
65# include "IMB_imbuf_types.hh"
66
67# include "MOV_read.hh"
68
69# include "ED_node.hh"
70
71# include "DNA_space_types.h"
72
73# include "DEG_depsgraph.hh"
74# include "DEG_depsgraph_build.hh"
75
76static bool rna_Image_is_stereo_3d_get(PointerRNA *ptr)
77{
78 return BKE_image_is_stereo((Image *)ptr->data);
79}
80
81static bool rna_Image_is_multiview_get(PointerRNA *ptr)
82{
83 return BKE_image_is_multiview((Image *)ptr->data);
84}
85
86static bool rna_Image_dirty_get(PointerRNA *ptr)
87{
88 return BKE_image_is_dirty((Image *)ptr->data);
89}
90
91static void rna_Image_source_set(PointerRNA *ptr, int value)
92{
93 Image *ima = (Image *)ptr->owner_id;
94
95 if (value != ima->source) {
96 ima->source = value;
99 if (ima->source == IMA_SRC_TILED) {
101 }
102
103 DEG_id_tag_update(&ima->id, 0);
106 }
107}
108
109static void rna_Image_reload_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
110{
111 Image *ima = (Image *)ptr->owner_id;
112 BKE_image_signal(bmain, ima, nullptr, IMA_SIGNAL_RELOAD);
114 DEG_id_tag_update(&ima->id, 0);
116}
117
118static int rna_Image_generated_type_get(PointerRNA *ptr)
119{
120 Image *ima = (Image *)ptr->data;
121 ImageTile *base_tile = BKE_image_get_tile(ima, 0);
122 return base_tile->gen_type;
123}
124
125static void rna_Image_generated_type_set(PointerRNA *ptr, int value)
126{
127 Image *ima = (Image *)ptr->data;
128 ImageTile *base_tile = BKE_image_get_tile(ima, 0);
129 base_tile->gen_type = value;
130}
131
132static int rna_Image_generated_width_get(PointerRNA *ptr)
133{
134 Image *ima = (Image *)ptr->data;
135 ImageTile *base_tile = BKE_image_get_tile(ima, 0);
136 return base_tile->gen_x;
137}
138
139static void rna_Image_generated_width_set(PointerRNA *ptr, int value)
140{
141 Image *ima = (Image *)ptr->data;
142 ImageTile *base_tile = BKE_image_get_tile(ima, 0);
143 base_tile->gen_x = std::clamp(value, 1, 65536);
144}
145
146static int rna_Image_generated_height_get(PointerRNA *ptr)
147{
148 Image *ima = (Image *)ptr->data;
149 ImageTile *base_tile = BKE_image_get_tile(ima, 0);
150 return base_tile->gen_y;
151}
152
153static void rna_Image_generated_height_set(PointerRNA *ptr, int value)
154{
155 Image *ima = (Image *)ptr->data;
156 ImageTile *base_tile = BKE_image_get_tile(ima, 0);
157 base_tile->gen_y = std::clamp(value, 1, 65536);
158}
159
160static bool rna_Image_generated_float_get(PointerRNA *ptr)
161{
162 Image *ima = (Image *)ptr->data;
163 ImageTile *base_tile = BKE_image_get_tile(ima, 0);
164 return (base_tile->gen_flag & IMA_GEN_FLOAT) != 0;
165}
166
167static void rna_Image_generated_float_set(PointerRNA *ptr, bool value)
168{
169 Image *ima = (Image *)ptr->data;
170 ImageTile *base_tile = BKE_image_get_tile(ima, 0);
171 if (value) {
172 base_tile->gen_flag |= IMA_GEN_FLOAT;
173 }
174 else {
175 base_tile->gen_flag &= ~IMA_GEN_FLOAT;
176 }
177}
178
179void rna_Image_generated_color_get(PointerRNA *ptr, float values[4])
180{
181 Image *ima = (Image *)(ptr->data);
182 ImageTile *base_tile = BKE_image_get_tile(ima, 0);
183 copy_v4_v4(values, base_tile->gen_color);
184}
185
186void rna_Image_generated_color_set(PointerRNA *ptr, const float values[4])
187{
188 Image *ima = (Image *)(ptr->data);
189 ImageTile *base_tile = BKE_image_get_tile(ima, 0);
190 for (uint i = 0; i < 4; i++) {
191 base_tile->gen_color[i] = std::clamp(values[i], 0.0f, FLT_MAX);
192 }
193}
194
195static void rna_Image_generated_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
196{
197 Image *ima = (Image *)ptr->owner_id;
198 BKE_image_signal(bmain, ima, nullptr, IMA_SIGNAL_FREE);
201}
202
203static void rna_Image_colormanage_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
204{
205 Image *ima = (Image *)ptr->owner_id;
206 BKE_image_signal(bmain, ima, nullptr, IMA_SIGNAL_COLORMANAGE);
207 DEG_id_tag_update(&ima->id, 0);
211}
212
213static void rna_Image_alpha_mode_update(Main *bmain, Scene *scene, PointerRNA *ptr)
214{
215 Image *ima = (Image *)ptr->owner_id;
216 /* When operating on a generated image, avoid re-generating when changing the alpha-mode
217 * as it doesn't impact generated images, causing them to reload pixel data, see #82785. */
218 if (ima->source == IMA_SRC_GENERATED) {
219 return;
220 }
221 rna_Image_colormanage_update(bmain, scene, ptr);
222}
223
224static void rna_Image_views_format_update(Main *bmain, Scene *scene, PointerRNA *ptr)
225{
226 Image *ima = (Image *)ptr->owner_id;
227 ImBuf *ibuf;
228 void *lock;
229
230 ibuf = BKE_image_acquire_ibuf(ima, nullptr, &lock);
231
232 if (ibuf) {
233 ImageUser iuser = {nullptr};
234 iuser.scene = scene;
235 BKE_image_signal(bmain, ima, &iuser, IMA_SIGNAL_FREE);
236 }
237
238 BKE_image_release_ibuf(ima, ibuf, lock);
241}
242
243static void rna_ImageUser_update(Main *bmain, Scene *scene, PointerRNA *ptr)
244{
245 ImageUser *iuser = static_cast<ImageUser *>(ptr->data);
246 ID *id = ptr->owner_id;
247
248 if (scene != nullptr) {
249 BKE_image_user_frame_calc(nullptr, iuser, scene->r.cfra);
250 }
251
252 if (id) {
253 if (GS(id->name) == ID_NT) {
254 /* Special update for node-trees. */
257 }
258 else {
259 /* Update material or texture for render preview. */
260 DEG_id_tag_update(id, 0);
262 }
263 }
264}
265
266static void rna_ImageUser_relations_update(Main *bmain, Scene *scene, PointerRNA *ptr)
267{
268 rna_ImageUser_update(bmain, scene, ptr);
270}
271
272static std::optional<std::string> rna_ImageUser_path(const PointerRNA *ptr)
273{
274 if (ptr->owner_id) {
275 switch (GS(ptr->owner_id->name)) {
276 case ID_OB:
277 case ID_TE:
278 return "image_user";
279 case ID_NT:
281 case ID_CA:
283 case ID_SCR: {
284 const bScreen *screen = reinterpret_cast<bScreen *>(ptr->owner_id);
285 const ImageUser *iuser = static_cast<ImageUser *>(ptr->data);
286 int area_index;
287 int space_index;
288 LISTBASE_FOREACH_INDEX (ScrArea *, area, &screen->areabase, area_index) {
289 LISTBASE_FOREACH_INDEX (SpaceLink *, sl, &area->spacedata, space_index) {
290 if (sl->spacetype == SPACE_IMAGE) {
291 SpaceImage *sima = reinterpret_cast<SpaceImage *>(sl);
292 if (&sima->iuser == iuser) {
293 return fmt::format("areas[{}].spaces[{}].image_user", area_index, space_index);
294 }
295 }
296 }
297 }
298 return " ... image_user";
299 }
300 default:
301 break;
302 }
303 }
304
305 return "";
306}
307
308static void rna_Image_gpu_texture_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
309{
310 Image *ima = (Image *)ptr->owner_id;
311
312 if (!G.background) {
314 }
315
317}
318
319static const EnumPropertyItem *rna_Image_source_itemf(bContext * /*C*/,
321 PropertyRNA * /*prop*/,
322 bool *r_free)
323{
324 Image *ima = (Image *)ptr->data;
325 EnumPropertyItem *item = nullptr;
326 int totitem = 0;
327
328 if (ima->source == IMA_SRC_VIEWER) {
330 }
331 else {
337 }
338
339 RNA_enum_item_end(&item, &totitem);
340 *r_free = true;
341
342 return item;
343}
344
345static int rna_Image_file_format_get(PointerRNA *ptr)
346{
347 Image *image = (Image *)ptr->data;
348 ImBuf *ibuf = BKE_image_acquire_ibuf(image, nullptr, nullptr);
349 int imtype = BKE_ftype_to_imtype(ibuf ? ibuf->ftype : IMB_FTYPE_NONE,
350 ibuf ? &ibuf->foptions : nullptr);
351
352 BKE_image_release_ibuf(image, ibuf, nullptr);
353
354 return imtype;
355}
356
357static void rna_Image_file_format_set(PointerRNA *ptr, int value)
358{
359 Image *image = (Image *)ptr->data;
360 if (BKE_imtype_is_movie(value) == 0) { /* should be able to throw an error here */
362 int ftype = BKE_imtype_to_ftype(value, &options);
363 BKE_image_file_format_set(image, ftype, &options);
364 }
365}
366
367static void rna_UDIMTile_size_get(PointerRNA *ptr, int *values)
368{
369 ImageTile *tile = (ImageTile *)ptr->data;
370 Image *image = (Image *)ptr->owner_id;
371
372 ImageUser image_user;
373 BKE_imageuser_default(&image_user);
374 image_user.tile = tile->tile_number;
375
376 void *lock;
377 ImBuf *ibuf = BKE_image_acquire_ibuf(image, &image_user, &lock);
378 if (ibuf) {
379 values[0] = ibuf->x;
380 values[1] = ibuf->y;
381 }
382 else {
383 values[0] = 0;
384 values[1] = 0;
385 }
386
387 BKE_image_release_ibuf(image, ibuf, lock);
388}
389
390static int rna_UDIMTile_channels_get(PointerRNA *ptr)
391{
392 ImageTile *tile = (ImageTile *)ptr->data;
393 Image *image = (Image *)ptr->owner_id;
394
395 ImageUser image_user;
396 BKE_imageuser_default(&image_user);
397 image_user.tile = tile->tile_number;
398
399 int channels = 0;
400
401 void *lock;
402 ImBuf *ibuf = BKE_image_acquire_ibuf(image, &image_user, &lock);
403 if (ibuf) {
404 channels = ibuf->channels;
405 }
406
407 BKE_image_release_ibuf(image, ibuf, lock);
408
409 return channels;
410}
411
412static void rna_UDIMTile_label_get(PointerRNA *ptr, char *value)
413{
414 const ImageTile *tile = (ImageTile *)ptr->data;
415 const Image *image = (Image *)ptr->owner_id;
416
417 /* Pass in a fixed size buffer as the value may be allocated based on the callbacks length. */
418 char value_buf[sizeof(tile->label)];
419 int len = BKE_image_get_tile_label(image, tile, value_buf, sizeof(tile->label));
420 memcpy(value, value_buf, len + 1);
421}
422
423static int rna_UDIMTile_label_length(PointerRNA *ptr)
424{
425 const ImageTile *tile = (ImageTile *)ptr->data;
426 const Image *image = (Image *)ptr->owner_id;
427
428 char label[sizeof(tile->label)];
429 return BKE_image_get_tile_label(image, tile, label, sizeof(label));
430}
431
432static void rna_UDIMTile_tile_number_set(PointerRNA *ptr, int value)
433{
434 ImageTile *tile = (ImageTile *)ptr->data;
435 Image *image = (Image *)ptr->owner_id;
436
437 /* Check that no other tile already has that number. */
438 ImageTile *cur_tile = BKE_image_get_tile(image, value);
439 if (cur_tile == nullptr) {
440 BKE_image_reassign_tile(image, tile, value);
441 }
442}
443
444static void rna_UDIMTile_generated_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
445{
446 Image *ima = (Image *)ptr->owner_id;
447 ImageTile *tile = (ImageTile *)ptr->data;
448
449 /* If the tile is still marked as generated, then update the tile as requested. */
450 if ((tile->gen_flag & IMA_GEN_TILE) != 0) {
453 }
454}
455
456static int rna_Image_active_tile_index_get(PointerRNA *ptr)
457{
458 Image *image = (Image *)ptr->data;
459 return image->active_tile_index;
460}
461
462static void rna_Image_active_tile_index_set(PointerRNA *ptr, int value)
463{
464 Image *image = (Image *)ptr->data;
465 int num_tiles = BLI_listbase_count(&image->tiles);
466
467 image->active_tile_index = min_ii(value, num_tiles - 1);
468}
469
470static void rna_Image_active_tile_index_range(
471 PointerRNA *ptr, int *min, int *max, int * /*softmin*/, int * /*softmax*/)
472{
473 Image *image = (Image *)ptr->data;
474 int num_tiles = BLI_listbase_count(&image->tiles);
475
476 *min = 0;
477 *max = max_ii(0, num_tiles - 1);
478}
479
480static PointerRNA rna_Image_active_tile_get(PointerRNA *ptr)
481{
482 Image *image = (Image *)ptr->data;
483 ImageTile *tile = static_cast<ImageTile *>(
484 BLI_findlink(&image->tiles, image->active_tile_index));
485
486 return RNA_pointer_create_with_parent(*ptr, &RNA_UDIMTile, tile);
487}
488
489static void rna_Image_active_tile_set(PointerRNA *ptr, PointerRNA value, ReportList * /*reports*/)
490{
491 Image *image = (Image *)ptr->data;
492 ImageTile *tile = (ImageTile *)value.data;
493 const int index = BLI_findindex(&image->tiles, tile);
494 if (index != -1) {
495 image->active_tile_index = index;
496 }
497}
498
499static bool rna_Image_has_data_get(PointerRNA *ptr)
500{
501 Image *image = (Image *)ptr->data;
502
503 return BKE_image_has_loaded_ibuf(image);
504}
505
506static void rna_Image_size_get(PointerRNA *ptr, int *values)
507{
508 Image *im = (Image *)ptr->data;
509 ImBuf *ibuf;
510 void *lock;
511
512 ibuf = BKE_image_acquire_ibuf(im, nullptr, &lock);
513 if (ibuf) {
514 values[0] = ibuf->x;
515 values[1] = ibuf->y;
516 }
517 else {
518 values[0] = 0;
519 values[1] = 0;
520 }
521
522 BKE_image_release_ibuf(im, ibuf, lock);
523}
524
525static void rna_Image_resolution_get(PointerRNA *ptr, float *values)
526{
527 Image *im = (Image *)ptr->data;
528 ImBuf *ibuf;
529 void *lock;
530
531 ibuf = BKE_image_acquire_ibuf(im, nullptr, &lock);
532 if (ibuf) {
533 values[0] = ibuf->ppm[0];
534 values[1] = ibuf->ppm[1];
535 }
536 else {
537 values[0] = 0;
538 values[1] = 0;
539 }
540
541 BKE_image_release_ibuf(im, ibuf, lock);
542}
543
544static void rna_Image_resolution_set(PointerRNA *ptr, const float *values)
545{
546 Image *im = (Image *)ptr->data;
547 ImBuf *ibuf;
548 void *lock;
549
550 ibuf = BKE_image_acquire_ibuf(im, nullptr, &lock);
551 if (ibuf) {
552 ibuf->ppm[0] = values[0];
553 ibuf->ppm[1] = values[1];
554 }
555
556 BKE_image_release_ibuf(im, ibuf, lock);
557}
558
559static int rna_Image_depth_get(PointerRNA *ptr)
560{
561 Image *im = (Image *)ptr->data;
562 ImBuf *ibuf;
563 void *lock;
564 int planes;
565
566 ibuf = BKE_image_acquire_ibuf(im, nullptr, &lock);
567
568 if (!ibuf) {
569 planes = 0;
570 }
571 else if (ibuf->float_buffer.data) {
572 planes = ibuf->planes * 4;
573 }
574 else {
575 planes = ibuf->planes;
576 }
577
578 BKE_image_release_ibuf(im, ibuf, lock);
579
580 return planes;
581}
582
583static int rna_Image_frame_duration_get(PointerRNA *ptr)
584{
585 Image *ima = (Image *)ptr->owner_id;
586 int duration = 1;
587
588 if (!BKE_image_has_anim(ima)) {
589 /* Ensure image has been loaded into memory and frame duration is known. */
590 void *lock;
591 ImBuf *ibuf = BKE_image_acquire_ibuf(ima, nullptr, &lock);
592 BKE_image_release_ibuf(ima, ibuf, lock);
593 }
594
595 if (BKE_image_has_anim(ima)) {
596 MovieReader *anim = ((ImageAnim *)ima->anims.first)->anim;
597 if (anim) {
599 }
600 }
601
602 return duration;
603}
604
605static int rna_Image_pixels_get_length(const PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
606{
607 Image *ima = (Image *)ptr->owner_id;
608 ImBuf *ibuf;
609 void *lock;
610
611 ibuf = BKE_image_acquire_ibuf(ima, nullptr, &lock);
612
613 if (ibuf) {
614 length[0] = IMB_get_pixel_count(ibuf) * size_t(ibuf->channels);
615 }
616 else {
617 length[0] = 0;
618 }
619
620 BKE_image_release_ibuf(ima, ibuf, lock);
621
622 return length[0];
623}
624
625static void rna_Image_pixels_get(PointerRNA *ptr, float *values)
626{
627 Image *ima = (Image *)ptr->owner_id;
628 ImBuf *ibuf;
629 void *lock;
630
631 ibuf = BKE_image_acquire_ibuf(ima, nullptr, &lock);
632
633 if (ibuf) {
634 const size_t size = IMB_get_pixel_count(ibuf) * size_t(ibuf->channels);
635
636 if (ibuf->float_buffer.data) {
637 memcpy(values, ibuf->float_buffer.data, sizeof(float) * size);
638 }
639 else {
640 for (size_t i = 0; i < size; i++) {
641 values[i] = ibuf->byte_buffer.data[i] * (1.0f / 255.0f);
642 }
643 }
644 }
645
646 BKE_image_release_ibuf(ima, ibuf, lock);
647}
648
649static void rna_Image_pixels_set(PointerRNA *ptr, const float *values)
650{
651 Image *ima = (Image *)ptr->owner_id;
652 ImBuf *ibuf;
653 void *lock;
654
655 ibuf = BKE_image_acquire_ibuf(ima, nullptr, &lock);
656
657 if (ibuf) {
658 const size_t size = IMB_get_pixel_count(ibuf) * size_t(ibuf->channels);
659
660 if (ibuf->float_buffer.data) {
661 memcpy(ibuf->float_buffer.data, values, sizeof(float) * size);
662 }
663 else {
664 for (size_t i = 0; i < size; i++) {
665 ibuf->byte_buffer.data[i] = unit_float_to_uchar_clamp(values[i]);
666 }
667 }
668
669 /* NOTE: Do update from the set() because typically pixels.foreach_set() is used to update
670 * the values, and it does not invoke the update(). */
671
673 BKE_image_mark_dirty(ima, ibuf);
674 if (!G.background) {
676 }
677
680 }
681
682 BKE_image_release_ibuf(ima, ibuf, lock);
683}
684
685static int rna_Image_channels_get(PointerRNA *ptr)
686{
687 Image *im = (Image *)ptr->data;
688 ImBuf *ibuf;
689 void *lock;
690 int channels = 0;
691
692 ibuf = BKE_image_acquire_ibuf(im, nullptr, &lock);
693 if (ibuf) {
694 channels = ibuf->channels;
695 }
696
697 BKE_image_release_ibuf(im, ibuf, lock);
698
699 return channels;
700}
701
702static bool rna_Image_is_float_get(PointerRNA *ptr)
703{
704 Image *im = (Image *)ptr->data;
705 ImBuf *ibuf;
706 void *lock;
707 bool is_float = false;
708
709 ibuf = BKE_image_acquire_ibuf(im, nullptr, &lock);
710 if (ibuf) {
711 is_float = ibuf->float_buffer.data != nullptr;
712 }
713
714 BKE_image_release_ibuf(im, ibuf, lock);
715
716 return is_float;
717}
718
719static PointerRNA rna_Image_packed_file_get(PointerRNA *ptr)
720{
721 Image *ima = (Image *)ptr->owner_id;
722
723 if (BKE_image_has_packedfile(ima)) {
724 ImagePackedFile *imapf = static_cast<ImagePackedFile *>(ima->packedfiles.first);
725 return RNA_pointer_create_with_parent(*ptr, &RNA_PackedFile, imapf->packedfile);
726 }
727 return PointerRNA_NULL;
728}
729
730static void rna_RenderSlot_clear(ID *id, RenderSlot *slot, ImageUser *iuser)
731{
732 Image *image = (Image *)id;
733 int index = BLI_findindex(&image->renderslots, slot);
734 BKE_image_clear_renderslot(image, iuser, index);
735
737}
738
739static PointerRNA rna_render_slots_active_get(PointerRNA *ptr)
740{
741 Image *image = (Image *)ptr->owner_id;
742 RenderSlot *render_slot = BKE_image_get_renderslot(image, image->render_slot);
743
744 return RNA_pointer_create_with_parent(*ptr, &RNA_RenderSlot, render_slot);
745}
746
747static void rna_render_slots_active_set(PointerRNA *ptr,
748 PointerRNA value,
749 ReportList * /*reports*/)
750{
751 Image *image = (Image *)ptr->owner_id;
752 if (value.owner_id == &image->id) {
753 RenderSlot *slot = (RenderSlot *)value.data;
754 int index = BLI_findindex(&image->renderslots, slot);
755 if (index != -1) {
756 image->render_slot = index;
758 }
759 }
760}
761
762static int rna_render_slots_active_index_get(PointerRNA *ptr)
763{
764 Image *image = (Image *)ptr->owner_id;
765 return image->render_slot;
766}
767
768static void rna_render_slots_active_index_set(PointerRNA *ptr, int value)
769{
770 Image *image = (Image *)ptr->owner_id;
771 int num_slots = BLI_listbase_count(&image->renderslots);
772 image->render_slot = value;
774 CLAMP(image->render_slot, 0, num_slots - 1);
775}
776
777static void rna_render_slots_active_index_range(
778 PointerRNA *ptr, int *min, int *max, int * /*softmin*/, int * /*softmax*/)
779{
780 Image *image = (Image *)ptr->owner_id;
781 *min = 0;
782 *max = max_ii(0, BLI_listbase_count(&image->renderslots) - 1);
783}
784
785static ImageTile *rna_UDIMTile_new(Image *image, int tile_number, const char *label)
786{
787 ImageTile *tile = BKE_image_add_tile(image, tile_number, label);
788
790
791 return tile;
792}
793
794static void rna_UDIMTile_remove(Image *image, PointerRNA *ptr)
795{
796 ImageTile *tile = (ImageTile *)ptr->data;
798
800}
801
802#else
803
805{
806 StructRNA *srna;
807 PropertyRNA *prop;
808
809 srna = RNA_def_struct(brna, "ImageUser", nullptr);
811 srna,
812 "Image User",
813 "Parameters defining how an Image data-block is used by another data-block");
814 RNA_def_struct_path_func(srna, "rna_ImageUser_path");
815
817
818 prop = RNA_def_property(srna, "use_auto_refresh", PROP_BOOLEAN, PROP_NONE);
819 RNA_def_property_boolean_sdna(prop, nullptr, "flag", IMA_ANIM_ALWAYS);
820 RNA_def_property_ui_text(prop, "Auto Refresh", "Always refresh image on frame changes");
821 RNA_def_property_update(prop, 0, "rna_ImageUser_relations_update");
823
824 prop = RNA_def_property(srna, "frame_current", PROP_INT, PROP_TIME);
825 RNA_def_property_int_sdna(prop, nullptr, "framenr");
828 prop, "Current Frame", "Current frame number in image sequence or movie");
829
830 /* animation */
831 prop = RNA_def_property(srna, "use_cyclic", PROP_BOOLEAN, PROP_NONE);
832 RNA_def_property_boolean_sdna(prop, nullptr, "cycl", 0);
833 RNA_def_property_ui_text(prop, "Cyclic", "Cycle the images in the movie");
834 RNA_def_property_update(prop, 0, "rna_ImageUser_update");
836
837 prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_NONE);
838 RNA_def_property_int_sdna(prop, nullptr, "frames");
840 RNA_def_property_ui_text(prop, "Frames", "Number of images of a movie to use");
841 RNA_def_property_update(prop, 0, "rna_ImageUser_update");
843
844 prop = RNA_def_property(srna, "frame_offset", PROP_INT, PROP_NONE);
845 RNA_def_property_int_sdna(prop, nullptr, "offset");
847 prop, "Offset", "Offset the number of the frame to use in the animation");
848 RNA_def_property_update(prop, 0, "rna_ImageUser_update");
849
850 prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
851 RNA_def_property_int_sdna(prop, nullptr, "sfra");
854 prop,
855 "Start Frame",
856 "Global starting frame of the movie/sequence, assuming first picture has a #1");
857 RNA_def_property_update(prop, 0, "rna_ImageUser_update");
859
860 prop = RNA_def_property(srna, "multilayer_layer", PROP_INT, PROP_UNSIGNED);
861 RNA_def_property_int_sdna(prop, nullptr, "layer");
862 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* image_multi_cb */
863 RNA_def_property_ui_text(prop, "Layer", "Layer in multilayer image");
864
865 prop = RNA_def_property(srna, "multilayer_pass", PROP_INT, PROP_UNSIGNED);
866 RNA_def_property_int_sdna(prop, nullptr, "pass");
867 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* image_multi_cb */
868 RNA_def_property_ui_text(prop, "Pass", "Pass in multilayer image");
869
870 prop = RNA_def_property(srna, "multilayer_view", PROP_INT, PROP_UNSIGNED);
871 RNA_def_property_int_sdna(prop, nullptr, "view");
872 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* image_multi_cb */
873 RNA_def_property_ui_text(prop, "View", "View in multilayer image");
874
875 prop = RNA_def_property(srna, "tile", PROP_INT, PROP_UNSIGNED);
876 RNA_def_property_int_sdna(prop, nullptr, "tile");
878 RNA_def_property_ui_text(prop, "Tile", "Tile in tiled image");
879
881}
882
883/* image.packed_files */
885{
886 StructRNA *srna;
887 PropertyRNA *prop;
888
889 srna = RNA_def_struct(brna, "ImagePackedFile", nullptr);
890 RNA_def_struct_sdna(srna, "ImagePackedFile");
891
892 prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
893 RNA_def_property_pointer_sdna(prop, nullptr, "packedfile");
894 RNA_def_property_ui_text(prop, "Packed File", "");
896
897 prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
898 RNA_def_property_string_sdna(prop, nullptr, "filepath");
901
902 prop = RNA_def_property(srna, "view", PROP_INT, PROP_NONE);
903 RNA_def_property_int_sdna(prop, nullptr, "view");
904 RNA_def_property_ui_text(prop, "View Index", "");
906
907 prop = RNA_def_property(srna, "tile_number", PROP_INT, PROP_NONE);
908 RNA_def_property_int_sdna(prop, nullptr, "tile_number");
909 RNA_def_property_ui_text(prop, "Tile Number", "");
911
913}
914
916{
917 StructRNA *srna;
918 PropertyRNA *prop, *parm;
919 FunctionRNA *func;
920
921 srna = RNA_def_struct(brna, "RenderSlot", nullptr);
922 RNA_def_struct_ui_text(srna, "Render Slot", "Parameters defining the render slot");
923
924 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
925 RNA_def_property_string_sdna(prop, nullptr, "name");
926 RNA_def_property_ui_text(prop, "Name", "Render slot name");
928
929 func = RNA_def_function(srna, "clear", "rna_RenderSlot_clear");
931 RNA_def_function_ui_description(func, "Clear the render slot");
932 parm = RNA_def_pointer(func, "iuser", "ImageUser", "ImageUser", "");
934}
935
937{
938 StructRNA *srna;
939 FunctionRNA *func;
940 PropertyRNA *prop, *parm;
941
942 RNA_def_property_srna(cprop, "RenderSlots");
943 srna = RNA_def_struct(brna, "RenderSlots", nullptr);
944 RNA_def_struct_sdna(srna, "Image");
945 RNA_def_struct_ui_text(srna, "Render Layers", "Collection of render layers");
946
947 prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
948 RNA_def_property_int_sdna(prop, nullptr, "render_slot");
950 "rna_render_slots_active_index_get",
951 "rna_render_slots_active_index_set",
952 "rna_render_slots_active_index_range");
953 RNA_def_property_ui_text(prop, "Active", "Active render slot of the image");
955
956 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
957 RNA_def_property_struct_type(prop, "RenderSlot");
959 prop, "rna_render_slots_active_get", "rna_render_slots_active_set", nullptr, nullptr);
961 RNA_def_property_ui_text(prop, "Active", "Active render slot of the image");
963
964 func = RNA_def_function(srna, "new", "BKE_image_add_renderslot");
965 RNA_def_function_ui_description(func, "Add a render slot to the image");
966 parm = RNA_def_string(func, "name", nullptr, 0, "Name", "New name for the render slot");
967 parm = RNA_def_pointer(func, "result", "RenderSlot", "", "Newly created render layer");
968 RNA_def_function_return(func, parm);
969}
970
972{
973 StructRNA *srna;
974 PropertyRNA *prop;
975
976 srna = RNA_def_struct(brna, "UDIMTile", nullptr);
977 RNA_def_struct_sdna(srna, "ImageTile");
978 RNA_def_struct_ui_text(srna, "UDIM Tile", "Properties of the UDIM tile");
979
980 prop = RNA_def_property(srna, "label", PROP_STRING, PROP_NONE);
981 RNA_def_property_string_sdna(prop, nullptr, "label");
982 RNA_def_property_ui_text(prop, "Label", "Tile label");
984 prop, "rna_UDIMTile_label_get", "rna_UDIMTile_label_length", nullptr);
986
987 prop = RNA_def_property(srna, "number", PROP_INT, PROP_NONE);
988 RNA_def_property_int_sdna(prop, nullptr, "tile_number");
989 RNA_def_property_ui_text(prop, "Number", "Number of the position that this tile covers");
990 RNA_def_property_int_funcs(prop, nullptr, "rna_UDIMTile_tile_number_set", nullptr);
992
993 prop = RNA_def_int_vector(
994 srna,
995 "size",
996 2,
997 nullptr,
998 0,
999 0,
1000 "Size",
1001 "Width and height of the tile buffer in pixels, zero when image data cannot be loaded",
1002 0,
1003 0);
1005 RNA_def_property_int_funcs(prop, "rna_UDIMTile_size_get", nullptr, nullptr);
1007
1008 prop = RNA_def_property(srna, "channels", PROP_INT, PROP_UNSIGNED);
1009 RNA_def_property_int_funcs(prop, "rna_UDIMTile_channels_get", nullptr, nullptr);
1010 RNA_def_property_ui_text(prop, "Channels", "Number of channels in the tile pixels buffer");
1012
1013 /* Generated tile information. */
1014 prop = RNA_def_property(srna, "generated_type", PROP_ENUM, PROP_NONE);
1015 RNA_def_property_enum_sdna(prop, nullptr, "gen_type");
1017 RNA_def_property_ui_text(prop, "Generated Type", "Generated image type");
1018 RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_UDIMTile_generated_update");
1020
1021 prop = RNA_def_property(srna, "generated_width", PROP_INT, PROP_PIXEL);
1022 RNA_def_property_int_sdna(prop, nullptr, "gen_x");
1024 RNA_def_property_range(prop, 1, 65536);
1025 RNA_def_property_ui_text(prop, "Generated Width", "Generated image width");
1026 RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_UDIMTile_generated_update");
1028
1029 prop = RNA_def_property(srna, "generated_height", PROP_INT, PROP_PIXEL);
1030 RNA_def_property_int_sdna(prop, nullptr, "gen_y");
1032 RNA_def_property_range(prop, 1, 65536);
1033 RNA_def_property_ui_text(prop, "Generated Height", "Generated image height");
1034 RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_UDIMTile_generated_update");
1036
1037 prop = RNA_def_property(srna, "use_generated_float", PROP_BOOLEAN, PROP_NONE);
1038 RNA_def_property_boolean_sdna(prop, nullptr, "gen_flag", IMA_GEN_FLOAT);
1039 RNA_def_property_ui_text(prop, "Float Buffer", "Generate floating-point buffer");
1040 RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_UDIMTile_generated_update");
1042
1043 prop = RNA_def_property(srna, "is_generated_tile", PROP_BOOLEAN, PROP_NONE);
1044 RNA_def_property_boolean_sdna(prop, nullptr, "gen_flag", IMA_GEN_TILE);
1045 RNA_def_property_ui_text(prop, "Is Generated Tile", "Is this image tile generated");
1047
1048 prop = RNA_def_property(srna, "generated_color", PROP_FLOAT, PROP_COLOR_GAMMA);
1049 RNA_def_property_float_sdna(prop, nullptr, "gen_color");
1050 RNA_def_property_array(prop, 4);
1051 RNA_def_property_ui_text(prop, "Color", "Fill color for the generated image");
1052 RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_UDIMTile_generated_update");
1054}
1055
1057{
1058 StructRNA *srna;
1059 PropertyRNA *prop;
1060
1061 FunctionRNA *func;
1062 PropertyRNA *parm;
1063
1064 RNA_def_property_srna(cprop, "UDIMTiles");
1065 srna = RNA_def_struct(brna, "UDIMTiles", nullptr);
1066 RNA_def_struct_sdna(srna, "Image");
1067 RNA_def_struct_ui_text(srna, "UDIM Tiles", "Collection of UDIM tiles");
1068
1069 prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
1070 RNA_def_property_int_sdna(prop, nullptr, "active_tile_index");
1072 "rna_Image_active_tile_index_get",
1073 "rna_Image_active_tile_index_set",
1074 "rna_Image_active_tile_index_range");
1075 RNA_def_property_ui_text(prop, "Active Tile Index", "Active index in tiles array");
1076
1077 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1078 RNA_def_property_struct_type(prop, "UDIMTile");
1080 prop, "rna_Image_active_tile_get", "rna_Image_active_tile_set", nullptr, nullptr);
1082 RNA_def_property_ui_text(prop, "Active Image Tile", "Active Image Tile");
1083
1084 func = RNA_def_function(srna, "new", "rna_UDIMTile_new");
1085 RNA_def_function_ui_description(func, "Add a tile to the image");
1086 parm = RNA_def_int(
1087 func, "tile_number", 1, 1, INT_MAX, "", "Number of the newly created tile", 1, 100);
1089 parm = RNA_def_string(func, "label", nullptr, 0, "", "Optional label for the tile");
1090 parm = RNA_def_pointer(func, "result", "UDIMTile", "", "Newly created image tile");
1091 RNA_def_function_return(func, parm);
1092
1093 func = RNA_def_function(srna, "get", "BKE_image_get_tile");
1094 RNA_def_function_ui_description(func, "Get a tile based on its tile number");
1095 parm = RNA_def_int(func, "tile_number", 0, 0, INT_MAX, "", "Number of the tile", 0, 100);
1097 parm = RNA_def_pointer(func, "result", "UDIMTile", "", "The tile");
1098 RNA_def_function_return(func, parm);
1099
1100 func = RNA_def_function(srna, "remove", "rna_UDIMTile_remove");
1101 RNA_def_function_ui_description(func, "Remove an image tile");
1102 parm = RNA_def_pointer(func, "tile", "UDIMTile", "", "Image tile to remove");
1105}
1106
1107static void rna_def_image(BlenderRNA *brna)
1108{
1109 StructRNA *srna;
1110 PropertyRNA *prop;
1111 static const EnumPropertyItem prop_type_items[] = {
1112 {IMA_TYPE_IMAGE, "IMAGE", 0, "Image", ""},
1113 {IMA_TYPE_MULTILAYER, "MULTILAYER", 0, "Multilayer", ""},
1114 {IMA_TYPE_UV_TEST, "UV_TEST", 0, "UV Test", ""},
1115 {IMA_TYPE_R_RESULT, "RENDER_RESULT", 0, "Render Result", ""},
1116 {IMA_TYPE_COMPOSITE, "COMPOSITING", 0, "Compositing", ""},
1117 {0, nullptr, 0, nullptr, nullptr},
1118 };
1119 static const EnumPropertyItem alpha_mode_items[] = {
1121 "STRAIGHT",
1122 0,
1123 "Straight",
1124 "Store RGB and alpha channels separately with alpha acting as a mask, also known as "
1125 "unassociated alpha. Commonly used by image editing applications and file formats like "
1126 "PNG."},
1128 "PREMUL",
1129 0,
1130 "Premultiplied",
1131 "Store RGB channels with alpha multiplied in, also known as associated alpha. The natural "
1132 "format for renders and used by file formats like OpenEXR."},
1134 "CHANNEL_PACKED",
1135 0,
1136 "Channel Packed",
1137 "Different images are packed in the RGB and alpha channels, and they should not "
1138 "affect each other. Channel packing is commonly used by game engines to save memory."},
1140 "NONE",
1141 0,
1142 "None",
1143 "Ignore alpha channel from the file and make image fully opaque"},
1144 {0, nullptr, 0, nullptr, nullptr},
1145 };
1146
1147 srna = RNA_def_struct(brna, "Image", "ID");
1149 srna, "Image", "Image data-block referencing an external or packed image");
1150 RNA_def_struct_ui_icon(srna, ICON_IMAGE_DATA);
1151
1152 prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
1154 RNA_def_property_string_sdna(prop, nullptr, "filepath");
1156 RNA_def_property_ui_text(prop, "File Name", "Image/Movie file name");
1157 RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_reload_update");
1158
1159 /* eek. this is horrible but needed so we can save to a new name without blanking the data :( */
1160 prop = RNA_def_property(srna, "filepath_raw", PROP_STRING, PROP_FILEPATH);
1161 RNA_def_property_string_sdna(prop, nullptr, "filepath");
1163 RNA_def_property_ui_text(prop, "File Name", "Image/Movie file name (without data refreshing)");
1164
1165 prop = RNA_def_property(srna, "file_format", PROP_ENUM, PROP_NONE);
1168 prop, "rna_Image_file_format_get", "rna_Image_file_format_set", nullptr);
1169 RNA_def_property_ui_text(prop, "File Format", "Format used for re-saving this file");
1170
1171 prop = RNA_def_property(srna, "source", PROP_ENUM, PROP_NONE);
1174 RNA_def_property_enum_funcs(prop, nullptr, "rna_Image_source_set", "rna_Image_source_itemf");
1175 RNA_def_property_ui_text(prop, "Source", "Where the image comes from");
1177
1178 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1179 RNA_def_property_enum_items(prop, prop_type_items);
1181 RNA_def_property_ui_text(prop, "Type", "How to generate the image");
1183
1184 prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
1185 RNA_def_property_struct_type(prop, "PackedFile");
1186 RNA_def_property_pointer_sdna(prop, nullptr, "packedfile");
1187 RNA_def_property_pointer_funcs(prop, "rna_Image_packed_file_get", nullptr, nullptr, nullptr);
1188 RNA_def_property_ui_text(prop, "Packed File", "First packed file of the image");
1189
1190 prop = RNA_def_property(srna, "packed_files", PROP_COLLECTION, PROP_NONE);
1191 RNA_def_property_collection_sdna(prop, nullptr, "packedfiles", nullptr);
1192 RNA_def_property_struct_type(prop, "ImagePackedFile");
1194 RNA_def_property_ui_text(prop, "Packed Files", "Collection of packed images");
1195
1196 prop = RNA_def_property(srna, "use_view_as_render", PROP_BOOLEAN, PROP_NONE);
1198 RNA_def_property_boolean_sdna(prop, nullptr, "flag", IMA_VIEW_AS_RENDER);
1200 prop,
1201 "View as Render",
1202 "Apply render part of display transformation when displaying this image on the screen");
1204
1205 prop = RNA_def_property(srna, "use_deinterlace", PROP_BOOLEAN, PROP_NONE);
1207 RNA_def_property_boolean_sdna(prop, nullptr, "flag", IMA_DEINTERLACE);
1208 RNA_def_property_ui_text(prop, "Deinterlace", "Deinterlace movie file on load");
1209 RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_reload_update");
1210
1211 prop = RNA_def_property(srna, "use_multiview", PROP_BOOLEAN, PROP_NONE);
1213 RNA_def_property_boolean_sdna(prop, nullptr, "flag", IMA_USE_VIEWS);
1214 RNA_def_property_ui_text(prop, "Use Multi-View", "Use Multiple Views (when available)");
1215 RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_views_format_update");
1216
1217 prop = RNA_def_property(srna, "is_stereo_3d", PROP_BOOLEAN, PROP_NONE);
1219 RNA_def_property_boolean_funcs(prop, "rna_Image_is_stereo_3d_get", nullptr);
1220 RNA_def_property_ui_text(prop, "Stereo 3D", "Image has left and right views");
1222
1223 prop = RNA_def_property(srna, "is_multiview", PROP_BOOLEAN, PROP_NONE);
1225 RNA_def_property_boolean_funcs(prop, "rna_Image_is_multiview_get", nullptr);
1226 RNA_def_property_ui_text(prop, "Multiple Views", "Image has more than one view");
1228
1229 prop = RNA_def_property(srna, "is_dirty", PROP_BOOLEAN, PROP_NONE);
1231 RNA_def_property_boolean_funcs(prop, "rna_Image_dirty_get", nullptr);
1233 RNA_def_property_ui_text(prop, "Dirty", "Image has changed and is not saved");
1234
1235 /* generated image (image_generated_change_cb) */
1236 prop = RNA_def_property(srna, "generated_type", PROP_ENUM, PROP_NONE);
1237 RNA_def_property_enum_sdna(prop, nullptr, "gen_type");
1239 RNA_def_property_ui_text(prop, "Generated Type", "Generated image type");
1241 prop, "rna_Image_generated_type_get", "rna_Image_generated_type_set", nullptr);
1242 RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");
1244
1245 prop = RNA_def_property(srna, "generated_width", PROP_INT, PROP_PIXEL);
1246 RNA_def_property_int_sdna(prop, nullptr, "gen_x");
1248 RNA_def_property_range(prop, 1, 65536);
1249 RNA_def_property_ui_text(prop, "Generated Width", "Generated image width");
1251 prop, "rna_Image_generated_width_get", "rna_Image_generated_width_set", nullptr);
1252 RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");
1254
1255 prop = RNA_def_property(srna, "generated_height", PROP_INT, PROP_PIXEL);
1256 RNA_def_property_int_sdna(prop, nullptr, "gen_y");
1258 RNA_def_property_range(prop, 1, 65536);
1259 RNA_def_property_ui_text(prop, "Generated Height", "Generated image height");
1261 prop, "rna_Image_generated_height_get", "rna_Image_generated_height_set", nullptr);
1262 RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");
1264
1265 prop = RNA_def_property(srna, "use_generated_float", PROP_BOOLEAN, PROP_NONE);
1266 RNA_def_property_boolean_sdna(prop, nullptr, "gen_flag", IMA_GEN_FLOAT);
1267 RNA_def_property_ui_text(prop, "Float Buffer", "Generate floating-point buffer");
1269 prop, "rna_Image_generated_float_get", "rna_Image_generated_float_set");
1270 RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");
1272
1273 prop = RNA_def_property(srna, "generated_color", PROP_FLOAT, PROP_COLOR_GAMMA);
1274 RNA_def_property_float_sdna(prop, nullptr, "gen_color");
1275 RNA_def_property_array(prop, 4);
1276 RNA_def_property_ui_text(prop, "Color", "Fill color for the generated image");
1278 prop, "rna_Image_generated_color_get", "rna_Image_generated_color_set", nullptr);
1279 RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");
1281
1282 prop = RNA_def_property(srna, "display_aspect", PROP_FLOAT, PROP_XYZ);
1284 RNA_def_property_float_sdna(prop, nullptr, "aspx");
1285 RNA_def_property_array(prop, 2);
1286 RNA_def_property_range(prop, 0.1f, FLT_MAX);
1287 RNA_def_property_ui_range(prop, 0.1f, 5000.0f, 1, 2);
1289 prop, "Display Aspect", "Display Aspect for this image, does not affect rendering");
1291
1292 prop = RNA_def_property(srna, "render_slots", PROP_COLLECTION, PROP_NONE);
1293 RNA_def_property_struct_type(prop, "RenderSlot");
1294 RNA_def_property_collection_sdna(prop, nullptr, "renderslots", nullptr);
1295 RNA_def_property_ui_text(prop, "Render Slots", "Render slots of the image");
1296 rna_def_render_slots(brna, prop);
1297
1298 prop = RNA_def_property(srna, "tiles", PROP_COLLECTION, PROP_NONE);
1299 RNA_def_property_struct_type(prop, "UDIMTile");
1300 RNA_def_property_collection_sdna(prop, nullptr, "tiles", nullptr);
1301 RNA_def_property_ui_text(prop, "Image Tiles", "Tiles of the image");
1302 rna_def_udim_tiles(brna, prop);
1303
1304 prop = RNA_def_property(srna, "has_data", PROP_BOOLEAN, PROP_NONE);
1305 RNA_def_property_boolean_funcs(prop, "rna_Image_has_data_get", nullptr);
1307 RNA_def_property_ui_text(prop, "Has Data", "True if the image data is loaded into memory");
1308
1309 prop = RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED);
1310 RNA_def_property_int_funcs(prop, "rna_Image_depth_get", nullptr, nullptr);
1311 RNA_def_property_ui_text(prop, "Depth", "Image bit depth");
1313
1314 prop = RNA_def_int_vector(
1315 srna,
1316 "size",
1317 2,
1318 nullptr,
1319 0,
1320 0,
1321 "Size",
1322 "Width and height of the image buffer in pixels, zero when image data cannot be loaded",
1323 0,
1324 0);
1326 RNA_def_property_int_funcs(prop, "rna_Image_size_get", nullptr, nullptr);
1328
1329 prop = RNA_def_float_vector(srna,
1330 "resolution",
1331 2,
1332 nullptr,
1333 0,
1334 0,
1335 "Resolution",
1336 "X/Y pixels per meter, for the image buffer",
1337 0,
1338 0);
1341 prop, "rna_Image_resolution_get", "rna_Image_resolution_set", nullptr);
1342
1343 prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_UNSIGNED);
1344 RNA_def_property_int_funcs(prop, "rna_Image_frame_duration_get", nullptr, nullptr);
1346 prop, "Duration", "Duration (in frames) of the image (1 when not a video/sequence)");
1348
1349 /* NOTE: About pixels/channels/is_float:
1350 * These properties describe how the image is stored internally (inside of ImBuf),
1351 * not how it was saved to disk or how it'll be saved on disk.
1352 */
1353 prop = RNA_def_property(srna, "pixels", PROP_FLOAT, PROP_NONE);
1355 RNA_def_property_multi_array(prop, 1, nullptr);
1356 RNA_def_property_ui_text(prop, "Pixels", "Image buffer pixels in floating-point values");
1357 RNA_def_property_dynamic_array_funcs(prop, "rna_Image_pixels_get_length");
1358 RNA_def_property_float_funcs(prop, "rna_Image_pixels_get", "rna_Image_pixels_set", nullptr);
1359
1360 prop = RNA_def_property(srna, "channels", PROP_INT, PROP_UNSIGNED);
1361 RNA_def_property_int_funcs(prop, "rna_Image_channels_get", nullptr, nullptr);
1362 RNA_def_property_ui_text(prop, "Channels", "Number of channels in pixels buffer");
1364
1365 prop = RNA_def_property(srna, "is_float", PROP_BOOLEAN, PROP_NONE);
1366 RNA_def_property_boolean_funcs(prop, "rna_Image_is_float_get", nullptr);
1369 prop, "Is Float", "True if this image is stored in floating-point buffer");
1370
1371 prop = RNA_def_property(srna, "colorspace_settings", PROP_POINTER, PROP_NONE);
1372 RNA_def_property_pointer_sdna(prop, nullptr, "colorspace_settings");
1373 RNA_def_property_struct_type(prop, "ColorManagedInputColorspaceSettings");
1374 RNA_def_property_ui_text(prop, "Color Space Settings", "Input color space settings");
1375
1376 prop = RNA_def_property(srna, "alpha_mode", PROP_ENUM, PROP_NONE);
1378 RNA_def_property_enum_items(prop, alpha_mode_items);
1380 "Alpha Mode",
1381 "Representation of alpha in the image file, to convert to and from "
1382 "when saving and loading the image");
1383 RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_alpha_mode_update");
1384
1385 prop = RNA_def_property(srna, "use_half_precision", PROP_BOOLEAN, PROP_NONE);
1388 "Half Float Precision",
1389 "Use 16 bits per channel to lower the memory usage during rendering");
1390 RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_gpu_texture_update");
1391
1392 prop = RNA_def_property(srna, "seam_margin", PROP_INT, PROP_NONE);
1394 prop,
1395 "Seam Margin",
1396 "Margin to take into account when fixing UV seams during painting. Higher "
1397 "number would improve seam-fixes for mipmaps, but decreases performance.");
1398 RNA_def_property_ui_range(prop, 1, 100, 1, 1);
1399
1400 /* multiview */
1401 prop = RNA_def_property(srna, "views_format", PROP_ENUM, PROP_NONE);
1403 RNA_def_property_enum_sdna(prop, nullptr, "views_format");
1405 RNA_def_property_ui_text(prop, "Views Format", "Mode to load image views");
1406 RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_views_format_update");
1407
1408 prop = RNA_def_property(srna, "stereo_3d_format", PROP_POINTER, PROP_NONE);
1409 RNA_def_property_pointer_sdna(prop, nullptr, "stereo3d_format");
1411 RNA_def_property_struct_type(prop, "Stereo3dFormat");
1412 RNA_def_property_ui_text(prop, "Stereo 3D Format", "Settings for stereo 3d");
1413
1414 RNA_api_image(srna);
1415}
1416
1418{
1419 rna_def_render_slot(brna);
1420 rna_def_udim_tile(brna);
1421 rna_def_image(brna);
1422 rna_def_imageuser(brna);
1424}
1425
1426#endif
#define G_MAIN
RenderSlot * BKE_image_get_renderslot(Image *ima, int index)
ImBuf * BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
void BKE_image_user_frame_calc(Image *ima, ImageUser *iuser, int cfra)
void BKE_image_mark_dirty(Image *image, ImBuf *ibuf)
bool BKE_image_fill_tile(Image *ima, ImageTile *tile)
void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
bool BKE_image_is_dirty(Image *image)
#define IMA_SIGNAL_COLORMANAGE
Definition BKE_image.hh:174
int BKE_image_get_tile_label(const Image *ima, const ImageTile *tile, char *label, int label_maxncpy)
bool BKE_image_has_anim(Image *image)
#define IMA_SIGNAL_FREE
Definition BKE_image.hh:169
void BKE_imageuser_default(ImageUser *iuser)
void BKE_image_free_gputextures(Image *ima)
Definition image_gpu.cc:581
#define IMA_SIGNAL_SRC_CHANGE
Definition BKE_image.hh:171
bool BKE_image_is_stereo(const Image *ima)
bool BKE_image_is_multiview(const Image *ima)
#define IMA_SIGNAL_RELOAD
Definition BKE_image.hh:168
bool BKE_image_has_packedfile(const Image *image)
void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal)
void BKE_image_reassign_tile(Image *ima, ImageTile *tile, int new_tile_number)
bool BKE_image_clear_renderslot(Image *ima, ImageUser *iuser, int slot)
ImageTile * BKE_image_add_tile(Image *ima, int tile_number, const char *label)
void BKE_image_file_format_set(Image *image, int ftype, const ImbFormatOptions *options)
bool BKE_image_remove_tile(Image *ima, ImageTile *tile)
void BKE_image_partial_update_mark_full_update(Image *image)
Mark the whole image to be updated.
bool BKE_image_has_loaded_ibuf(Image *image)
char BKE_ftype_to_imtype(int ftype, const ImbFormatOptions *options)
int BKE_imtype_to_ftype(char imtype, ImbFormatOptions *r_options)
bool BKE_imtype_is_movie(char imtype)
bool BKE_id_is_in_global_main(ID *id)
Definition lib_id.cc:2500
void BKE_main_ensure_invariants(Main &bmain, std::optional< blender::Span< ID * > > modified_ids=std::nullopt)
void BKE_ntree_update_tag_image_user_changed(bNodeTree *ntree, ImageUser *iuser)
#define BLI_assert(a)
Definition BLI_assert.h:46
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:586
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:534
#define LISTBASE_FOREACH_INDEX(type, var, list, index_var)
int BLI_listbase_count(const ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:524
MINLINE int min_ii(int a, int b)
MINLINE int max_ii(int a, int b)
MINLINE void copy_v4_v4(float r[4], const float a[4])
unsigned int uint
#define CLAMP(a, b, c)
#define BLT_I18NCONTEXT_ID_IMAGE
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
@ ID_RECALC_SOURCE
Definition DNA_ID.h:1143
@ ID_RECALC_EDITORS
Definition DNA_ID.h:1111
@ ID_CA
@ ID_TE
@ ID_NT
@ ID_SCR
@ ID_OB
@ IMA_GEN_TILE
@ IMA_GEN_FLOAT
@ IMA_SRC_FILE
@ IMA_SRC_MOVIE
@ IMA_SRC_GENERATED
@ IMA_SRC_VIEWER
@ IMA_SRC_TILED
@ IMA_SRC_SEQUENCE
@ IMA_GENTYPE_GRID_COLOR
@ IMA_GENTYPE_GRID
@ IMA_GENTYPE_BLANK
@ IMA_DEINTERLACE
@ IMA_HIGH_BITDEPTH
@ IMA_USE_VIEWS
@ IMA_VIEW_AS_RENDER
@ IMA_ALPHA_IGNORE
@ IMA_ALPHA_STRAIGHT
@ IMA_ALPHA_PREMUL
@ IMA_ALPHA_CHANNEL_PACKED
@ IMA_TYPE_MULTILAYER
@ IMA_TYPE_UV_TEST
@ IMA_TYPE_R_RESULT
@ IMA_TYPE_COMPOSITE
@ IMA_TYPE_IMAGE
@ IMA_ANIM_ALWAYS
#define MINAFRAME
#define MAXFRAMEF
#define MINAFRAMEF
#define MAXFRAME
@ SPACE_IMAGE
size_t IMB_get_pixel_count(const ImBuf *ibuf)
Get the length of the data of the given image buffer in pixels.
@ IMB_FTYPE_NONE
@ IB_DISPLAY_BUFFER_INVALID
@ IMB_TC_RECORD_RUN
Definition MOV_enums.hh:54
#define RNA_MAX_ARRAY_DIMENSION
Definition RNA_define.hh:27
ParameterFlag
Definition RNA_types.hh:544
@ PARM_RNAPTR
Definition RNA_types.hh:547
@ PARM_REQUIRED
Definition RNA_types.hh:545
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:889
@ PROP_FLOAT
Definition RNA_types.hh:164
@ PROP_BOOLEAN
Definition RNA_types.hh:162
@ PROP_ENUM
Definition RNA_types.hh:166
@ PROP_INT
Definition RNA_types.hh:163
@ PROP_STRING
Definition RNA_types.hh:165
@ PROP_POINTER
Definition RNA_types.hh:167
@ PROP_COLLECTION
Definition RNA_types.hh:168
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition RNA_types.hh:503
PropertyFlag
Definition RNA_types.hh:300
@ PROP_THICK_WRAP
Definition RNA_types.hh:423
@ PROP_DYNAMIC
Definition RNA_types.hh:428
@ PROP_ANIMATABLE
Definition RNA_types.hh:319
@ PROP_PROPORTIONAL
Definition RNA_types.hh:349
@ PROP_PATH_SUPPORTS_BLEND_RELATIVE
Definition RNA_types.hh:456
@ PROP_EDITABLE
Definition RNA_types.hh:306
@ PROP_NEVER_NULL
Definition RNA_types.hh:377
@ PROP_TIME
Definition RNA_types.hh:253
@ PROP_XYZ
Definition RNA_types.hh:269
@ PROP_PIXEL
Definition RNA_types.hh:248
@ PROP_NONE
Definition RNA_types.hh:233
@ PROP_COLOR_GAMMA
Definition RNA_types.hh:272
@ PROP_UNSIGNED
Definition RNA_types.hh:249
@ PROP_FILEPATH
Definition RNA_types.hh:236
#define ND_DRAW
Definition WM_types.hh:461
#define ND_DISPLAY
Definition WM_types.hh:491
#define NA_EDITED
Definition WM_types.hh:584
#define NC_IMAGE
Definition WM_types.hh:384
volatile int lock
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
CCL_NAMESPACE_BEGIN struct Options options
#define GS(x)
float length(VecOp< float, D >) RET
ccl_gpu_kernel_postfix ccl_global KernelWorkTile const int num_tiles
const ccl_global KernelWorkTile * tile
MINLINE unsigned char unit_float_to_uchar_clamp(float val)
#define G(x, y, z)
int MOV_get_duration_frames(MovieReader *anim, IMB_Timecode_Type tc)
const PointerRNA PointerRNA_NULL
PointerRNA RNA_pointer_create_with_parent(const PointerRNA &parent, StructRNA *type, void *data)
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_struct_name_property(StructRNA *srna, PropertyRNA *prop)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_define_lib_overridable(const bool make_overridable)
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
PropertyRNA * RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
void RNA_def_property_dynamic_array_funcs(PropertyRNA *prop, const char *getlength)
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
PropertyRNA * RNA_def_int_vector(StructOrFunctionRNA *cont_, const char *identifier, const int len, const int *default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
void RNA_def_property_array(PropertyRNA *prop, int length)
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
void RNA_def_function_flag(FunctionRNA *func, int flag)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_subtype(PropertyRNA *prop, PropertySubType subtype)
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_enum_items_add_value(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item, int value)
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_image(BlenderRNA *brna)
static void rna_def_image(BlenderRNA *brna)
static void rna_def_render_slot(BlenderRNA *brna)
Definition rna_image.cc:915
static void rna_def_render_slots(BlenderRNA *brna, PropertyRNA *cprop)
Definition rna_image.cc:936
static const EnumPropertyItem image_source_items[]
Definition rna_image.cc:35
static void rna_def_image_packed_files(BlenderRNA *brna)
Definition rna_image.cc:884
static void rna_def_udim_tile(BlenderRNA *brna)
Definition rna_image.cc:971
static void rna_def_udim_tiles(BlenderRNA *brna, PropertyRNA *cprop)
static void rna_def_imageuser(BlenderRNA *brna)
Definition rna_image.cc:804
const EnumPropertyItem rna_enum_image_generated_type_items[]
Definition rna_image.cc:24
void RNA_api_image(StructRNA *srna)
void RNA_api_image_packed_file(StructRNA *srna)
std::optional< std::string > rna_CameraBackgroundImage_image_or_movieclip_user_path(const PointerRNA *ptr)
std::optional< std::string > rna_Node_ImageUser_path(const PointerRNA *ptr)
const EnumPropertyItem rna_enum_image_type_all_items[]
Definition rna_scene.cc:386
const EnumPropertyItem rna_enum_views_format_items[]
Definition rna_scene.cc:499
#define min(a, b)
Definition sort.cc:36
#define FLT_MAX
Definition stdcycles.h:14
Definition DNA_ID.h:414
char name[258]
Definition DNA_ID.h:432
ImBufFloatBuffer float_buffer
ImbFormatOptions foptions
ImBufByteBuffer byte_buffer
unsigned char planes
enum eImbFileType ftype
double ppm[2]
struct PackedFile * packedfile
float gen_color[4]
struct Scene * scene
ListBase renderslots
short source
struct RenderData r
struct ImageUser iuser
ListBase areabase
void * BKE_image_get_tile
Definition stubs.c:36
i
Definition text_draw.cc:230
max
Definition text_draw.cc:251
uint len
void WM_main_add_notifier(uint type, void *reference)
PointerRNA * ptr
Definition wm_files.cc:4238