Blender  V3.3
image_ops.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
8 #include <errno.h>
9 #include <fcntl.h>
10 #include <stddef.h>
11 #include <stdlib.h>
12 #include <string.h>
13 #ifndef WIN32
14 # include <unistd.h>
15 #else
16 # include <io.h>
17 #endif
18 
19 #include "MEM_guardedalloc.h"
20 
21 #include "BLI_blenlib.h"
22 #include "BLI_fileops.h"
23 #include "BLI_ghash.h"
24 #include "BLI_math.h"
25 #include "BLI_string.h"
26 #include "BLI_utildefines.h"
27 
28 #include "BLT_translation.h"
29 
30 #include "DNA_camera_types.h"
31 #include "DNA_node_types.h"
32 #include "DNA_object_types.h"
33 #include "DNA_scene_types.h"
34 #include "DNA_screen_types.h"
35 
36 #include "BKE_colortools.h"
37 #include "BKE_context.h"
38 #include "BKE_global.h"
39 #include "BKE_icons.h"
40 #include "BKE_image.h"
41 #include "BKE_image_format.h"
42 #include "BKE_image_save.h"
43 #include "BKE_layer.h"
44 #include "BKE_lib_id.h"
45 #include "BKE_main.h"
46 #include "BKE_packedFile.h"
47 #include "BKE_report.h"
48 #include "BKE_scene.h"
49 
50 #include "DEG_depsgraph.h"
51 
52 #include "GPU_state.h"
53 
54 #include "IMB_colormanagement.h"
55 #include "IMB_imbuf.h"
56 #include "IMB_imbuf_types.h"
57 #include "IMB_moviecache.h"
58 #include "IMB_openexr.h"
59 
60 #include "RE_pipeline.h"
61 
62 #include "RNA_access.h"
63 #include "RNA_define.h"
64 #include "RNA_enum_types.h"
65 #include "RNA_prototypes.h"
66 
67 #include "ED_image.h"
68 #include "ED_mask.h"
69 #include "ED_paint.h"
70 #include "ED_render.h"
71 #include "ED_screen.h"
72 #include "ED_space_api.h"
73 #include "ED_util.h"
74 #include "ED_util_imbuf.h"
75 #include "ED_uvedit.h"
76 
77 #include "UI_interface.h"
78 #include "UI_resources.h"
79 #include "UI_view2d.h"
80 
81 #include "WM_api.h"
82 #include "WM_types.h"
83 
84 #include "PIL_time.h"
85 
86 #include "RE_engine.h"
87 
88 #include "image_intern.h"
89 
90 /* -------------------------------------------------------------------- */
94 static void sima_zoom_set(
95  SpaceImage *sima, ARegion *region, float zoom, const float location[2], const bool zoom_to_pos)
96 {
97  float oldzoom = sima->zoom;
98  int width, height;
99 
100  sima->zoom = zoom;
101 
102  if (sima->zoom < 0.1f || sima->zoom > 4.0f) {
103  /* check zoom limits */
105 
106  width *= sima->zoom;
107  height *= sima->zoom;
108 
109  if ((width < 4) && (height < 4) && sima->zoom < oldzoom) {
110  sima->zoom = oldzoom;
111  }
112  else if (BLI_rcti_size_x(&region->winrct) <= sima->zoom) {
113  sima->zoom = oldzoom;
114  }
115  else if (BLI_rcti_size_y(&region->winrct) <= sima->zoom) {
116  sima->zoom = oldzoom;
117  }
118  }
119 
120  if (zoom_to_pos && location) {
121  float aspx, aspy, w, h;
122 
124  ED_space_image_get_aspect(sima, &aspx, &aspy);
125 
126  w = width * aspx;
127  h = height * aspy;
128 
129  sima->xof += ((location[0] - 0.5f) * w - sima->xof) * (sima->zoom - oldzoom) / sima->zoom;
130  sima->yof += ((location[1] - 0.5f) * h - sima->yof) * (sima->zoom - oldzoom) / sima->zoom;
131  }
132 }
133 
135  ARegion *region,
136  float zoomfac,
137  const float location[2],
138  const bool zoom_to_pos)
139 {
140  sima_zoom_set(sima, region, sima->zoom * zoomfac, location, zoom_to_pos);
141 }
142 
146 static void sima_zoom_set_from_bounds(SpaceImage *sima, ARegion *region, const rctf *bounds)
147 {
148  int image_size[2];
149  float aspx, aspy;
150 
151  ED_space_image_get_size(sima, &image_size[0], &image_size[1]);
152  ED_space_image_get_aspect(sima, &aspx, &aspy);
153 
154  image_size[0] = image_size[0] * aspx;
155  image_size[1] = image_size[1] * aspy;
156 
157  /* adjust offset and zoom */
158  sima->xof = roundf((BLI_rctf_cent_x(bounds) - 0.5f) * image_size[0]);
159  sima->yof = roundf((BLI_rctf_cent_y(bounds) - 0.5f) * image_size[1]);
160 
161  float size_xy[2], size;
162  size_xy[0] = BLI_rcti_size_x(&region->winrct) / (BLI_rctf_size_x(bounds) * image_size[0]);
163  size_xy[1] = BLI_rcti_size_y(&region->winrct) / (BLI_rctf_size_y(bounds) * image_size[1]);
164 
165  size = min_ff(size_xy[0], size_xy[1]);
166  CLAMP_MAX(size, 100.0f);
167 
168  sima_zoom_set(sima, region, size, NULL, false);
169 }
170 
172 {
173  /* Edit image is set by templates used throughout the interface, so image
174  * operations work outside the image editor. */
175  Image *ima = CTX_data_pointer_get_type(C, "edit_image", &RNA_Image).data;
176 
177  if (ima) {
178  return ima;
179  }
180 
181  /* Image editor. */
183  return (sima) ? sima->image : NULL;
184 }
185 
187 {
188  /* Edit image user is set by templates used throughout the interface, so
189  * image operations work outside the image editor. */
190  ImageUser *iuser = CTX_data_pointer_get_type(C, "edit_image_user", &RNA_ImageUser).data;
191 
192  if (iuser) {
193  return iuser;
194  }
195 
196  /* Image editor. */
198  return (sima) ? &sima->iuser : NULL;
199 }
200 
202 {
203  /* Try to get image user from context if available, otherwise use default. */
204  ImageUser *iuser_context = image_user_from_context(C);
205  ImageUser iuser;
206  if (iuser_context) {
207  iuser = *iuser_context;
208  }
209  else {
210  BKE_imageuser_default(&iuser);
211  }
212 
213  /* Use the file associated with the active tile. Otherwise use the first tile. */
214  if (ima && ima->source == IMA_SRC_TILED) {
216  iuser.tile = active ? active->tile_number : ((ImageTile *)ima->tiles.first)->tile_number;
217  }
218 
219  return iuser;
220 }
221 
223 {
224  Image *ima = image_from_context(C);
226 
227  if (ima == NULL) {
228  return false;
229  }
230 
231  void *lock;
232  ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock);
233  const bool has_buffer = (ibuf && (ibuf->rect || ibuf->rect_float));
234  BKE_image_release_ibuf(ima, ibuf, lock);
235  return has_buffer;
236 }
237 
242 {
243  Image *ima = image_from_context(C);
245 
246  return BKE_image_has_ibuf(ima, &iuser);
247 }
248 
250 {
251  /* Do not run 'replace' on packed images, it does not give user expected results at all. */
252  Image *ima = image_from_context(C);
253  return (ima && BLI_listbase_is_empty(&ima->packedfiles));
254 }
255 
256 static void image_view_all(struct SpaceImage *sima, struct ARegion *region, struct wmOperator *op)
257 {
258  float aspx, aspy, zoomx, zoomy, w, h;
259  int width, height;
260  const bool fit_view = RNA_boolean_get(op->ptr, "fit_view");
261 
263  ED_space_image_get_aspect(sima, &aspx, &aspy);
264 
265  w = width * aspx;
266  h = height * aspy;
267 
268  float xof = 0.0f, yof = 0.0f;
269  if ((sima->image == NULL) || (sima->image->source == IMA_SRC_TILED)) {
270  /* Extend the shown area to cover all UDIM tiles. */
271  int x_tiles, y_tiles;
272  if (sima->image == NULL) {
273  x_tiles = sima->tile_grid_shape[0];
274  y_tiles = sima->tile_grid_shape[1];
275  }
276  else {
277  x_tiles = y_tiles = 1;
278  LISTBASE_FOREACH (ImageTile *, tile, &sima->image->tiles) {
279  int tile_x = (tile->tile_number - 1001) % 10;
280  int tile_y = (tile->tile_number - 1001) / 10;
281  x_tiles = max_ii(x_tiles, tile_x + 1);
282  y_tiles = max_ii(y_tiles, tile_y + 1);
283  }
284  }
285  xof = 0.5f * (x_tiles - 1.0f) * w;
286  yof = 0.5f * (y_tiles - 1.0f) * h;
287  w *= x_tiles;
288  h *= y_tiles;
289  }
290 
291  /* check if the image will fit in the image with (zoom == 1) */
292  width = BLI_rcti_size_x(&region->winrct) + 1;
293  height = BLI_rcti_size_y(&region->winrct) + 1;
294 
295  if (fit_view) {
296  const int margin = 5; /* margin from border */
297 
298  zoomx = (float)width / (w + 2 * margin);
299  zoomy = (float)height / (h + 2 * margin);
300 
301  sima_zoom_set(sima, region, min_ff(zoomx, zoomy), NULL, false);
302  }
303  else {
304  if ((w >= width || h >= height) && (width > 0 && height > 0)) {
305  zoomx = (float)width / w;
306  zoomy = (float)height / h;
307 
308  /* find the zoom value that will fit the image in the image space */
309  sima_zoom_set(sima, region, 1.0f / power_of_2(1.0f / min_ff(zoomx, zoomy)), NULL, false);
310  }
311  else {
312  sima_zoom_set(sima, region, 1.0f, NULL, false);
313  }
314  }
315 
316  sima->xof = xof;
317  sima->yof = yof;
318 }
319 
321 {
323  /* XXX ARegion *region = CTX_wm_region(C); */
324 
325  if (sima) {
326  return true; /* XXX (region && region->type->regionid == RGN_TYPE_WINDOW); */
327  }
328  return false;
329 }
330 
331 /* For IMAGE_OT_curves_point_set to avoid sampling when in uv smooth mode or editmode */
333 {
336  ToolSettings *toolsettings = scene->toolsettings;
337 
338  if (sima && !toolsettings->uvsculpt && (CTX_data_edit_object(C) == NULL)) {
339  return true;
340  }
341 
342  return false;
343 }
344 
347 /* -------------------------------------------------------------------- */
351 typedef struct ViewPanData {
352  float x, y;
353  float xof, yof;
354  int launch_event;
355  bool own_cursor;
357 
358 static void image_view_pan_init(bContext *C, wmOperator *op, const wmEvent *event)
359 {
360  wmWindow *win = CTX_wm_window(C);
362  ViewPanData *vpd;
363 
364  op->customdata = vpd = MEM_callocN(sizeof(ViewPanData), "ImageViewPanData");
365 
366  /* Grab will be set when running from gizmo. */
367  vpd->own_cursor = (win->grabcursor == 0);
368  if (vpd->own_cursor) {
370  }
371 
372  vpd->x = event->xy[0];
373  vpd->y = event->xy[1];
374  vpd->xof = sima->xof;
375  vpd->yof = sima->yof;
377 
379 }
380 
381 static void image_view_pan_exit(bContext *C, wmOperator *op, bool cancel)
382 {
384  ViewPanData *vpd = op->customdata;
385 
386  if (cancel) {
387  sima->xof = vpd->xof;
388  sima->yof = vpd->yof;
390  }
391 
392  if (vpd->own_cursor) {
394  }
395  MEM_freeN(op->customdata);
396 }
397 
399 {
401  float offset[2];
402 
403  RNA_float_get_array(op->ptr, "offset", offset);
404  sima->xof += offset[0];
405  sima->yof += offset[1];
406 
408 
409  return OPERATOR_FINISHED;
410 }
411 
412 static int image_view_pan_invoke(bContext *C, wmOperator *op, const wmEvent *event)
413 {
414  if (event->type == MOUSEPAN) {
416  float offset[2];
417 
418  offset[0] = (event->prev_xy[0] - event->xy[0]) / sima->zoom;
419  offset[1] = (event->prev_xy[1] - event->xy[1]) / sima->zoom;
420  RNA_float_set_array(op->ptr, "offset", offset);
421 
422  image_view_pan_exec(C, op);
423  return OPERATOR_FINISHED;
424  }
425 
426  image_view_pan_init(C, op, event);
427  return OPERATOR_RUNNING_MODAL;
428 }
429 
430 static int image_view_pan_modal(bContext *C, wmOperator *op, const wmEvent *event)
431 {
433  ViewPanData *vpd = op->customdata;
434  float offset[2];
435 
436  switch (event->type) {
437  case MOUSEMOVE:
438  sima->xof = vpd->xof;
439  sima->yof = vpd->yof;
440  offset[0] = (vpd->x - event->xy[0]) / sima->zoom;
441  offset[1] = (vpd->y - event->xy[1]) / sima->zoom;
442  RNA_float_set_array(op->ptr, "offset", offset);
443  image_view_pan_exec(C, op);
444  break;
445  default:
446  if (event->type == vpd->launch_event && event->val == KM_RELEASE) {
447  image_view_pan_exit(C, op, false);
448  return OPERATOR_FINISHED;
449  }
450  break;
451  }
452 
453  return OPERATOR_RUNNING_MODAL;
454 }
455 
457 {
458  image_view_pan_exit(C, op, true);
459 }
460 
462 {
463  /* identifiers */
464  ot->name = "Pan View";
465  ot->idname = "IMAGE_OT_view_pan";
466  ot->description = "Pan the view";
467 
468  /* api callbacks */
474 
475  /* flags */
477 
478  /* properties */
480  "offset",
481  2,
482  NULL,
483  -FLT_MAX,
484  FLT_MAX,
485  "Offset",
486  "Offset in floating-point units, 1.0 is the width and height of the image",
487  -FLT_MAX,
488  FLT_MAX);
489 }
490 
493 /* -------------------------------------------------------------------- */
497 typedef struct ViewZoomData {
498  float origx, origy;
499  float zoom;
500  int launch_event;
501  float location[2];
502 
503  /* needed for continuous zoom */
504  wmTimer *timer;
505  double timer_lastdraw;
506  bool own_cursor;
507 
508  /* */
512 
513 static void image_view_zoom_init(bContext *C, wmOperator *op, const wmEvent *event)
514 {
515  wmWindow *win = CTX_wm_window(C);
517  ARegion *region = CTX_wm_region(C);
518  ViewZoomData *vpd;
519 
520  op->customdata = vpd = MEM_callocN(sizeof(ViewZoomData), "ImageViewZoomData");
521 
522  /* Grab will be set when running from gizmo. */
523  vpd->own_cursor = (win->grabcursor == 0);
524  if (vpd->own_cursor) {
526  }
527 
528  vpd->origx = event->xy[0];
529  vpd->origy = event->xy[1];
530  vpd->zoom = sima->zoom;
532 
534  &region->v2d, event->mval[0], event->mval[1], &vpd->location[0], &vpd->location[1]);
535 
536  if (U.viewzoom == USER_ZOOM_CONTINUE) {
537  /* needs a timer to continue redrawing */
540  }
541 
542  vpd->sima = sima;
543  vpd->region = region;
544 
546 }
547 
548 static void image_view_zoom_exit(bContext *C, wmOperator *op, bool cancel)
549 {
551  ViewZoomData *vpd = op->customdata;
552 
553  if (cancel) {
554  sima->zoom = vpd->zoom;
556  }
557 
558  if (vpd->timer) {
560  }
561 
562  if (vpd->own_cursor) {
564  }
565  MEM_freeN(op->customdata);
566 }
567 
569 {
571  ARegion *region = CTX_wm_region(C);
572 
573  sima_zoom_set_factor(sima, region, RNA_float_get(op->ptr, "factor"), NULL, false);
574 
575  ED_region_tag_redraw(region);
576 
577  return OPERATOR_FINISHED;
578 }
579 
580 enum {
584 };
585 
586 static int image_view_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *event)
587 {
588  if (ELEM(event->type, MOUSEZOOM, MOUSEPAN)) {
590  ARegion *region = CTX_wm_region(C);
591  float delta, factor, location[2];
592 
594  &region->v2d, event->mval[0], event->mval[1], &location[0], &location[1]);
595 
596  delta = event->prev_xy[0] - event->xy[0] + event->prev_xy[1] - event->xy[1];
597 
598  if (U.uiflag & USER_ZOOM_INVERT) {
599  delta *= -1;
600  }
601 
602  factor = 1.0f + delta / 300.0f;
603  RNA_float_set(op->ptr, "factor", factor);
604  const bool use_cursor_init = RNA_boolean_get(op->ptr, "use_cursor_init");
605  sima_zoom_set(sima,
606  region,
607  sima->zoom * factor,
608  location,
609  (use_cursor_init && (U.uiflag & USER_ZOOM_TO_MOUSEPOS)));
610  ED_region_tag_redraw(region);
611 
612  return OPERATOR_FINISHED;
613  }
614 
615  image_view_zoom_init(C, op, event);
616  return OPERATOR_RUNNING_MODAL;
617 }
618 
620  wmOperator *op,
621  const int x,
622  const int y,
623  const short viewzoom,
624  const short zoom_invert,
625  const bool zoom_to_pos)
626 {
627  float factor;
628  float delta;
629 
630  if (viewzoom != USER_ZOOM_SCALE) {
631  if (U.uiflag & USER_ZOOM_HORIZ) {
632  delta = (float)(x - vpd->origx);
633  }
634  else {
635  delta = (float)(y - vpd->origy);
636  }
637  }
638  else {
639  delta = x - vpd->origx + y - vpd->origy;
640  }
641 
642  delta /= U.pixelsize;
643 
644  if (zoom_invert) {
645  delta = -delta;
646  }
647 
648  if (viewzoom == USER_ZOOM_CONTINUE) {
649  double time = PIL_check_seconds_timer();
650  float time_step = (float)(time - vpd->timer_lastdraw);
651  float zfac;
652  zfac = 1.0f + ((delta / 20.0f) * time_step);
653  vpd->timer_lastdraw = time;
654  /* this is the final zoom, but instead make it into a factor */
655  factor = (vpd->sima->zoom * zfac) / vpd->zoom;
656  }
657  else {
658  factor = 1.0f + delta / 300.0f;
659  }
660 
661  RNA_float_set(op->ptr, "factor", factor);
662  sima_zoom_set(vpd->sima, vpd->region, vpd->zoom * factor, vpd->location, zoom_to_pos);
664 }
665 
666 static int image_view_zoom_modal(bContext *C, wmOperator *op, const wmEvent *event)
667 {
668  ViewZoomData *vpd = op->customdata;
669  short event_code = VIEW_PASS;
670 
671  /* execute the events */
672  if (event->type == TIMER && event->customdata == vpd->timer) {
673  /* continuous zoom */
674  event_code = VIEW_APPLY;
675  }
676  else if (event->type == MOUSEMOVE) {
677  event_code = VIEW_APPLY;
678  }
679  else if (event->type == vpd->launch_event && event->val == KM_RELEASE) {
680  event_code = VIEW_CONFIRM;
681  }
682 
683  if (event_code == VIEW_APPLY) {
684  const bool use_cursor_init = RNA_boolean_get(op->ptr, "use_cursor_init");
685  image_zoom_apply(vpd,
686  op,
687  event->xy[0],
688  event->xy[1],
689  U.viewzoom,
690  (U.uiflag & USER_ZOOM_INVERT) != 0,
691  (use_cursor_init && (U.uiflag & USER_ZOOM_TO_MOUSEPOS)));
692  }
693  else if (event_code == VIEW_CONFIRM) {
694  image_view_zoom_exit(C, op, false);
695  return OPERATOR_FINISHED;
696  }
697 
698  return OPERATOR_RUNNING_MODAL;
699 }
700 
702 {
703  image_view_zoom_exit(C, op, true);
704 }
705 
707 {
708  PropertyRNA *prop;
709 
710  /* identifiers */
711  ot->name = "Zoom View";
712  ot->idname = "IMAGE_OT_view_zoom";
713  ot->description = "Zoom in/out the image";
714 
715  /* api callbacks */
721 
722  /* flags */
724 
725  /* properties */
726  prop = RNA_def_float(ot->srna,
727  "factor",
728  0.0f,
729  -FLT_MAX,
730  FLT_MAX,
731  "Factor",
732  "Zoom factor, values higher than 1.0 zoom in, lower values zoom out",
733  -FLT_MAX,
734  FLT_MAX);
736 
738 }
739 
742 #ifdef WITH_INPUT_NDOF
743 
744 /* -------------------------------------------------------------------- */
748 /* Combined pan/zoom from a 3D mouse device.
749  * Z zooms, XY pans
750  * "view" (not "paper") control -- user moves the viewpoint, not the image being viewed
751  * that explains the negative signs in the code below
752  */
753 
754 static int image_view_ndof_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
755 {
756  if (event->type != NDOF_MOTION) {
757  return OPERATOR_CANCELLED;
758  }
759 
761  ARegion *region = CTX_wm_region(C);
762  float pan_vec[3];
763 
764  const wmNDOFMotionData *ndof = event->customdata;
765  const float speed = NDOF_PIXELS_PER_SECOND;
766 
767  WM_event_ndof_pan_get(ndof, pan_vec, true);
768 
769  mul_v2_fl(pan_vec, (speed * ndof->dt) / sima->zoom);
770  pan_vec[2] *= -ndof->dt;
771 
772  sima_zoom_set_factor(sima, region, 1.0f + pan_vec[2], NULL, false);
773  sima->xof += pan_vec[0];
774  sima->yof += pan_vec[1];
775 
776  ED_region_tag_redraw(region);
777 
778  return OPERATOR_FINISHED;
779 }
780 
781 void IMAGE_OT_view_ndof(wmOperatorType *ot)
782 {
783  /* identifiers */
784  ot->name = "NDOF Pan/Zoom";
785  ot->idname = "IMAGE_OT_view_ndof";
786  ot->description = "Use a 3D mouse device to pan/zoom the view";
787 
788  /* api callbacks */
789  ot->invoke = image_view_ndof_invoke;
791 
792  /* flags */
794 }
795 
798 #endif /* WITH_INPUT_NDOF */
799 
800 /* -------------------------------------------------------------------- */
804 /* Updates the fields of the View2D member of the SpaceImage struct.
805  * Default behavior is to reset the position of the image and set the zoom to 1
806  * If the image will not fit within the window rectangle, the zoom is adjusted */
807 
809 {
810  SpaceImage *sima;
811  ARegion *region;
812 
813  /* retrieve state */
814  sima = CTX_wm_space_image(C);
815  region = CTX_wm_region(C);
816 
817  image_view_all(sima, region, op);
818 
819  ED_region_tag_redraw(region);
820 
821  return OPERATOR_FINISHED;
822 }
823 
825 {
826  PropertyRNA *prop;
827 
828  /* identifiers */
829  ot->name = "Frame All";
830  ot->idname = "IMAGE_OT_view_all";
831  ot->description = "View the entire image";
832 
833  /* api callbacks */
836 
837  /* flags */
839 
840  /* properties */
841  prop = RNA_def_boolean(ot->srna, "fit_view", 0, "Fit View", "Fit frame to the viewport");
843 }
844 
847 /* -------------------------------------------------------------------- */
852 {
853  SpaceImage *sima;
854  ARegion *region;
855 
856  sima = CTX_wm_space_image(C);
857  region = CTX_wm_region(C);
858 
859  image_view_all(sima, region, op);
860 
861  sima->cursor[0] = 0.5f;
862  sima->cursor[1] = 0.5f;
863 
864  /* Needed for updating the cursor. */
866 
867  return OPERATOR_FINISHED;
868 }
869 
871 {
872  PropertyRNA *prop;
873 
874  /* identifiers */
875  ot->name = "Cursor To Center View";
876  ot->description = "Set 2D Cursor To Center View location";
877  ot->idname = "IMAGE_OT_view_cursor_center";
878 
879  /* api callbacks */
882 
883  /* properties */
884  prop = RNA_def_boolean(ot->srna, "fit_view", 0, "Fit View", "Fit frame to the viewport");
886 }
887 
890 /* -------------------------------------------------------------------- */
895 {
897  ARegion *region = CTX_wm_region(C);
898 
899  ED_image_view_center_to_point(sima, sima->cursor[0], sima->cursor[1]);
900 
901  ED_region_tag_redraw(region);
902 
903  return OPERATOR_FINISHED;
904 }
905 
907 {
908  /* identifiers */
909  ot->name = "Center View to Cursor";
910  ot->description = "Center the view so that the cursor is in the middle of the view";
911  ot->idname = "IMAGE_OT_view_center_cursor";
912 
913  /* api callbacks */
916 }
917 
920 /* -------------------------------------------------------------------- */
925 {
926  SpaceImage *sima;
927  ARegion *region;
928  Scene *scene;
929  ViewLayer *view_layer;
930  Object *obedit;
931 
932  /* retrieve state */
933  sima = CTX_wm_space_image(C);
934  region = CTX_wm_region(C);
936  view_layer = CTX_data_view_layer(C);
937  obedit = CTX_data_edit_object(C);
938 
939  /* get bounds */
940  float min[2], max[2];
941  if (ED_space_image_show_uvedit(sima, obedit)) {
942  uint objects_len = 0;
944  view_layer, ((View3D *)NULL), &objects_len);
945  bool success = ED_uvedit_minmax_multi(scene, objects, objects_len, min, max);
946  MEM_freeN(objects);
947  if (!success) {
948  return OPERATOR_CANCELLED;
949  }
950  }
951  else if (ED_space_image_check_show_maskedit(sima, obedit)) {
952  if (!ED_mask_selected_minmax(C, min, max, false)) {
953  return OPERATOR_CANCELLED;
954  }
955  }
956  rctf bounds = {
957  .xmin = min[0],
958  .ymin = min[1],
959  .xmax = max[0],
960  .ymax = max[1],
961  };
962 
963  /* add some margin */
964  BLI_rctf_scale(&bounds, 1.4f);
965 
966  sima_zoom_set_from_bounds(sima, region, &bounds);
967 
968  ED_region_tag_redraw(region);
969 
970  return OPERATOR_FINISHED;
971 }
972 
974 {
976 }
977 
979 {
980  /* identifiers */
981  ot->name = "View Center";
982  ot->idname = "IMAGE_OT_view_selected";
983  ot->description = "View all selected UVs";
984 
985  /* api callbacks */
988 }
989 
992 /* -------------------------------------------------------------------- */
997 {
999  ARegion *region = CTX_wm_region(C);
1000  float location[2];
1001 
1002  RNA_float_get_array(op->ptr, "location", location);
1003 
1005  sima, region, powf(2.0f, 1.0f / 3.0f), location, U.uiflag & USER_ZOOM_TO_MOUSEPOS);
1006 
1007  ED_region_tag_redraw(region);
1008 
1009  return OPERATOR_FINISHED;
1010 }
1011 
1012 static int image_view_zoom_in_invoke(bContext *C, wmOperator *op, const wmEvent *event)
1013 {
1014  ARegion *region = CTX_wm_region(C);
1015  float location[2];
1016 
1018  &region->v2d, event->mval[0], event->mval[1], &location[0], &location[1]);
1019  RNA_float_set_array(op->ptr, "location", location);
1020 
1021  return image_view_zoom_in_exec(C, op);
1022 }
1023 
1025 {
1026  PropertyRNA *prop;
1027 
1028  /* identifiers */
1029  ot->name = "Zoom In";
1030  ot->idname = "IMAGE_OT_view_zoom_in";
1031  ot->description = "Zoom in the image (centered around 2D cursor)";
1032 
1033  /* api callbacks */
1037 
1038  /* flags */
1040 
1041  /* properties */
1042  prop = RNA_def_float_vector(ot->srna,
1043  "location",
1044  2,
1045  NULL,
1046  -FLT_MAX,
1047  FLT_MAX,
1048  "Location",
1049  "Cursor location in screen coordinates",
1050  -10.0f,
1051  10.0f);
1053 }
1054 
1056 {
1057  SpaceImage *sima = CTX_wm_space_image(C);
1058  ARegion *region = CTX_wm_region(C);
1059  float location[2];
1060 
1061  RNA_float_get_array(op->ptr, "location", location);
1062 
1064  sima, region, powf(0.5f, 1.0f / 3.0f), location, U.uiflag & USER_ZOOM_TO_MOUSEPOS);
1065 
1066  ED_region_tag_redraw(region);
1067 
1068  return OPERATOR_FINISHED;
1069 }
1070 
1071 static int image_view_zoom_out_invoke(bContext *C, wmOperator *op, const wmEvent *event)
1072 {
1073  ARegion *region = CTX_wm_region(C);
1074  float location[2];
1075 
1077  &region->v2d, event->mval[0], event->mval[1], &location[0], &location[1]);
1078  RNA_float_set_array(op->ptr, "location", location);
1079 
1080  return image_view_zoom_out_exec(C, op);
1081 }
1082 
1084 {
1085  PropertyRNA *prop;
1086 
1087  /* identifiers */
1088  ot->name = "Zoom Out";
1089  ot->idname = "IMAGE_OT_view_zoom_out";
1090  ot->description = "Zoom out the image (centered around 2D cursor)";
1091 
1092  /* api callbacks */
1096 
1097  /* flags */
1099 
1100  /* properties */
1101  prop = RNA_def_float_vector(ot->srna,
1102  "location",
1103  2,
1104  NULL,
1105  -FLT_MAX,
1106  FLT_MAX,
1107  "Location",
1108  "Cursor location in screen coordinates",
1109  -10.0f,
1110  10.0f);
1112 }
1113 
1116 /* -------------------------------------------------------------------- */
1121 {
1122  SpaceImage *sima = CTX_wm_space_image(C);
1123  ARegion *region = CTX_wm_region(C);
1124 
1125  sima_zoom_set(sima, region, RNA_float_get(op->ptr, "ratio"), NULL, false);
1126 
1127  /* ensure pixel exact locations for draw */
1128  sima->xof = (int)sima->xof;
1129  sima->yof = (int)sima->yof;
1130 
1131  ED_region_tag_redraw(region);
1132 
1133  return OPERATOR_FINISHED;
1134 }
1135 
1137 {
1138  /* identifiers */
1139  ot->name = "View Zoom Ratio";
1140  ot->idname = "IMAGE_OT_view_zoom_ratio";
1141  ot->description = "Set zoom ratio of the view";
1142 
1143  /* api callbacks */
1146 
1147  /* flags */
1149 
1150  /* properties */
1152  "ratio",
1153  0.0f,
1154  -FLT_MAX,
1155  FLT_MAX,
1156  "Ratio",
1157  "Zoom ratio, 1.0 is 1:1, higher is zoomed in, lower is zoomed out",
1158  -FLT_MAX,
1159  FLT_MAX);
1160 }
1161 
1164 /* -------------------------------------------------------------------- */
1169 {
1170  SpaceImage *sima = CTX_wm_space_image(C);
1171  ARegion *region = CTX_wm_region(C);
1172  rctf bounds;
1173  const bool zoom_in = !RNA_boolean_get(op->ptr, "zoom_out");
1174 
1176 
1178 
1179  const struct {
1180  float xof;
1181  float yof;
1182  float zoom;
1183  } sima_view_prev = {
1184  .xof = sima->xof,
1185  .yof = sima->yof,
1186  .zoom = sima->zoom,
1187  };
1188 
1189  sima_zoom_set_from_bounds(sima, region, &bounds);
1190 
1191  /* zoom out */
1192  if (!zoom_in) {
1193  sima->xof = sima_view_prev.xof + (sima->xof - sima_view_prev.xof);
1194  sima->yof = sima_view_prev.yof + (sima->yof - sima_view_prev.yof);
1195  sima->zoom = sima_view_prev.zoom * (sima_view_prev.zoom / sima->zoom);
1196  }
1197 
1198  ED_region_tag_redraw(region);
1199 
1200  return OPERATOR_FINISHED;
1201 }
1202 
1204 {
1205  /* identifiers */
1206  ot->name = "Zoom to Border";
1207  ot->description = "Zoom in the view to the nearest item contained in the border";
1208  ot->idname = "IMAGE_OT_view_zoom_border";
1209 
1210  /* api callbacks */
1215 
1217 
1218  /* rna */
1220 }
1221 
1222 /* load/replace/save callbacks */
1223 static void image_filesel(bContext *C, wmOperator *op, const char *path)
1224 {
1225  RNA_string_set(op->ptr, "filepath", path);
1227 }
1228 
1231 /* -------------------------------------------------------------------- */
1235 typedef struct ImageOpenData {
1240 
1242 {
1243  ImageOpenData *iod;
1244  op->customdata = iod = MEM_callocN(sizeof(ImageOpenData), __func__);
1245  iod->iuser = CTX_data_pointer_get_type(C, "image_user", &RNA_ImageUser).data;
1247 }
1248 
1250 {
1251  MEM_freeN(op->customdata);
1252  op->customdata = NULL;
1253 }
1254 
1256  wmOperator *op,
1257  ImageFrameRange *range,
1258  const char *relbase,
1259  bool is_relative_path,
1260  bool use_multiview)
1261 {
1262  bool exists = false;
1263  Image *ima = NULL;
1264 
1265  errno = 0;
1266  ima = BKE_image_load_exists_ex(bmain, range->filepath, &exists);
1267 
1268  if (!ima) {
1269  if (op->customdata) {
1270  MEM_freeN(op->customdata);
1271  }
1272  BKE_reportf(op->reports,
1273  RPT_ERROR,
1274  "Cannot read '%s': %s",
1275  range->filepath,
1276  errno ? strerror(errno) : TIP_("unsupported image format"));
1277  return NULL;
1278  }
1279 
1280  if (!exists) {
1281  /* only image path after save, never ibuf */
1282  if (is_relative_path) {
1283  BLI_path_rel(ima->filepath, relbase);
1284  }
1285 
1286  /* handle multiview images */
1287  if (use_multiview) {
1288  ImageOpenData *iod = op->customdata;
1289  ImageFormatData *imf = &iod->im_format;
1290 
1291  ima->flag |= IMA_USE_VIEWS;
1292  ima->views_format = imf->views_format;
1293  *ima->stereo3d_format = imf->stereo3d_format;
1294  }
1295  else {
1296  ima->flag &= ~IMA_USE_VIEWS;
1297  BKE_image_free_views(ima);
1298  }
1299 
1300  if (ima->source == IMA_SRC_FILE) {
1301  if (range->udims_detected && range->udim_tiles.first) {
1302  ima->source = IMA_SRC_TILED;
1303  ImageTile *first_tile = ima->tiles.first;
1304  first_tile->tile_number = range->offset;
1305  LISTBASE_FOREACH (LinkData *, node, &range->udim_tiles) {
1307  }
1308  }
1309  else if (range->length > 1) {
1310  ima->source = IMA_SRC_SEQUENCE;
1311  }
1312  }
1313  }
1314 
1315  return ima;
1316 }
1317 
1319 {
1320  Main *bmain = CTX_data_main(C);
1321  ScrArea *area = CTX_wm_area(C);
1323  ImageUser *iuser = NULL;
1324  Image *ima = NULL;
1325  int frame_seq_len = 0;
1326  int frame_ofs = 1;
1327 
1328  const bool is_relative_path = RNA_boolean_get(op->ptr, "relative_path");
1329  const bool use_multiview = RNA_boolean_get(op->ptr, "use_multiview");
1330  const bool use_udim = RNA_boolean_get(op->ptr, "use_udim_detecting");
1331 
1332  if (!op->customdata) {
1333  image_open_init(C, op);
1334  }
1335 
1336  ListBase ranges = ED_image_filesel_detect_sequences(bmain, op, use_udim);
1337  LISTBASE_FOREACH (ImageFrameRange *, range, &ranges) {
1338  Image *ima_range = image_open_single(
1339  bmain, op, range, BKE_main_blendfile_path(bmain), is_relative_path, use_multiview);
1340 
1341  /* take the first image */
1342  if ((ima == NULL) && ima_range) {
1343  ima = ima_range;
1344  frame_seq_len = range->length;
1345  frame_ofs = range->offset;
1346  }
1347 
1348  BLI_freelistN(&range->udim_tiles);
1349  }
1350  BLI_freelistN(&ranges);
1351 
1352  if (ima == NULL) {
1353  return OPERATOR_CANCELLED;
1354  }
1355 
1356  /* hook into UI */
1357  ImageOpenData *iod = op->customdata;
1358 
1359  if (iod->pprop.prop) {
1360  /* when creating new ID blocks, use is already 1, but RNA
1361  * pointer use also increases user, so this compensates it */
1362  id_us_min(&ima->id);
1363 
1364  PointerRNA imaptr;
1365  RNA_id_pointer_create(&ima->id, &imaptr);
1366  RNA_property_pointer_set(&iod->pprop.ptr, iod->pprop.prop, imaptr, NULL);
1367  RNA_property_update(C, &iod->pprop.ptr, iod->pprop.prop);
1368  }
1369 
1370  if (iod->iuser) {
1371  iuser = iod->iuser;
1372  }
1373  else if (area && area->spacetype == SPACE_IMAGE) {
1374  SpaceImage *sima = area->spacedata.first;
1375  ED_space_image_set(bmain, sima, ima, false);
1376  iuser = &sima->iuser;
1377  }
1378  else {
1379  Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
1380  if (tex && tex->type == TEX_IMAGE) {
1381  iuser = &tex->iuser;
1382  }
1383 
1384  if (iuser == NULL) {
1385  Camera *cam = CTX_data_pointer_get_type(C, "camera", &RNA_Camera).data;
1386  if (cam) {
1387  LISTBASE_FOREACH (CameraBGImage *, bgpic, &cam->bg_images) {
1388  if (bgpic->ima == ima) {
1389  iuser = &bgpic->iuser;
1390  break;
1391  }
1392  }
1393  }
1394  }
1395  }
1396 
1397  /* initialize because of new image */
1398  if (iuser) {
1399  /* If the sequence was a tiled image, we only have one frame. */
1400  iuser->frames = (ima->source == IMA_SRC_SEQUENCE) ? frame_seq_len : 1;
1401  iuser->sfra = 1;
1402  iuser->framenr = 1;
1403  if (ima->source == IMA_SRC_MOVIE) {
1404  iuser->offset = 0;
1405  }
1406  else {
1407  iuser->offset = frame_ofs - 1;
1408  }
1409  iuser->scene = scene;
1410  BKE_image_init_imageuser(ima, iuser);
1411  }
1412 
1413  /* XXX BKE_packedfile_unpack_image frees image buffers */
1415 
1416  BKE_image_signal(bmain, ima, iuser, IMA_SIGNAL_RELOAD);
1418 
1419  MEM_freeN(op->customdata);
1420 
1421  return OPERATOR_FINISHED;
1422 }
1423 
1424 static int image_open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
1425 {
1426  SpaceImage *sima = CTX_wm_space_image(C); /* XXX other space types can call */
1427  const char *path = U.textudir;
1428  Image *ima = NULL;
1430 
1431  if (sima) {
1432  ima = sima->image;
1433  }
1434 
1435  if (ima == NULL) {
1436  Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
1437  if (tex && tex->type == TEX_IMAGE) {
1438  ima = tex->ima;
1439  }
1440  }
1441 
1442  if (ima == NULL) {
1443  PointerRNA ptr;
1444  PropertyRNA *prop;
1445 
1446  /* hook into UI */
1448 
1449  if (prop) {
1450  PointerRNA oldptr;
1451  Image *oldima;
1452 
1453  oldptr = RNA_property_pointer_get(&ptr, prop);
1454  oldima = (Image *)oldptr.owner_id;
1455  /* unlikely to fail but better avoid strange crash */
1456  if (oldima && GS(oldima->id.name) == ID_IM) {
1457  ima = oldima;
1458  }
1459  }
1460  }
1461 
1462  if (ima) {
1463  path = ima->filepath;
1464  }
1465 
1466  if (RNA_struct_property_is_set(op->ptr, "filepath")) {
1467  return image_open_exec(C, op);
1468  }
1469 
1470  image_open_init(C, op);
1471 
1472  /* Show multi-view save options only if scene has multi-views. */
1473  PropertyRNA *prop;
1474  prop = RNA_struct_find_property(op->ptr, "show_multiview");
1475  RNA_property_boolean_set(op->ptr, prop, (scene->r.scemode & R_MULTIVIEW) != 0);
1476 
1477  image_filesel(C, op, path);
1478 
1479  return OPERATOR_RUNNING_MODAL;
1480 }
1481 
1483  PropertyRNA *prop,
1484  void *UNUSED(user_data))
1485 {
1486  const char *prop_id = RNA_property_identifier(prop);
1487 
1488  return !(STR_ELEM(prop_id, "filepath", "directory", "filename"));
1489 }
1490 
1492 {
1493  uiLayout *layout = op->layout;
1494  ImageOpenData *iod = op->customdata;
1495  ImageFormatData *imf = &iod->im_format;
1496  PointerRNA imf_ptr;
1497 
1498  /* main draw call */
1501 
1502  /* image template */
1503  RNA_pointer_create(NULL, &RNA_ImageFormatSettings, imf, &imf_ptr);
1504 
1505  /* multiview template */
1506  if (RNA_boolean_get(op->ptr, "show_multiview")) {
1507  uiTemplateImageFormatViews(layout, &imf_ptr, op->ptr);
1508  }
1509 }
1510 
1512 {
1513  PropertyRNA *prop = RNA_def_boolean(
1514  ot->srna, "allow_path_tokens", true, "", "Allow the path to contain substitution tokens");
1516 }
1517 
1519 {
1520  /* identifiers */
1521  ot->name = "Open Image";
1522  ot->description = "Open image";
1523  ot->idname = "IMAGE_OT_open";
1524 
1525  /* api callbacks */
1526  ot->exec = image_open_exec;
1529  ot->ui = image_open_draw;
1530 
1531  /* flags */
1533 
1534  /* properties */
1538  FILE_SPECIAL,
1539  FILE_OPENFILE,
1544 
1546  ot->srna,
1547  "use_sequence_detection",
1548  true,
1549  "Detect Sequences",
1550  "Automatically detect animated sequences in selected images (based on file names)");
1552  "use_udim_detecting",
1553  true,
1554  "Detect UDIMs",
1555  "Detect selected UDIM files and load all matching tiles");
1556 }
1557 
1560 /* -------------------------------------------------------------------- */
1565 {
1566  Image *ima = op->customdata;
1567  if (ima == NULL) {
1568  return OPERATOR_CANCELLED;
1569  }
1570 
1571  char filepath[FILE_MAX];
1572  RNA_string_get(op->ptr, "filepath", filepath);
1573 
1574  /* If loading into a tiled texture, ensure that the filename is tokenized. */
1575  if (ima->source == IMA_SRC_TILED) {
1576  char *filename = (char *)BLI_path_basename(filepath);
1577  BKE_image_ensure_tile_token(filename);
1578  }
1579 
1580  PointerRNA imaptr;
1581  PropertyRNA *imaprop;
1582  RNA_id_pointer_create(&ima->id, &imaptr);
1583  imaprop = RNA_struct_find_property(&imaptr, "filepath");
1584 
1585  RNA_property_string_set(&imaptr, imaprop, filepath);
1586  RNA_property_update(C, &imaptr, imaprop);
1587 
1588  return OPERATOR_FINISHED;
1589 }
1590 
1591 static int image_file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event)
1592 {
1593  Image *ima = image_from_context(C);
1594  if (!ima) {
1595  return OPERATOR_CANCELLED;
1596  }
1597 
1598  char filepath[FILE_MAX];
1599  BLI_strncpy(filepath, ima->filepath, sizeof(filepath));
1600 
1601  /* Shift+Click to open the file, Alt+Click to browse a folder in the OS's browser. */
1602  if (event->modifier & (KM_SHIFT | KM_ALT)) {
1603  wmOperatorType *ot = WM_operatortype_find("WM_OT_path_open", true);
1604  PointerRNA props_ptr;
1605 
1606  if (event->modifier & KM_ALT) {
1607  char *lslash = (char *)BLI_path_slash_rfind(filepath);
1608  if (lslash) {
1609  *lslash = '\0';
1610  }
1611  }
1612  else if (ima->source == IMA_SRC_TILED) {
1614  BKE_image_user_file_path(&iuser, ima, filepath);
1615  }
1616 
1618  RNA_string_set(&props_ptr, "filepath", filepath);
1620  WM_operator_properties_free(&props_ptr);
1621 
1622  return OPERATOR_CANCELLED;
1623  }
1624 
1625  /* The image is typically passed to the operator via layout/button context (e.g.
1626  * #uiLayoutSetContextPointer()). The File Browser doesn't support restoring this context
1627  * when calling `exec()` though, so we have to pass it the image via custom data. */
1628  op->customdata = ima;
1629 
1630  image_filesel(C, op, filepath);
1631 
1632  return OPERATOR_RUNNING_MODAL;
1633 }
1634 
1636 {
1637  return image_from_context(C) != NULL;
1638 }
1639 
1641 {
1642  /* identifiers */
1643  ot->name = "Browse Image";
1644  ot->description =
1645  "Open an image file browser, hold Shift to open the file, Alt to browse containing "
1646  "directory";
1647  ot->idname = "IMAGE_OT_file_browse";
1648 
1649  /* api callbacks */
1653 
1654  /* flags */
1655  ot->flag = OPTYPE_UNDO;
1656 
1657  /* properties */
1660  FILE_SPECIAL,
1661  FILE_OPENFILE,
1665 }
1666 
1669 /* -------------------------------------------------------------------- */
1674 {
1676  Image *ima = image_from_context(C);
1678 
1679  if (!ima || !iuser) {
1680  /* Try to get a Texture, or a SpaceImage from context... */
1681  Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
1682  if (tex && tex->type == TEX_IMAGE) {
1683  ima = tex->ima;
1684  iuser = &tex->iuser;
1685  }
1686  }
1687 
1688  if (!ima || !iuser || !BKE_image_has_anim(ima)) {
1689  return OPERATOR_CANCELLED;
1690  }
1691 
1692  struct anim *anim = ((ImageAnim *)ima->anims.first)->anim;
1693  if (!anim) {
1694  return OPERATOR_CANCELLED;
1695  }
1697  BKE_image_user_frame_calc(ima, iuser, scene->r.cfra);
1698 
1699  return OPERATOR_FINISHED;
1700 }
1701 
1703 {
1704  /* identifiers */
1705  ot->name = "Match Movie Length";
1706  ot->description = "Set image's user's length to the one of this video";
1707  ot->idname = "IMAGE_OT_match_movie_length";
1708 
1709  /* api callbacks */
1711 
1712  /* flags */
1713  /* Don't think we need undo for that. */
1714  ot->flag = OPTYPE_REGISTER | OPTYPE_INTERNAL /* | OPTYPE_UNDO */;
1715 }
1716 
1719 /* -------------------------------------------------------------------- */
1724 {
1725  Main *bmain = CTX_data_main(C);
1726  SpaceImage *sima = CTX_wm_space_image(C);
1727  char str[FILE_MAX];
1728 
1729  if (!sima->image) {
1730  return OPERATOR_CANCELLED;
1731  }
1732 
1733  RNA_string_get(op->ptr, "filepath", str);
1734 
1735  /* we can't do much if the str is longer than FILE_MAX :/ */
1736  BLI_strncpy(sima->image->filepath, str, sizeof(sima->image->filepath));
1737 
1738  if (sima->image->source == IMA_SRC_GENERATED) {
1739  sima->image->source = IMA_SRC_FILE;
1740  BKE_image_signal(bmain, sima->image, &sima->iuser, IMA_SIGNAL_SRC_CHANGE);
1741  }
1742 
1744  sima->image->source = IMA_SRC_MOVIE;
1745  }
1746  else {
1747  sima->image->source = IMA_SRC_FILE;
1748  }
1749 
1750  /* XXX BKE_packedfile_unpack_image frees image buffers */
1752 
1754  BKE_image_signal(bmain, sima->image, &sima->iuser, IMA_SIGNAL_RELOAD);
1756 
1757  return OPERATOR_FINISHED;
1758 }
1759 
1760 static int image_replace_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
1761 {
1762  SpaceImage *sima = CTX_wm_space_image(C);
1763 
1764  if (!sima->image) {
1765  return OPERATOR_CANCELLED;
1766  }
1767 
1768  if (RNA_struct_property_is_set(op->ptr, "filepath")) {
1769  return image_replace_exec(C, op);
1770  }
1771 
1772  if (!RNA_struct_property_is_set(op->ptr, "relative_path")) {
1773  RNA_boolean_set(op->ptr, "relative_path", BLI_path_is_rel(sima->image->filepath));
1774  }
1775 
1776  image_filesel(C, op, sima->image->filepath);
1777 
1778  return OPERATOR_RUNNING_MODAL;
1779 }
1780 
1782 {
1783  /* identifiers */
1784  ot->name = "Replace Image";
1785  ot->idname = "IMAGE_OT_replace";
1786  ot->description = "Replace current image by another one from disk";
1787 
1788  /* api callbacks */
1792 
1793  /* flags */
1795 
1796  /* properties */
1799  FILE_SPECIAL,
1800  FILE_OPENFILE,
1804 }
1805 
1808 /* -------------------------------------------------------------------- */
1812 typedef struct ImageSaveData {
1817 
1819 {
1820  if (RNA_struct_property_is_set(op->ptr, "filepath")) {
1821  RNA_string_get(op->ptr, "filepath", opts->filepath);
1823  }
1824 
1825  opts->relative = (RNA_struct_find_property(op->ptr, "relative_path") &&
1826  RNA_boolean_get(op->ptr, "relative_path"));
1827  opts->save_copy = (RNA_struct_find_property(op->ptr, "copy") &&
1828  RNA_boolean_get(op->ptr, "copy"));
1829  opts->save_as_render = (RNA_struct_find_property(op->ptr, "save_as_render") &&
1830  RNA_boolean_get(op->ptr, "save_as_render"));
1831 }
1832 
1833 static bool save_image_op(
1834  Main *bmain, Image *ima, ImageUser *iuser, wmOperator *op, const ImageSaveOptions *opts)
1835 {
1836  WM_cursor_wait(true);
1837 
1838  bool ok = BKE_image_save(op->reports, bmain, ima, iuser, opts);
1839 
1840  WM_cursor_wait(false);
1841 
1842  /* Remember file path for next save. */
1843  BLI_strncpy(G.ima, opts->filepath, sizeof(G.ima));
1844 
1846 
1847  return ok;
1848 }
1849 
1851 {
1852  Main *bmain = CTX_data_main(C);
1856 
1857  ImageSaveData *isd = MEM_callocN(sizeof(*isd), __func__);
1858  isd->image = image;
1859  isd->iuser = iuser;
1860 
1861  if (!BKE_image_save_options_init(&isd->opts, bmain, scene, image, iuser, true, false)) {
1863  MEM_freeN(isd);
1864  return NULL;
1865  }
1866 
1867  isd->opts.do_newpath = true;
1868 
1869  if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
1870  RNA_string_set(op->ptr, "filepath", isd->opts.filepath);
1871  }
1872 
1873  /* Enable save_copy by default for render results. */
1875  !RNA_struct_property_is_set(op->ptr, "copy")) {
1876  RNA_boolean_set(op->ptr, "copy", true);
1877  }
1878 
1879  if (!RNA_struct_property_is_set(op->ptr, "save_as_render")) {
1880  RNA_boolean_set(op->ptr, "save_as_render", isd->opts.save_as_render);
1881  }
1882 
1883  /* Show multiview save options only if image has multiviews. */
1884  PropertyRNA *prop;
1885  prop = RNA_struct_find_property(op->ptr, "show_multiview");
1887  prop = RNA_struct_find_property(op->ptr, "use_multiview");
1889 
1890  op->customdata = isd;
1891 
1892  return isd;
1893 }
1894 
1896 {
1897  if (op->customdata) {
1898  ImageSaveData *isd = op->customdata;
1900 
1901  MEM_freeN(op->customdata);
1902  op->customdata = NULL;
1903  }
1904 }
1905 
1907 {
1908  Main *bmain = CTX_data_main(C);
1909  ImageSaveData *isd;
1910 
1911  if (op->customdata) {
1912  isd = op->customdata;
1913  }
1914  else {
1915  isd = image_save_as_init(C, op);
1916  if (isd == NULL) {
1917  return OPERATOR_CANCELLED;
1918  }
1919  }
1920 
1921  image_save_options_from_op(bmain, &isd->opts, op);
1923 
1924  save_image_op(bmain, isd->image, isd->iuser, op, &isd->opts);
1925 
1926  if (isd->opts.save_copy == false) {
1928  }
1929 
1930  image_save_as_free(op);
1931 
1932  return OPERATOR_FINISHED;
1933 }
1934 
1936 {
1937  Main *bmain = CTX_data_main(C);
1938  ImageSaveData *isd = op->customdata;
1939 
1940  image_save_options_from_op(bmain, &isd->opts, op);
1942 
1944 }
1945 
1946 static int image_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
1947 {
1948  if (RNA_struct_property_is_set(op->ptr, "filepath")) {
1949  return image_save_as_exec(C, op);
1950  }
1951 
1952  ImageSaveData *isd = image_save_as_init(C, op);
1953  if (isd == NULL) {
1954  return OPERATOR_CANCELLED;
1955  }
1956 
1957  image_filesel(C, op, isd->opts.filepath);
1958 
1959  return OPERATOR_RUNNING_MODAL;
1960 }
1961 
1963 {
1964  image_save_as_free(op);
1965 }
1966 
1968  PropertyRNA *prop,
1969  void *UNUSED(user_data))
1970 {
1971  const char *prop_id = RNA_property_identifier(prop);
1972 
1973  return !(STREQ(prop_id, "filepath") || STREQ(prop_id, "directory") ||
1974  STREQ(prop_id, "filename") ||
1975  /* when saving a copy, relative path has no effect */
1976  (STREQ(prop_id, "relative_path") && RNA_boolean_get(ptr, "copy")));
1977 }
1978 
1980 {
1981  uiLayout *layout = op->layout;
1982  ImageSaveData *isd = op->customdata;
1983  PointerRNA imf_ptr;
1984  const bool is_multiview = RNA_boolean_get(op->ptr, "show_multiview");
1985  const bool save_as_render = RNA_boolean_get(op->ptr, "save_as_render");
1986 
1987  uiLayoutSetPropSep(layout, true);
1988  uiLayoutSetPropDecorate(layout, false);
1989 
1990  /* main draw call */
1993 
1994  uiItemS(layout);
1995 
1996  /* image template */
1997  RNA_pointer_create(NULL, &RNA_ImageFormatSettings, &isd->opts.im_format, &imf_ptr);
1998  uiTemplateImageSettings(layout, &imf_ptr, save_as_render);
1999 
2000  if (!save_as_render) {
2001  PointerRNA linear_settings_ptr = RNA_pointer_get(&imf_ptr, "linear_colorspace_settings");
2002  uiLayout *col = uiLayoutColumn(layout, true);
2003  uiItemS(col);
2004  uiItemR(col, &linear_settings_ptr, "name", 0, IFACE_("Color Space"), ICON_NONE);
2005  }
2006 
2007  /* multiview template */
2008  if (is_multiview) {
2009  uiTemplateImageFormatViews(layout, &imf_ptr, op->ptr);
2010  }
2011 }
2012 
2014 {
2016  return false;
2017  }
2018 
2019  if (G.is_rendering) {
2020  /* no need to NULL check here */
2021  Image *ima = image_from_context(C);
2022 
2023  if (ima->source == IMA_SRC_VIEWER) {
2024  CTX_wm_operator_poll_msg_set(C, "can't save image while rendering");
2025  return false;
2026  }
2027  }
2028 
2029  return true;
2030 }
2031 
2033 {
2034  /* identifiers */
2035  ot->name = "Save As Image";
2036  ot->idname = "IMAGE_OT_save_as";
2037  ot->description = "Save the image with another name and/or settings";
2038 
2039  /* api callbacks */
2046 
2047  /* flags */
2049 
2050  /* properties */
2051  PropertyRNA *prop;
2052  prop = RNA_def_boolean(ot->srna,
2053  "save_as_render",
2054  0,
2055  "Save As Render",
2056  "Apply render part of display transform when saving byte image");
2058  prop = RNA_def_boolean(ot->srna,
2059  "copy",
2060  0,
2061  "Copy",
2062  "Create a new image file without modifying the current image in blender");
2064 
2068  FILE_SPECIAL,
2069  FILE_SAVE,
2073 }
2074 
2077 /* -------------------------------------------------------------------- */
2084 static bool image_file_format_writable(Image *ima, ImageUser *iuser)
2085 {
2086  void *lock;
2087  ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock);
2088  bool ret = false;
2089 
2090  if (ibuf && BKE_image_buffer_format_writable(ibuf)) {
2091  ret = true;
2092  }
2093 
2094  BKE_image_release_ibuf(ima, ibuf, lock);
2095  return ret;
2096 }
2097 
2099 {
2100  /* Can't save if there are no pixels. */
2101  if (image_from_context_has_data_poll(C) == false) {
2102  return false;
2103  }
2104 
2105  /* Check if there is a valid file path and image format we can write
2106  * outside of the 'poll' so we can show a report with a pop-up. */
2107 
2108  /* Can always repack images.
2109  * Images without a filepath will go to "Save As". */
2110  return true;
2111 }
2112 
2114 {
2115  Main *bmain = CTX_data_main(C);
2119  ImageSaveOptions opts;
2120  bool ok = false;
2121 
2123  /* Save packed files to memory. */
2125  /* Report since this can be called from key shortcuts. */
2126  BKE_reportf(op->reports, RPT_INFO, "Packed to memory image \"%s\"", image->filepath);
2127  return OPERATOR_FINISHED;
2128  }
2129 
2130  if (!BKE_image_save_options_init(&opts, bmain, scene, image, iuser, false, false)) {
2132  return OPERATOR_CANCELLED;
2133  }
2134  image_save_options_from_op(bmain, &opts, op);
2135 
2136  /* Check if file write permission is ok. */
2137  if (BLI_exists(opts.filepath) && !BLI_file_is_writable(opts.filepath)) {
2138  BKE_reportf(
2139  op->reports, RPT_ERROR, "Cannot save image, path \"%s\" is not writable", opts.filepath);
2140  }
2141  else if (save_image_op(bmain, image, iuser, op, &opts)) {
2142  /* Report since this can be called from key shortcuts. */
2143  BKE_reportf(op->reports, RPT_INFO, "Saved image \"%s\"", opts.filepath);
2144  ok = true;
2145  }
2146 
2148 
2149  if (ok) {
2150  return OPERATOR_FINISHED;
2151  }
2152 
2153  return OPERATOR_CANCELLED;
2154 }
2155 
2156 static int image_save_invoke(bContext *C, wmOperator *op, const wmEvent *event)
2157 {
2158  Image *ima = image_from_context(C);
2160 
2161  /* Not writable formats or images without a file-path will go to "Save As". */
2162  if (!BKE_image_has_packedfile(ima) &&
2163  (!BKE_image_has_filepath(ima) || !image_file_format_writable(ima, iuser))) {
2164  WM_operator_name_call(C, "IMAGE_OT_save_as", WM_OP_INVOKE_DEFAULT, NULL, event);
2165  return OPERATOR_CANCELLED;
2166  }
2167  return image_save_exec(C, op);
2168 }
2169 
2171 {
2172  /* identifiers */
2173  ot->name = "Save Image";
2174  ot->idname = "IMAGE_OT_save";
2175  ot->description = "Save the image with current name and settings";
2176 
2177  /* api callbacks */
2178  ot->exec = image_save_exec;
2180  ot->poll = image_save_poll;
2181 
2182  /* flags */
2184 }
2185 
2188 /* -------------------------------------------------------------------- */
2193 {
2194  Main *bmain = CTX_data_main(C);
2196  ImBuf *ibuf, *first_ibuf = NULL;
2197  int tot = 0;
2198  char di[FILE_MAX];
2199  struct MovieCacheIter *iter;
2200 
2201  if (image == NULL) {
2202  return OPERATOR_CANCELLED;
2203  }
2204 
2205  if (image->source != IMA_SRC_SEQUENCE) {
2206  BKE_report(op->reports, RPT_ERROR, "Can only save sequence on image sequences");
2207  return OPERATOR_CANCELLED;
2208  }
2209 
2210  if (image->type == IMA_TYPE_MULTILAYER) {
2211  BKE_report(op->reports, RPT_ERROR, "Cannot save multilayer sequences");
2212  return OPERATOR_CANCELLED;
2213  }
2214 
2215  /* get total dirty buffers and first dirty buffer which is used for menu */
2216  ibuf = NULL;
2217  if (image->cache != NULL) {
2218  iter = IMB_moviecacheIter_new(image->cache);
2219  while (!IMB_moviecacheIter_done(iter)) {
2220  ibuf = IMB_moviecacheIter_getImBuf(iter);
2221  if (ibuf != NULL && ibuf->userflags & IB_BITMAPDIRTY) {
2222  if (first_ibuf == NULL) {
2223  first_ibuf = ibuf;
2224  }
2225  tot++;
2226  }
2228  }
2230  }
2231 
2232  if (tot == 0) {
2233  BKE_report(op->reports, RPT_WARNING, "No images have been changed");
2234  return OPERATOR_CANCELLED;
2235  }
2236 
2237  /* get a filename for menu */
2238  BLI_split_dir_part(first_ibuf->name, di, sizeof(di));
2239  BKE_reportf(op->reports, RPT_INFO, "%d image(s) will be saved in %s", tot, di);
2240 
2241  iter = IMB_moviecacheIter_new(image->cache);
2242  while (!IMB_moviecacheIter_done(iter)) {
2243  ibuf = IMB_moviecacheIter_getImBuf(iter);
2244 
2245  if (ibuf != NULL && ibuf->userflags & IB_BITMAPDIRTY) {
2246  char name[FILE_MAX];
2247  BLI_strncpy(name, ibuf->name, sizeof(name));
2248 
2249  BLI_path_abs(name, BKE_main_blendfile_path(bmain));
2250 
2251  if (0 == IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat)) {
2252  BKE_reportf(op->reports, RPT_ERROR, "Could not write image: %s", strerror(errno));
2253  break;
2254  }
2255 
2256  BKE_reportf(op->reports, RPT_INFO, "Saved %s", ibuf->name);
2257  ibuf->userflags &= ~IB_BITMAPDIRTY;
2258  }
2259 
2261  }
2263 
2264  return OPERATOR_FINISHED;
2265 }
2266 
2268 {
2269  /* identifiers */
2270  ot->name = "Save Sequence";
2271  ot->idname = "IMAGE_OT_save_sequence";
2272  ot->description = "Save a sequence of images";
2273 
2274  /* api callbacks */
2277 
2278  /* flags */
2280 }
2281 
2284 /* -------------------------------------------------------------------- */
2289 {
2291 }
2292 
2293 static bool image_should_be_saved(Image *ima, bool *is_format_writable)
2294 {
2295  if (BKE_image_is_dirty_writable(ima, is_format_writable) &&
2298  }
2299  return false;
2300 }
2301 
2302 static bool image_has_valid_path(Image *ima)
2303 {
2304  return strchr(ima->filepath, '\\') || strchr(ima->filepath, '/');
2305 }
2306 
2308 {
2309  /* Images without a filepath (implied with IMA_SRC_GENERATED) should
2310  * be packed during a save_all operation. */
2311  return (ima->source == IMA_SRC_GENERATED) ||
2312  (ima->source == IMA_SRC_TILED && !BKE_image_has_filepath(ima));
2313 }
2314 
2316 {
2317  ReportList reports;
2318  BKE_reports_init(&reports, RPT_STORE);
2319 
2320  uint modified_images_count = ED_image_save_all_modified_info(bmain, &reports);
2321  bool should_save = modified_images_count || !BLI_listbase_is_empty(&reports.list);
2322 
2323  BKE_reports_clear(&reports);
2324 
2325  return should_save;
2326 }
2327 
2329 {
2330  GSet *unique_paths = BLI_gset_str_new(__func__);
2331 
2332  int num_saveable_images = 0;
2333 
2334  for (Image *ima = bmain->images.first; ima; ima = ima->id.next) {
2335  bool is_format_writable;
2336 
2337  if (image_should_be_saved(ima, &is_format_writable)) {
2339  if (!ID_IS_LINKED(ima)) {
2340  num_saveable_images++;
2341  }
2342  else {
2343  BKE_reportf(reports,
2344  RPT_WARNING,
2345  "Packed library image can't be saved: \"%s\" from \"%s\"",
2346  ima->id.name + 2,
2347  ima->id.lib->filepath);
2348  }
2349  }
2350  else if (!is_format_writable) {
2351  BKE_reportf(reports,
2352  RPT_WARNING,
2353  "Image can't be saved, use a different file format: \"%s\"",
2354  ima->id.name + 2);
2355  }
2356  else {
2357  if (image_has_valid_path(ima)) {
2358  num_saveable_images++;
2359  if (BLI_gset_haskey(unique_paths, ima->filepath)) {
2360  BKE_reportf(reports,
2361  RPT_WARNING,
2362  "Multiple images can't be saved to an identical path: \"%s\"",
2363  ima->filepath);
2364  }
2365  else {
2366  BLI_gset_insert(unique_paths, BLI_strdup(ima->filepath));
2367  }
2368  }
2369  else {
2370  BKE_reportf(reports,
2371  RPT_WARNING,
2372  "Image can't be saved, no valid file path: \"%s\"",
2373  ima->filepath);
2374  }
2375  }
2376  }
2377  }
2378 
2379  BLI_gset_free(unique_paths, MEM_freeN);
2380  return num_saveable_images;
2381 }
2382 
2384 {
2385  Main *bmain = CTX_data_main(C);
2386 
2387  ED_image_save_all_modified_info(bmain, reports);
2388 
2389  bool ok = true;
2390 
2391  for (Image *ima = bmain->images.first; ima; ima = ima->id.next) {
2392  bool is_format_writable;
2393 
2394  if (image_should_be_saved(ima, &is_format_writable)) {
2396  BKE_image_memorypack(ima);
2397  }
2398  else if (is_format_writable) {
2399  if (image_has_valid_path(ima)) {
2400  ImageSaveOptions opts;
2402  if (BKE_image_save_options_init(&opts, bmain, scene, ima, NULL, false, false)) {
2403  bool saved_successfully = BKE_image_save(reports, bmain, ima, NULL, &opts);
2404  ok = ok && saved_successfully;
2405  }
2407  }
2408  }
2409  }
2410  }
2411  return ok;
2412 }
2413 
2415 {
2417  return num_files > 0;
2418 }
2419 
2421 {
2423  return OPERATOR_FINISHED;
2424 }
2425 
2427 {
2428  /* identifiers */
2429  ot->name = "Save All Modified";
2430  ot->idname = "IMAGE_OT_save_all_modified";
2431  ot->description = "Save all modified images";
2432 
2433  /* api callbacks */
2436 
2437  /* flags */
2439 }
2440 
2443 /* -------------------------------------------------------------------- */
2448 {
2449  Main *bmain = CTX_data_main(C);
2450  Image *ima = image_from_context(C);
2452 
2453  if (!ima) {
2454  return OPERATOR_CANCELLED;
2455  }
2456 
2457  /* XXX BKE_packedfile_unpack_image frees image buffers */
2459 
2460  BKE_image_signal(bmain, ima, iuser, IMA_SIGNAL_RELOAD);
2461  DEG_id_tag_update(&ima->id, 0);
2462 
2464 
2465  return OPERATOR_FINISHED;
2466 }
2467 
2469 {
2470  /* identifiers */
2471  ot->name = "Reload Image";
2472  ot->idname = "IMAGE_OT_reload";
2473  ot->description = "Reload current image from disk";
2474 
2475  /* api callbacks */
2477 
2478  /* flags */
2479  ot->flag = OPTYPE_REGISTER; /* no undo, image buffer is not handled by undo */
2480 }
2481 
2484 /* -------------------------------------------------------------------- */
2488 #define IMA_DEF_NAME N_("Untitled")
2489 
2490 enum {
2494 };
2495 
2496 typedef struct ImageNewData {
2499 
2501 {
2502  if (op->customdata) {
2503  return op->customdata;
2504  }
2505 
2506  ImageNewData *data = MEM_callocN(sizeof(ImageNewData), __func__);
2507  UI_context_active_but_prop_get_templateID(C, &data->pprop.ptr, &data->pprop.prop);
2508  op->customdata = data;
2509  return data;
2510 }
2511 
2512 static void image_new_free(wmOperator *op)
2513 {
2515 }
2516 
2518 {
2519  SpaceImage *sima;
2520  Image *ima;
2521  Main *bmain;
2522  PropertyRNA *prop;
2523  char name_buffer[MAX_ID_NAME - 2];
2524  const char *name;
2525  float color[4];
2526  int width, height, floatbuf, gen_type, alpha;
2527  int stereo3d;
2528 
2529  /* retrieve state */
2530  sima = CTX_wm_space_image(C);
2531  bmain = CTX_data_main(C);
2532 
2533  prop = RNA_struct_find_property(op->ptr, "name");
2534  RNA_property_string_get(op->ptr, prop, name_buffer);
2535  if (!RNA_property_is_set(op->ptr, prop)) {
2536  /* Default value, we can translate! */
2537  name = DATA_(name_buffer);
2538  }
2539  else {
2540  name = name_buffer;
2541  }
2542  width = RNA_int_get(op->ptr, "width");
2543  height = RNA_int_get(op->ptr, "height");
2544  floatbuf = RNA_boolean_get(op->ptr, "float");
2545  gen_type = RNA_enum_get(op->ptr, "generated_type");
2546  RNA_float_get_array(op->ptr, "color", color);
2547  alpha = RNA_boolean_get(op->ptr, "alpha");
2548  stereo3d = RNA_boolean_get(op->ptr, "use_stereo_3d");
2549  bool tiled = RNA_boolean_get(op->ptr, "tiled");
2550 
2551  if (!alpha) {
2552  color[3] = 1.0f;
2553  }
2554 
2555  ima = BKE_image_add_generated(bmain,
2556  width,
2557  height,
2558  name,
2559  alpha ? 32 : 24,
2560  floatbuf,
2561  gen_type,
2562  color,
2563  stereo3d,
2564  false,
2565  tiled);
2566 
2567  if (!ima) {
2568  image_new_free(op);
2569  return OPERATOR_CANCELLED;
2570  }
2571 
2572  /* hook into UI */
2574 
2575  if (data->pprop.prop) {
2576  /* when creating new ID blocks, use is already 1, but RNA
2577  * pointer use also increases user, so this compensates it */
2578  id_us_min(&ima->id);
2579 
2580  PointerRNA imaptr;
2581  RNA_id_pointer_create(&ima->id, &imaptr);
2582  RNA_property_pointer_set(&data->pprop.ptr, data->pprop.prop, imaptr, NULL);
2583  RNA_property_update(C, &data->pprop.ptr, data->pprop.prop);
2584  }
2585  else if (sima) {
2586  ED_space_image_set(bmain, sima, ima, false);
2587  }
2588  else {
2589  /* #BKE_image_add_generated creates one user by default, remove it if image is not linked to
2590  * anything. ref. T94599. */
2591  id_us_min(&ima->id);
2592  }
2593 
2594  BKE_image_signal(bmain, ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_USER_NEW_IMAGE);
2595 
2597 
2598  image_new_free(op);
2599 
2600  return OPERATOR_FINISHED;
2601 }
2602 
2603 static int image_new_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
2604 {
2605  /* Get property in advance, it doesn't work after WM_operator_props_dialog_popup. */
2606  ImageNewData *data;
2607  op->customdata = data = MEM_callocN(sizeof(ImageNewData), __func__);
2608  UI_context_active_but_prop_get_templateID(C, &data->pprop.ptr, &data->pprop.prop);
2609 
2610  /* Better for user feedback. */
2611  RNA_string_set(op->ptr, "name", DATA_(IMA_DEF_NAME));
2612  return WM_operator_props_dialog_popup(C, op, 300);
2613 }
2614 
2616 {
2617  uiLayout *col;
2618  uiLayout *layout = op->layout;
2619 #if 0
2621  const bool is_multiview = (scene->r.scemode & R_MULTIVIEW) != 0;
2622 #endif
2623 
2624  /* copy of WM_operator_props_dialog_popup() layout */
2625 
2626  uiLayoutSetPropSep(layout, true);
2627  uiLayoutSetPropDecorate(layout, false);
2628 
2629  col = uiLayoutColumn(layout, false);
2630  uiItemR(col, op->ptr, "name", 0, NULL, ICON_NONE);
2631  uiItemR(col, op->ptr, "width", 0, NULL, ICON_NONE);
2632  uiItemR(col, op->ptr, "height", 0, NULL, ICON_NONE);
2633  uiItemR(col, op->ptr, "color", 0, NULL, ICON_NONE);
2634  uiItemR(col, op->ptr, "alpha", 0, NULL, ICON_NONE);
2635  uiItemR(col, op->ptr, "generated_type", 0, NULL, ICON_NONE);
2636  uiItemR(col, op->ptr, "float", 0, NULL, ICON_NONE);
2637  uiItemR(col, op->ptr, "tiled", 0, NULL, ICON_NONE);
2638 
2639 #if 0
2640  if (is_multiview) {
2641  uiItemL(col[0], "", ICON_NONE);
2642  uiItemR(col[1], op->ptr, "use_stereo_3d", 0, NULL, ICON_NONE);
2643  }
2644 #endif
2645 }
2646 
2648 {
2649  image_new_free(op);
2650 }
2651 
2653 {
2654  PropertyRNA *prop;
2655  static float default_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
2656 
2657  /* identifiers */
2658  ot->name = "New Image";
2659  ot->description = "Create a new image";
2660  ot->idname = "IMAGE_OT_new";
2661 
2662  /* api callbacks */
2663  ot->exec = image_new_exec;
2665  ot->ui = image_new_draw;
2667 
2668  /* flags */
2669  ot->flag = OPTYPE_UNDO;
2670 
2671  /* properties */
2672  RNA_def_string(ot->srna, "name", IMA_DEF_NAME, MAX_ID_NAME - 2, "Name", "Image data-block name");
2673  prop = RNA_def_int(ot->srna, "width", 1024, 1, INT_MAX, "Width", "Image width", 1, 16384);
2675  prop = RNA_def_int(ot->srna, "height", 1024, 1, INT_MAX, "Height", "Image height", 1, 16384);
2677  prop = RNA_def_float_color(
2678  ot->srna, "color", 4, NULL, 0.0f, FLT_MAX, "Color", "Default fill color", 0.0f, 1.0f);
2680  RNA_def_property_float_array_default(prop, default_color);
2681  RNA_def_boolean(ot->srna, "alpha", 1, "Alpha", "Create an image with an alpha channel");
2682  RNA_def_enum(ot->srna,
2683  "generated_type",
2686  "Generated Type",
2687  "Fill the image with a grid for UV map testing");
2689  ot->srna, "float", 0, "32-bit Float", "Create image with 32-bit floating-point bit depth");
2691  prop = RNA_def_boolean(
2692  ot->srna, "use_stereo_3d", 0, "Stereo 3D", "Create an image with left and right views");
2694  prop = RNA_def_boolean(ot->srna, "tiled", 0, "Tiled", "Create a tiled image");
2696 }
2697 
2698 #undef IMA_DEF_NAME
2699 
2702 /* -------------------------------------------------------------------- */
2707 {
2708  Image *ima = image_from_context(C);
2710  ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
2711  SpaceImage *sima = CTX_wm_space_image(C);
2712  const bool is_paint = ((sima != NULL) && (sima->mode == SI_MODE_PAINT));
2713 
2714  if (ibuf == NULL) {
2715  /* TODO: this should actually never happen, but does for render-results -> cleanup. */
2716  return OPERATOR_CANCELLED;
2717  }
2718 
2719  const bool use_flip_x = RNA_boolean_get(op->ptr, "use_flip_x");
2720  const bool use_flip_y = RNA_boolean_get(op->ptr, "use_flip_y");
2721 
2722  if (!use_flip_x && !use_flip_y) {
2723  BKE_image_release_ibuf(ima, ibuf, NULL);
2724  return OPERATOR_FINISHED;
2725  }
2726 
2727  ED_image_undo_push_begin_with_image(op->type->name, ima, ibuf, &iuser);
2728 
2729  if (is_paint) {
2731  }
2732 
2733  const int size_x = ibuf->x;
2734  const int size_y = ibuf->y;
2735 
2736  if (ibuf->rect_float) {
2737  float *float_pixels = (float *)ibuf->rect_float;
2738 
2739  float *orig_float_pixels = MEM_dupallocN(float_pixels);
2740  for (int x = 0; x < size_x; x++) {
2741  const int source_pixel_x = use_flip_x ? size_x - x - 1 : x;
2742  for (int y = 0; y < size_y; y++) {
2743  const int source_pixel_y = use_flip_y ? size_y - y - 1 : y;
2744 
2745  const float *source_pixel =
2746  &orig_float_pixels[4 * (source_pixel_x + source_pixel_y * size_x)];
2747  float *target_pixel = &float_pixels[4 * (x + y * size_x)];
2748 
2749  copy_v4_v4(target_pixel, source_pixel);
2750  }
2751  }
2752  MEM_freeN(orig_float_pixels);
2753 
2754  if (ibuf->rect) {
2755  IMB_rect_from_float(ibuf);
2756  }
2757  }
2758  else if (ibuf->rect) {
2759  char *char_pixels = (char *)ibuf->rect;
2760  char *orig_char_pixels = MEM_dupallocN(char_pixels);
2761  for (int x = 0; x < size_x; x++) {
2762  const int source_pixel_x = use_flip_x ? size_x - x - 1 : x;
2763  for (int y = 0; y < size_y; y++) {
2764  const int source_pixel_y = use_flip_y ? size_y - y - 1 : y;
2765 
2766  const char *source_pixel =
2767  &orig_char_pixels[4 * (source_pixel_x + source_pixel_y * size_x)];
2768  char *target_pixel = &char_pixels[4 * (x + y * size_x)];
2769 
2770  copy_v4_v4_char(target_pixel, source_pixel);
2771  }
2772  }
2773  MEM_freeN(orig_char_pixels);
2774  }
2775  else {
2776  BKE_image_release_ibuf(ima, ibuf, NULL);
2777  return OPERATOR_CANCELLED;
2778  }
2779 
2781  BKE_image_mark_dirty(ima, ibuf);
2782 
2783  if (ibuf->mipmap[0]) {
2784  ibuf->userflags |= IB_MIPMAP_INVALID;
2785  }
2786 
2788 
2790 
2792 
2793  BKE_image_release_ibuf(ima, ibuf, NULL);
2794 
2795  return OPERATOR_FINISHED;
2796 }
2797 
2799 {
2800  /* identifiers */
2801  ot->name = "Flip Image";
2802  ot->idname = "IMAGE_OT_flip";
2803  ot->description = "Flip the image";
2804 
2805  /* api callbacks */
2806  ot->exec = image_flip_exec;
2808 
2809  /* properties */
2810  PropertyRNA *prop;
2811  prop = RNA_def_boolean(
2812  ot->srna, "use_flip_x", false, "Horizontal", "Flip the image horizontally");
2814  prop = RNA_def_boolean(ot->srna, "use_flip_y", false, "Vertical", "Flip the image vertically");
2816 
2817  /* flags */
2818  ot->flag = OPTYPE_REGISTER;
2819 }
2820 
2823 /* -------------------------------------------------------------------- */
2828 {
2829  Image *ima = image_from_context(C);
2831  ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
2832  SpaceImage *sima = CTX_wm_space_image(C);
2833  const bool is_paint = ((sima != NULL) && (sima->mode == SI_MODE_PAINT));
2834 
2835  /* flags indicate if this channel should be inverted */
2836  const bool r = RNA_boolean_get(op->ptr, "invert_r");
2837  const bool g = RNA_boolean_get(op->ptr, "invert_g");
2838  const bool b = RNA_boolean_get(op->ptr, "invert_b");
2839  const bool a = RNA_boolean_get(op->ptr, "invert_a");
2840 
2841  size_t i;
2842 
2843  if (ibuf == NULL) {
2844  /* TODO: this should actually never happen, but does for render-results -> cleanup */
2845  return OPERATOR_CANCELLED;
2846  }
2847 
2848  ED_image_undo_push_begin_with_image(op->type->name, ima, ibuf, &iuser);
2849 
2850  if (is_paint) {
2852  }
2853 
2854  /* TODO: make this into an IMB_invert_channels(ibuf,r,g,b,a) method!? */
2855  if (ibuf->rect_float) {
2856 
2857  float *fp = (float *)ibuf->rect_float;
2858  for (i = ((size_t)ibuf->x) * ibuf->y; i > 0; i--, fp += 4) {
2859  if (r) {
2860  fp[0] = 1.0f - fp[0];
2861  }
2862  if (g) {
2863  fp[1] = 1.0f - fp[1];
2864  }
2865  if (b) {
2866  fp[2] = 1.0f - fp[2];
2867  }
2868  if (a) {
2869  fp[3] = 1.0f - fp[3];
2870  }
2871  }
2872 
2873  if (ibuf->rect) {
2874  IMB_rect_from_float(ibuf);
2875  }
2876  }
2877  else if (ibuf->rect) {
2878 
2879  char *cp = (char *)ibuf->rect;
2880  for (i = ((size_t)ibuf->x) * ibuf->y; i > 0; i--, cp += 4) {
2881  if (r) {
2882  cp[0] = 255 - cp[0];
2883  }
2884  if (g) {
2885  cp[1] = 255 - cp[1];
2886  }
2887  if (b) {
2888  cp[2] = 255 - cp[2];
2889  }
2890  if (a) {
2891  cp[3] = 255 - cp[3];
2892  }
2893  }
2894  }
2895  else {
2896  BKE_image_release_ibuf(ima, ibuf, NULL);
2897  return OPERATOR_CANCELLED;
2898  }
2899 
2901  BKE_image_mark_dirty(ima, ibuf);
2902 
2903  if (ibuf->mipmap[0]) {
2904  ibuf->userflags |= IB_MIPMAP_INVALID;
2905  }
2906 
2908 
2910 
2912 
2913  BKE_image_release_ibuf(ima, ibuf, NULL);
2914 
2915  return OPERATOR_FINISHED;
2916 }
2917 
2919 {
2920  PropertyRNA *prop;
2921 
2922  /* identifiers */
2923  ot->name = "Invert Channels";
2924  ot->idname = "IMAGE_OT_invert";
2925  ot->description = "Invert image's channels";
2926 
2927  /* api callbacks */
2930 
2931  /* properties */
2932  prop = RNA_def_boolean(ot->srna, "invert_r", 0, "Red", "Invert red channel");
2934  prop = RNA_def_boolean(ot->srna, "invert_g", 0, "Green", "Invert green channel");
2936  prop = RNA_def_boolean(ot->srna, "invert_b", 0, "Blue", "Invert blue channel");
2938  prop = RNA_def_boolean(ot->srna, "invert_a", 0, "Alpha", "Invert alpha channel");
2940 
2941  /* flags */
2942  ot->flag = OPTYPE_REGISTER;
2943 }
2944 
2947 /* -------------------------------------------------------------------- */
2951 static int image_scale_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
2952 {
2953  Image *ima = image_from_context(C);
2955  PropertyRNA *prop = RNA_struct_find_property(op->ptr, "size");
2956  if (!RNA_property_is_set(op->ptr, prop)) {
2957  ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
2958  const int size[2] = {ibuf->x, ibuf->y};
2959  RNA_property_int_set_array(op->ptr, prop, size);
2960  BKE_image_release_ibuf(ima, ibuf, NULL);
2961  }
2962  return WM_operator_props_dialog_popup(C, op, 200);
2963 }
2964 
2966 {
2967  Image *ima = image_from_context(C);
2969  ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
2970  SpaceImage *sima = CTX_wm_space_image(C);
2971  const bool is_paint = ((sima != NULL) && (sima->mode == SI_MODE_PAINT));
2972 
2973  if (ibuf == NULL) {
2974  /* TODO: this should actually never happen, but does for render-results -> cleanup */
2975  return OPERATOR_CANCELLED;
2976  }
2977 
2978  if (is_paint) {
2980  }
2981 
2982  PropertyRNA *prop = RNA_struct_find_property(op->ptr, "size");
2983  int size[2];
2984  if (RNA_property_is_set(op->ptr, prop)) {
2985  RNA_property_int_get_array(op->ptr, prop, size);
2986  }
2987  else {
2988  size[0] = ibuf->x;
2989  size[1] = ibuf->y;
2990  RNA_property_int_set_array(op->ptr, prop, size);
2991  }
2992 
2993  ED_image_undo_push_begin_with_image(op->type->name, ima, ibuf, &iuser);
2994 
2996  IMB_scaleImBuf(ibuf, size[0], size[1]);
2997  BKE_image_mark_dirty(ima, ibuf);
2998  BKE_image_release_ibuf(ima, ibuf, NULL);
2999 
3001 
3003 
3004  DEG_id_tag_update(&ima->id, 0);
3006 
3007  return OPERATOR_FINISHED;
3008 }
3009 
3011 {
3012  /* identifiers */
3013  ot->name = "Resize Image";
3014  ot->idname = "IMAGE_OT_resize";
3015  ot->description = "Resize the image";
3016 
3017  /* api callbacks */
3021 
3022  /* properties */
3023  RNA_def_int_vector(ot->srna, "size", 2, NULL, 1, INT_MAX, "Size", "", 1, SHRT_MAX);
3024 
3025  /* flags */
3026  ot->flag = OPTYPE_REGISTER;
3027 }
3028 
3031 /* -------------------------------------------------------------------- */
3036 {
3037  Image *ima = image_from_context(C);
3038 
3039  if (!ima) {
3040  return false;
3041  }
3042 
3043  if (ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
3044  BKE_report(op->reports, RPT_ERROR, "Packing movies or image sequences not supported");
3045  return false;
3046  }
3047 
3048  return true;
3049 }
3050 
3052 {
3053  struct Main *bmain = CTX_data_main(C);
3054  Image *ima = image_from_context(C);
3055 
3056  if (!image_pack_test(C, op)) {
3057  return OPERATOR_CANCELLED;
3058  }
3059 
3060  if (BKE_image_is_dirty(ima)) {
3061  BKE_image_memorypack(ima);
3062  }
3063  else {
3064  BKE_image_packfiles(op->reports, ima, ID_BLEND_PATH(bmain, &ima->id));
3065  }
3066 
3068 
3069  return OPERATOR_FINISHED;
3070 }
3071 
3073 {
3074  /* identifiers */
3075  ot->name = "Pack Image";
3076  ot->description = "Pack an image as embedded data into the .blend file";
3077  ot->idname = "IMAGE_OT_pack";
3078 
3079  /* api callbacks */
3080  ot->exec = image_pack_exec;
3081 
3082  /* flags */
3084 }
3085 
3088 /* -------------------------------------------------------------------- */
3093 {
3094  Main *bmain = CTX_data_main(C);
3095  Image *ima = image_from_context(C);
3096  int method = RNA_enum_get(op->ptr, "method");
3097 
3098  /* find the supplied image by name */
3099  if (RNA_struct_property_is_set(op->ptr, "id")) {
3100  char imaname[MAX_ID_NAME - 2];
3101  RNA_string_get(op->ptr, "id", imaname);
3102  ima = BLI_findstring(&bmain->images, imaname, offsetof(ID, name) + 2);
3103  if (!ima) {
3104  ima = image_from_context(C);
3105  }
3106  }
3107 
3108  if (!ima || !BKE_image_has_packedfile(ima)) {
3109  return OPERATOR_CANCELLED;
3110  }
3111 
3112  if (ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
3113  BKE_report(op->reports, RPT_ERROR, "Unpacking movies or image sequences not supported");
3114  return OPERATOR_CANCELLED;
3115  }
3116 
3117  if (G.fileflags & G_FILE_AUTOPACK) {
3118  BKE_report(op->reports,
3119  RPT_WARNING,
3120  "AutoPack is enabled, so image will be packed again on file save");
3121  }
3122 
3123  /* XXX BKE_packedfile_unpack_image frees image buffers */
3125 
3126  BKE_packedfile_unpack_image(CTX_data_main(C), op->reports, ima, method);
3127 
3129 
3130  return OPERATOR_FINISHED;
3131 }
3132 
3133 static int image_unpack_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
3134 {
3135  Image *ima = image_from_context(C);
3136 
3137  if (RNA_struct_property_is_set(op->ptr, "id")) {
3138  return image_unpack_exec(C, op);
3139  }
3140 
3141  if (!ima || !BKE_image_has_packedfile(ima)) {
3142  return OPERATOR_CANCELLED;
3143  }
3144 
3145  if (ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
3146  BKE_report(op->reports, RPT_ERROR, "Unpacking movies or image sequences not supported");
3147  return OPERATOR_CANCELLED;
3148  }
3149 
3150  if (G.fileflags & G_FILE_AUTOPACK) {
3151  BKE_report(op->reports,
3152  RPT_WARNING,
3153  "AutoPack is enabled, so image will be packed again on file save");
3154  }
3155 
3156  unpack_menu(C,
3157  "IMAGE_OT_unpack",
3158  ima->id.name + 2,
3159  ima->filepath,
3160  "textures",
3162  ((ImagePackedFile *)ima->packedfiles.first)->packedfile :
3163  NULL);
3164 
3165  return OPERATOR_FINISHED;
3166 }
3167 
3169 {
3170  /* identifiers */
3171  ot->name = "Unpack Image";
3172  ot->description = "Save an image packed in the .blend file to disk";
3173  ot->idname = "IMAGE_OT_unpack";
3174 
3175  /* api callbacks */
3178 
3179  /* flags */
3181 
3182  /* properties */
3183  RNA_def_enum(
3184  ot->srna, "method", rna_enum_unpack_method_items, PF_USE_LOCAL, "Method", "How to unpack");
3185  /* XXX, weak!, will fail with library, name collisions */
3187  ot->srna, "id", NULL, MAX_ID_NAME - 2, "Image Name", "Image data-block name to unpack");
3188 }
3189 
3192 /* -------------------------------------------------------------------- */
3197  struct ARegion *region,
3198  int mval[2],
3199  float fpos[2])
3200 {
3201  void *lock;
3202  ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock, 0);
3203 
3204  if (ibuf == NULL) {
3205  ED_space_image_release_buffer(sima, ibuf, lock);
3206  return false;
3207  }
3208 
3209  UI_view2d_region_to_view(&region->v2d, mval[0], mval[1], &fpos[0], &fpos[1]);
3210 
3211  ED_space_image_release_buffer(sima, ibuf, lock);
3212  return true;
3213 }
3214 
3216  SpaceImage *sima, ARegion *region, const int mval[2], float r_col[3], bool *r_is_data)
3217 {
3218  if (r_is_data) {
3219  *r_is_data = false;
3220  }
3221  if (sima->image == NULL) {
3222  return false;
3223  }
3224  float uv[2];
3225  UI_view2d_region_to_view(&region->v2d, mval[0], mval[1], &uv[0], &uv[1]);
3226  int tile = BKE_image_get_tile_from_pos(sima->image, uv, uv, NULL);
3227 
3228  void *lock;
3229  ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock, tile);
3230  bool ret = false;
3231 
3232  if (ibuf == NULL) {
3233  ED_space_image_release_buffer(sima, ibuf, lock);
3234  return false;
3235  }
3236 
3237  if (uv[0] >= 0.0f && uv[1] >= 0.0f && uv[0] < 1.0f && uv[1] < 1.0f) {
3238  const float *fp;
3239  uchar *cp;
3240  int x = (int)(uv[0] * ibuf->x), y = (int)(uv[1] * ibuf->y);
3241 
3242  CLAMP(x, 0, ibuf->x - 1);
3243  CLAMP(y, 0, ibuf->y - 1);
3244 
3245  if (ibuf->rect_float) {
3246  fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
3247  copy_v3_v3(r_col, fp);
3248  ret = true;
3249  }
3250  else if (ibuf->rect) {
3251  cp = (uchar *)(ibuf->rect + y * ibuf->x + x);
3252  rgb_uchar_to_float(r_col, cp);
3254  ret = true;
3255  }
3256  }
3257 
3258  if (r_is_data) {
3259  *r_is_data = (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) != 0;
3260  }
3261 
3262  ED_space_image_release_buffer(sima, ibuf, lock);
3263  return ret;
3264 }
3265 
3267 {
3268  /* identifiers */
3269  ot->name = "Sample Color";
3270  ot->idname = "IMAGE_OT_sample";
3271  ot->description = "Use mouse to sample a color in current image";
3272 
3273  /* api callbacks */
3278 
3279  /* flags */
3280  ot->flag = OPTYPE_BLOCKING;
3281 
3282  PropertyRNA *prop;
3283  prop = RNA_def_int(ot->srna, "size", 1, 1, 128, "Sample Size", "", 1, 64);
3286 }
3287 
3290 /* -------------------------------------------------------------------- */
3295 {
3296  SpaceImage *sima = CTX_wm_space_image(C);
3297  ARegion *region = CTX_wm_region(C);
3299  Image *ima = ED_space_image(sima);
3300 
3301  int x_start = RNA_int_get(op->ptr, "xstart");
3302  int y_start = RNA_int_get(op->ptr, "ystart");
3303  int x_end = RNA_int_get(op->ptr, "xend");
3304  int y_end = RNA_int_get(op->ptr, "yend");
3305 
3306  float uv1[2], uv2[2], ofs[2];
3307  UI_view2d_region_to_view(&region->v2d, x_start, y_start, &uv1[0], &uv1[1]);
3308  UI_view2d_region_to_view(&region->v2d, x_end, y_end, &uv2[0], &uv2[1]);
3309 
3310  /* If the image has tiles, shift the positions accordingly. */
3311  int tile = BKE_image_get_tile_from_pos(ima, uv1, uv1, ofs);
3312  sub_v2_v2(uv2, ofs);
3313 
3314  void *lock;
3315  ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock, tile);
3316  Histogram *hist = &sima->sample_line_hist;
3317 
3318  if (ibuf == NULL) {
3319  ED_space_image_release_buffer(sima, ibuf, lock);
3320  return OPERATOR_CANCELLED;
3321  }
3322  /* hmmmm */
3323  if (ibuf->channels < 3) {
3324  ED_space_image_release_buffer(sima, ibuf, lock);
3325  return OPERATOR_CANCELLED;
3326  }
3327 
3328  copy_v2_v2(hist->co[0], uv1);
3329  copy_v2_v2(hist->co[1], uv2);
3330 
3331  /* enable line drawing */
3332  hist->flag |= HISTO_FLAG_SAMPLELINE;
3333 
3335 
3336  /* reset y zoom */
3337  hist->ymax = 1.0f;
3338 
3339  ED_space_image_release_buffer(sima, ibuf, lock);
3340 
3342 
3343  return OPERATOR_FINISHED;
3344 }
3345 
3346 static int image_sample_line_invoke(bContext *C, wmOperator *op, const wmEvent *event)
3347 {
3348  SpaceImage *sima = CTX_wm_space_image(C);
3349 
3350  Histogram *hist = &sima->sample_line_hist;
3351  hist->flag &= ~HISTO_FLAG_SAMPLELINE;
3352 
3353  if (!ED_space_image_has_buffer(sima)) {
3354  return OPERATOR_CANCELLED;
3355  }
3356 
3357  return WM_gesture_straightline_invoke(C, op, event);
3358 }
3359 
3361 {
3362  /* identifiers */
3363  ot->name = "Sample Line";
3364  ot->idname = "IMAGE_OT_sample_line";
3365  ot->description = "Sample a line and show it in Scope panels";
3366 
3367  /* api callbacks */
3373 
3374  /* flags */
3375  ot->flag = 0; /* no undo/register since this operates on the space */
3376 
3378 }
3379 
3382 /* -------------------------------------------------------------------- */
3387 {
3388  static const EnumPropertyItem point_items[] = {
3389  {0, "BLACK_POINT", 0, "Black Point", ""},
3390  {1, "WHITE_POINT", 0, "White Point", ""},
3391  {0, NULL, 0, NULL, NULL},
3392  };
3393 
3394  /* identifiers */
3395  ot->name = "Set Curves Point";
3396  ot->idname = "IMAGE_OT_curves_point_set";
3397  ot->description = "Set black point or white point for curves";
3398 
3399  /* flags */
3401 
3402  /* api callbacks */
3407 
3408  /* properties */
3409  RNA_def_enum(
3410  ot->srna, "point", point_items, 0, "Point", "Set black point or white point for curves");
3411 
3412  PropertyRNA *prop;
3413  prop = RNA_def_int(ot->srna, "size", 1, 1, 128, "Sample Size", "", 1, 64);
3416 }
3417 
3420 /* -------------------------------------------------------------------- */
3425 {
3426  Image *ima = image_from_context(C);
3427 
3428  return (ima && ima->type == IMA_TYPE_R_RESULT);
3429 }
3430 
3432 {
3433  Image *ima = image_from_context(C);
3434  const int direction = RNA_boolean_get(op->ptr, "reverse") ? -1 : 1;
3435 
3436  if (!ED_image_slot_cycle(ima, direction)) {
3437  return OPERATOR_CANCELLED;
3438  }
3439 
3441 
3442  /* no undo push for browsing existing */
3443  RenderSlot *slot = BKE_image_get_renderslot(ima, ima->render_slot);
3444  if ((slot && slot->render) || ima->render_slot == ima->last_render_slot) {
3445  return OPERATOR_CANCELLED;
3446  }
3447 
3448  return OPERATOR_FINISHED;
3449 }
3450 
3452 {
3453  /* identifiers */
3454  ot->name = "Cycle Render Slot";
3455  ot->idname = "IMAGE_OT_cycle_render_slot";
3456  ot->description = "Cycle through all non-void render slots";
3457 
3458  /* api callbacks */
3461 
3462  /* flags */
3463  ot->flag = OPTYPE_REGISTER;
3464 
3465  RNA_def_boolean(ot->srna, "reverse", 0, "Cycle in Reverse", "");
3466 }
3467 
3470 /* -------------------------------------------------------------------- */
3475 {
3476  Image *ima = image_from_context(C);
3478 
3479  if (!BKE_image_clear_renderslot(ima, iuser, ima->render_slot)) {
3480  return OPERATOR_CANCELLED;
3481  }
3482 
3484 
3485  return OPERATOR_FINISHED;
3486 }
3487 
3489 {
3490  /* identifiers */
3491  ot->name = "Clear Render Slot";
3492  ot->idname = "IMAGE_OT_clear_render_slot";
3493  ot->description = "Clear the currently selected render slot";
3494 
3495  /* api callbacks */
3498 
3499  /* flags */
3500  ot->flag = OPTYPE_REGISTER;
3501 }
3502 
3505 /* -------------------------------------------------------------------- */
3510 {
3511  Image *ima = image_from_context(C);
3512 
3514  ima->render_slot = BLI_findindex(&ima->renderslots, slot);
3515 
3517 
3518  return OPERATOR_FINISHED;
3519 }
3520 
3522 {
3523  /* identifiers */
3524  ot->name = "Add Render Slot";
3525  ot->idname = "IMAGE_OT_add_render_slot";
3526  ot->description = "Add a new render slot";
3527 
3528  /* api callbacks */
3531 
3532  /* flags */
3533  ot->flag = OPTYPE_REGISTER;
3534 }
3535 
3538 /* -------------------------------------------------------------------- */
3543 {
3544  Image *ima = image_from_context(C);
3546 
3547  if (!BKE_image_remove_renderslot(ima, iuser, ima->render_slot)) {
3548  return OPERATOR_CANCELLED;
3549  }
3550 
3552 
3553  return OPERATOR_FINISHED;
3554 }
3555 
3557 {
3558  /* identifiers */
3559  ot->name = "Remove Render Slot";
3560  ot->idname = "IMAGE_OT_remove_render_slot";
3561  ot->description = "Remove the current render slot";
3562 
3563  /* api callbacks */
3566 
3567  /* flags */
3568  ot->flag = OPTYPE_REGISTER;
3569 }
3570 
3573 /* -------------------------------------------------------------------- */
3578 {
3579  /* prevent changes during render */
3580  if (G.is_rendering) {
3581  return 0;
3582  }
3583 
3585 }
3586 
3588 {
3590 
3591  /* set the new frame number */
3592  scene->r.cfra = RNA_int_get(op->ptr, "frame");
3594  scene->r.subframe = 0.0f;
3595 
3596  /* do updates */
3599 }
3600 
3602 {
3603  change_frame_apply(C, op);
3604 
3605  return OPERATOR_FINISHED;
3606 }
3607 
3608 static int frame_from_event(bContext *C, const wmEvent *event)
3609 {
3610  ARegion *region = CTX_wm_region(C);
3612  int framenr = 0;
3613 
3614  if (region->regiontype == RGN_TYPE_WINDOW) {
3615  float sfra = scene->r.sfra, efra = scene->r.efra, framelen = region->winx / (efra - sfra + 1);
3616 
3617  framenr = sfra + event->mval[0] / framelen;
3618  }
3619  else {
3620  float viewx, viewy;
3621 
3622  UI_view2d_region_to_view(&region->v2d, event->mval[0], event->mval[1], &viewx, &viewy);
3623 
3624  framenr = round_fl_to_int(viewx);
3625  }
3626 
3627  return framenr;
3628 }
3629 
3630 static int change_frame_invoke(bContext *C, wmOperator *op, const wmEvent *event)
3631 {
3632  ARegion *region = CTX_wm_region(C);
3633 
3634  if (region->regiontype == RGN_TYPE_WINDOW) {
3635  const SpaceImage *sima = CTX_wm_space_image(C);
3636  if (!ED_space_image_show_cache_and_mval_over(sima, region, event->mval)) {
3637  return OPERATOR_PASS_THROUGH;
3638  }
3639  }
3640 
3641  RNA_int_set(op->ptr, "frame", frame_from_event(C, event));
3642 
3643  change_frame_apply(C, op);
3644 
3645  /* add temp handler */
3647 
3648  return OPERATOR_RUNNING_MODAL;
3649 }
3650 
3651 static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event)
3652 {
3653  switch (event->type) {
3654  case EVT_ESCKEY:
3655  return OPERATOR_FINISHED;
3656 
3657  case MOUSEMOVE:
3658  RNA_int_set(op->ptr, "frame", frame_from_event(C, event));
3659  change_frame_apply(C, op);
3660  break;
3661 
3662  case LEFTMOUSE:
3663  case RIGHTMOUSE:
3664  if (event->val == KM_RELEASE) {
3665  return OPERATOR_FINISHED;
3666  }
3667  break;
3668  }
3669 
3670  return OPERATOR_RUNNING_MODAL;
3671 }
3672 
3674 {
3675  /* identifiers */
3676  ot->name = "Change Frame";
3677  ot->idname = "IMAGE_OT_change_frame";
3678  ot->description = "Interactively change the current frame number";
3679 
3680  /* api callbacks */
3685 
3686  /* flags */
3688 
3689  /* rna */
3690  RNA_def_int(ot->srna, "frame", 0, MINAFRAME, MAXFRAME, "Frame", "", MINAFRAME, MAXFRAME);
3691 }
3692 
3693 /* Reload cached render results... */
3694 /* goes over all scenes, reads render layers */
3696 {
3697  Main *bmain = CTX_data_main(C);
3699  SpaceImage *sima = CTX_wm_space_image(C);
3700  Image *ima;
3701 
3702  ima = BKE_image_ensure_viewer(bmain, IMA_TYPE_R_RESULT, "Render Result");
3703  if (sima->image == NULL) {
3704  ED_space_image_set(bmain, sima, ima, false);
3705  }
3706 
3708 
3710  return OPERATOR_FINISHED;
3711 }
3712 
3714 {
3715  ot->name = "Open Cached Render";
3716  ot->idname = "IMAGE_OT_read_viewlayers";
3717  ot->description = "Read all the current scene's view layers from cache, as needed";
3718 
3721 
3722  /* flags */
3723  ot->flag = 0;
3724 }
3725 
3728 /* -------------------------------------------------------------------- */
3733 {
3734  ARegion *region = CTX_wm_region(C);
3737  SpaceImage *sima = CTX_wm_space_image(C);
3738 
3739  if (re == NULL) {
3740  /* Shouldn't happen, but better be safe close to the release. */
3741  return OPERATOR_CANCELLED;
3742  }
3743 
3744  /* Get information about the previous render, or current scene if no render yet. */
3745  int width, height;
3746  BKE_render_resolution(&scene->r, false, &width, &height);
3748  &scene->r;
3749 
3750  /* Get rectangle from the operator. */
3751  rctf border;
3754 
3755  /* Adjust for cropping. */
3756  if ((rd->mode & (R_BORDER | R_CROP)) == (R_BORDER | R_CROP)) {
3757  border.xmin = rd->border.xmin + border.xmin * (rd->border.xmax - rd->border.xmin);
3758  border.xmax = rd->border.xmin + border.xmax * (rd->border.xmax - rd->border.xmin);
3759  border.ymin = rd->border.ymin + border.ymin * (rd->border.ymax - rd->border.ymin);
3760  border.ymax = rd->border.ymin + border.ymax * (rd->border.ymax - rd->border.ymin);
3761  }
3762 
3763  CLAMP(border.xmin, 0.0f, 1.0f);
3764  CLAMP(border.ymin, 0.0f, 1.0f);
3765  CLAMP(border.xmax, 0.0f, 1.0f);
3766  CLAMP(border.ymax, 0.0f, 1.0f);
3767 
3768  /* Drawing a border surrounding the entire camera view switches off border rendering
3769  * or the border covers no pixels. */
3770  if ((border.xmin <= 0.0f && border.xmax >= 1.0f && border.ymin <= 0.0f && border.ymax >= 1.0f) ||
3771  (border.xmin == border.xmax || border.ymin == border.ymax)) {
3772  scene->r.mode &= ~R_BORDER;
3773  }
3774  else {
3775  /* Snap border to pixel boundaries, so drawing a border within a pixel selects that pixel. */
3776  border.xmin = floorf(border.xmin * width) / width;
3777  border.xmax = ceilf(border.xmax * width) / width;
3778  border.ymin = floorf(border.ymin * height) / height;
3779  border.ymax = ceilf(border.ymax * height) / height;
3780 
3781  /* Set border. */
3782  scene->r.border = border;
3783  scene->r.mode |= R_BORDER;
3784  }
3785 
3788 
3789  return OPERATOR_FINISHED;
3790 }
3791 
3793 {
3794  /* identifiers */
3795  ot->name = "Render Region";
3796  ot->description = "Set the boundaries of the render region and enable render region";
3797  ot->idname = "IMAGE_OT_render_border";
3798 
3799  /* api callbacks */
3805 
3806  /* flags */
3808 
3809  /* rna */
3811 }
3812 
3815 /* -------------------------------------------------------------------- */
3820 {
3822  scene->r.mode &= ~R_BORDER;
3824  BLI_rctf_init(&scene->r.border, 0.0f, 1.0f, 0.0f, 1.0f);
3825  return OPERATOR_FINISHED;
3826 }
3827 
3829 {
3830  /* identifiers */
3831  ot->name = "Clear Render Region";
3832  ot->description = "Clear the boundaries of the render region and disable render region";
3833  ot->idname = "IMAGE_OT_clear_render_border";
3834 
3835  /* api callbacks */
3838 
3839  /* flags */
3841 }
3842 
3845 /* -------------------------------------------------------------------- */
3850 {
3851  float color[4];
3852  RNA_float_get_array(ptr, "color", color);
3853  int gen_type = RNA_enum_get(ptr, "generated_type");
3854  int width = RNA_int_get(ptr, "width");
3855  int height = RNA_int_get(ptr, "height");
3856  bool is_float = RNA_boolean_get(ptr, "float");
3857  int planes = RNA_boolean_get(ptr, "alpha") ? 32 : 24;
3858 
3859  return BKE_image_fill_tile(ima, tile, width, height, color, gen_type, planes, is_float);
3860 }
3861 
3862 static void draw_fill_tile(PointerRNA *ptr, uiLayout *layout)
3863 {
3864  uiLayoutSetPropSep(layout, true);
3865  uiLayoutSetPropDecorate(layout, false);
3866 
3867  uiLayout *col = uiLayoutColumn(layout, false);
3868  uiItemR(col, ptr, "color", 0, NULL, ICON_NONE);
3869  uiItemR(col, ptr, "width", 0, NULL, ICON_NONE);
3870  uiItemR(col, ptr, "height", 0, NULL, ICON_NONE);
3871  uiItemR(col, ptr, "alpha", 0, NULL, ICON_NONE);
3872  uiItemR(col, ptr, "generated_type", 0, NULL, ICON_NONE);
3873  uiItemR(col, ptr, "float", 0, NULL, ICON_NONE);
3874 }
3875 
3877 {
3878  ImageUser iuser;
3879  BKE_imageuser_default(&iuser);
3880  if (tile != NULL) {
3881  iuser.tile = tile->tile_number;
3882  }
3883 
3884  /* Acquire ibuf to get the default values.
3885  * If the specified tile has no ibuf, try acquiring the main tile instead
3886  * (unless the specified tile already was the first tile). */
3887  ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
3888  if (ibuf == NULL && (tile != NULL) && (tile != ima->tiles.first)) {
3889  ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
3890  }
3891 
3892  if (ibuf != NULL) {
3893  /* Initialize properties from reference tile. */
3894  RNA_int_set(ptr, "width", ibuf->x);
3895  RNA_int_set(ptr, "height", ibuf->y);
3896  RNA_boolean_set(ptr, "float", ibuf->rect_float != NULL);
3897  RNA_boolean_set(ptr, "alpha", ibuf->planes > 24);
3898 
3899  BKE_image_release_ibuf(ima, ibuf, NULL);
3900  }
3901 }
3902 
3904 {
3905  PropertyRNA *prop;
3906  static float default_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
3907  prop = RNA_def_float_color(
3908  srna, "color", 4, NULL, 0.0f, FLT_MAX, "Color", "Default fill color", 0.0f, 1.0f);
3910  RNA_def_property_float_array_default(prop, default_color);
3911  RNA_def_enum(srna,
3912  "generated_type",
3915  "Generated Type",
3916  "Fill the image with a grid for UV map testing");
3917  prop = RNA_def_int(srna, "width", 1024, 1, INT_MAX, "Width", "Image width", 1, 16384);
3919  prop = RNA_def_int(srna, "height", 1024, 1, INT_MAX, "Height", "Image height", 1, 16384);
3921 
3922  /* Only needed when filling the first tile. */
3924  srna, "float", 0, "32-bit Float", "Create image with 32-bit floating-point bit depth");
3925  RNA_def_boolean(srna, "alpha", 1, "Alpha", "Create an image with an alpha channel");
3926 }
3927 
3928 static bool tile_add_poll(bContext *C)
3929 {
3930  Image *ima = CTX_data_edit_image(C);
3931 
3932  return (ima != NULL && ima->source == IMA_SRC_TILED && BKE_image_has_ibuf(ima, NULL));
3933 }
3934 
3936 {
3937  Image *ima = CTX_data_edit_image(C);
3938 
3939  int start_tile = RNA_int_get(op->ptr, "number");
3940  int end_tile = start_tile + RNA_int_get(op->ptr, "count") - 1;
3941 
3942  if (start_tile < 1001 || end_tile > IMA_UDIM_MAX) {
3943  BKE_report(op->reports, RPT_ERROR, "Invalid UDIM index range was specified");
3944  return OPERATOR_CANCELLED;
3945  }
3946 
3947  bool fill_tile = RNA_boolean_get(op->ptr, "fill");
3948  char *label = RNA_string_get_alloc(op->ptr, "label", NULL, 0, NULL);
3949 
3950  /* BKE_image_add_tile assumes a pre-sorted list of tiles. */
3951  BKE_image_sort_tiles(ima);
3952 
3953  ImageTile *last_tile_created = NULL;
3954  for (int tile_number = start_tile; tile_number <= end_tile; tile_number++) {
3955  ImageTile *tile = BKE_image_add_tile(ima, tile_number, label);
3956 
3957  if (tile != NULL) {
3958  if (fill_tile) {
3959  do_fill_tile(op->ptr, ima, tile);
3960  }
3961 
3962  last_tile_created = tile;
3963  }
3964  }
3965  MEM_freeN(label);
3966 
3967  if (!last_tile_created) {
3968  BKE_report(op->reports, RPT_WARNING, "No UDIM tiles were created");
3969  return OPERATOR_CANCELLED;
3970  }
3971 
3972  ima->active_tile_index = BLI_findindex(&ima->tiles, last_tile_created);
3973 
3975  return OPERATOR_FINISHED;
3976 }
3977 
3978 static int tile_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
3979 {
3980  Image *ima = CTX_data_edit_image(C);
3981 
3982  /* Find the first gap in tile numbers or the number after the last if
3983  * no gap exists. */
3984  int next_number = 0;
3985  LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
3986  next_number = tile->tile_number + 1;
3987  if (tile->next == NULL || tile->next->tile_number > next_number) {
3988  break;
3989  }
3990  }
3991 
3993  tile_fill_init(op->ptr, ima, tile);
3994 
3995  RNA_int_set(op->ptr, "number", next_number);
3996  RNA_int_set(op->ptr, "count", 1);
3997  RNA_string_set(op->ptr, "label", "");
3998 
3999  return WM_operator_props_dialog_popup(C, op, 300);
4000 }
4001 
4003 {
4004  uiLayout *col;
4005  uiLayout *layout = op->layout;
4006 
4007  uiLayoutSetPropSep(layout, true);
4008  uiLayoutSetPropDecorate(layout, false);
4009 
4010  col = uiLayoutColumn(layout, false);
4011  uiItemR(col, op->ptr, "number", 0, NULL, ICON_NONE);
4012  uiItemR(col, op->ptr, "count", 0, NULL, ICON_NONE);
4013  uiItemR(col, op->ptr, "label", 0, NULL, ICON_NONE);
4014  uiItemR(layout, op->ptr, "fill", 0, NULL, ICON_NONE);
4015 
4016  if (RNA_boolean_get(op->ptr, "fill")) {
4017  draw_fill_tile(op->ptr, layout);
4018  }
4019 }
4020 
4022 {
4023  /* identifiers */
4024  ot->name = "Add Tile";
4025  ot->description = "Adds a tile to the image";
4026  ot->idname = "IMAGE_OT_tile_add";
4027 
4028  /* api callbacks */
4029  ot->poll = tile_add_poll;
4030  ot->exec = tile_add_exec;
4032  ot->ui = tile_add_draw;
4033 
4034  /* flags */
4036 
4037  RNA_def_int(ot->srna,
4038  "number",
4039  1002,
4040  1001,
4041  IMA_UDIM_MAX,
4042  "Number",
4043  "UDIM number of the tile",
4044  1001,
4045  1099);
4046  RNA_def_int(ot->srna, "count", 1, 1, INT_MAX, "Count", "How many tiles to add", 1, 1000);
4047  RNA_def_string(ot->srna, "label", NULL, 0, "Label", "Optional tile label");
4048  RNA_def_boolean(ot->srna, "fill", true, "Fill", "Fill new tile with a generated image");
4049  def_fill_tile(ot->srna);
4050 }
4051 
4054 /* -------------------------------------------------------------------- */
4059 {
4060  Image *ima = CTX_data_edit_image(C);
4061 
4062  return (ima != NULL && ima->source == IMA_SRC_TILED && !BLI_listbase_is_single(&ima->tiles));
4063 }
4064 
4066 {
4067  Image *ima = CTX_data_edit_image(C);
4068 
4070  if (!BKE_image_remove_tile(ima, tile)) {
4071  return OPERATOR_CANCELLED;
4072  }
4073 
4074  /* Ensure that the active index is valid. */
4076 
4078 
4079  return OPERATOR_FINISHED;
4080 }
4081 
4083 {
4084  /* identifiers */
4085  ot->name = "Remove Tile";
4086  ot->description = "Removes a tile from the image";
4087  ot->idname = "IMAGE_OT_tile_remove";
4088 
4089  /* api callbacks */
4092 
4093  /* flags */
4095 }
4096 
4099 /* -------------------------------------------------------------------- */
4104 {
4105  Image *ima = CTX_data_edit_image(C);
4106 
4107  if (ima != NULL && ima->source == IMA_SRC_TILED) {
4108  /* Filling secondary tiles is only allowed if the primary tile exists. */
4109  return (ima->active_tile_index == 0) || BKE_image_has_ibuf(ima, NULL);
4110  }
4111  return false;
4112 }
4113 
4115 {
4116  Image *ima = CTX_data_edit_image(C);
4117 
4119  if (!do_fill_tile(op->ptr, ima, tile)) {
4120  return OPERATOR_CANCELLED;
4121  }
4122 
4124 
4125  return OPERATOR_FINISHED;
4126 }
4127 
4128 static int tile_fill_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
4129 {
4131 
4132  return WM_operator_props_dialog_popup(C, op, 300);
4133 }
4134 
4136 {
4137  draw_fill_tile(op->ptr, op->layout);
4138 }
4139 
4141 {
4142  /* identifiers */
4143  ot->name = "Fill Tile";
4144  ot->description = "Fill the current tile with a generated image";
4145  ot->idname = "IMAGE_OT_tile_fill";
4146 
4147  /* api callbacks */
4148  ot->poll = tile_fill_poll;
4149  ot->exec = tile_fill_exec;
4151  ot->ui = tile_fill_draw;
4152 
4153  /* flags */
4155 
4156  def_fill_tile(ot->srna);
4157 }
4158 
typedef float(TangentPoint)[2]
void BKE_histogram_update_sample_line(struct Histogram *hist, struct ImBuf *ibuf, const struct ColorManagedViewSettings *view_settings, const struct ColorManagedDisplaySettings *display_settings)
struct ScrArea * CTX_wm_area(const bContext *C)
Definition: context.c:738
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1090
struct Object * CTX_data_edit_object(const bContext *C)
Definition: context.c:1370
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:713
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
Definition: context.c:473
struct ViewLayer * CTX_data_view_layer(const bContext *C)
Definition: context.c:1100
struct Image * CTX_data_edit_image(const bContext *C)
Definition: context.c:1375
struct ARegion * CTX_wm_region(const bContext *C)
Definition: context.c:749
void CTX_wm_operator_poll_msg_set(struct bContext *C, const char *msg)
Definition: context.c:1042
struct SpaceImage * CTX_wm_space_image(const bContext *C)
Definition: context.c:824
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1074
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:723
@ G_FILE_AUTOPACK
Definition: BKE_global.h:209
void BKE_icon_changed(int icon_id)
Definition: icons.cc:637
int BKE_icon_id_ensure(struct ID *id)
Definition: icons.cc:699
bool BKE_image_remove_renderslot(struct Image *ima, struct ImageUser *iuser, int slot)
bool BKE_image_remove_tile(struct Image *ima, struct ImageTile *tile)
void BKE_image_release_ibuf(struct Image *ima, struct ImBuf *ibuf, void *lock)
void BKE_image_sort_tiles(struct Image *ima)
void BKE_image_user_file_path(const struct ImageUser *iuser, const struct Image *ima, char *path)
bool BKE_image_has_ibuf(struct Image *ima, struct ImageUser *iuser)
struct ImBuf * BKE_image_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, void **r_lock)
struct RenderSlot * BKE_image_add_renderslot(struct Image *ima, const char *name)
bool BKE_image_is_multiview(const struct Image *ima)
struct Image * BKE_image_add_generated(struct Main *bmain, unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short gen_type, const float color[4], bool stereo3d, bool is_data, bool tiled)
#define IMA_UDIM_MAX
Definition: BKE_image.h:36
void BKE_image_partial_update_mark_full_update(struct Image *image)
Mark the whole image to be updated.
bool BKE_image_has_filepath(const struct Image *ima)
void BKE_image_packfiles(struct ReportList *reports, struct Image *ima, const char *basepath)
bool BKE_image_is_dirty_writable(struct Image *image, bool *r_is_writable)
bool BKE_image_memorypack(struct Image *ima)
bool BKE_image_clear_renderslot(struct Image *ima, struct ImageUser *iuser, int slot)
struct Image * BKE_image_ensure_viewer(struct Main *bmain, int type, const char *name)
void BKE_image_mark_dirty(struct Image *image, struct ImBuf *ibuf)
bool BKE_image_has_packedfile(const struct Image *image)
#define IMA_SIGNAL_SRC_CHANGE
Definition: BKE_image.h:132
bool BKE_image_has_anim(struct Image *image)
void BKE_image_ensure_tile_token(char *filename)
#define IMA_SIGNAL_USER_NEW_IMAGE
Definition: BKE_image.h:134
bool BKE_image_is_dirty(struct Image *image)
#define IMA_SIGNAL_RELOAD
Definition: BKE_image.h:129
void BKE_image_signal(struct Main *bmain, struct Image *ima, struct ImageUser *iuser, int signal)
int BKE_image_get_tile_from_pos(struct Image *ima, const float uv[2], float r_uv[2], float r_ofs[2])
bool BKE_image_buffer_format_writable(struct ImBuf *ibuf)
void BKE_image_free_views(struct Image *image)
void BKE_image_init_imageuser(struct Image *ima, struct ImageUser *iuser)
void BKE_image_free_packedfiles(struct Image *image)
bool BKE_image_fill_tile(struct Image *ima, struct ImageTile *tile, int width, int height, const float color[4], int gen_type, int planes, bool is_float)
struct ImageTile * BKE_image_add_tile(struct Image *ima, int tile_number, const char *label)
struct Image * BKE_image_load_exists_ex(struct Main *bmain, const char *filepath, bool *r_exists)
void BKE_image_user_frame_calc(struct Image *ima, struct ImageUser *iuser, int cfra)
void BKE_imageuser_default(struct ImageUser *iuser)
struct RenderSlot * BKE_image_get_renderslot(struct Image *ima, int index)
bool BKE_image_save(struct ReportList *reports, struct Main *bmain, struct Image *ima, struct ImageUser *iuser, const struct ImageSaveOptions *opts)
void BKE_image_save_options_update(struct ImageSaveOptions *opts, const struct Image *ima)
bool BKE_image_save_options_init(ImageSaveOptions *opts, struct Main *bmain, struct Scene *scene, struct Image *ima, struct ImageUser *iuser, const bool guess_path, const bool save_as_render)
Definition: image_save.cc:76
void BKE_image_save_options_free(struct ImageSaveOptions *opts)
Definition: image_save.cc:241
#define BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, v3d, r_len)
Definition: BKE_layer.h:550
void id_us_min(struct ID *id)
Definition: lib_id.c:313
const char * BKE_main_blendfile_path(const struct Main *bmain) ATTR_NONNULL()
int BKE_packedfile_unpack_image(struct Main *bmain, struct ReportList *reports, struct Image *ima, enum ePF_FileStatus how)
Definition: packedFile.c:620
@ PF_USE_LOCAL
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_reports_clear(ReportList *reports)
Definition: report.c:63
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition: report.c:83
void BKE_reports_init(ReportList *reports, int flag)
Definition: report.c:50
void BKE_render_resolution(const struct RenderData *r, const bool use_crop, int *r_width, int *r_height)
Definition: scene.cc:2960
File and directory operations.
int BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: storage.c:314
bool BLI_file_is_writable(const char *filepath) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: fileops.c:167
GSet * BLI_gset_str_new(const char *info)
struct GSet GSet
Definition: BLI_ghash.h:340
bool BLI_gset_haskey(const GSet *gs, const void *key) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.c:1007
void BLI_gset_insert(GSet *gs, void *key)
Definition: BLI_ghash.c:962
void BLI_gset_free(GSet *gs, GSetKeyFreeFP keyfreefp)
Definition: BLI_ghash.c:1037
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
Definition: BLI_listbase.h:269
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:336
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:466
void void BLI_INLINE bool BLI_listbase_is_single(const struct ListBase *lb)
Definition: BLI_listbase.h:265
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findstring(const struct ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int round_fl_to_int(float a)
MINLINE int min_ii(int a, int b)
MINLINE float min_ff(float a, float b)
MINLINE int max_ii(int a, int b)
MINLINE float power_of_2(float f)
void rgb_uchar_to_float(float r_col[3], const unsigned char col_ub[3])
Definition: math_color.c:376
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE void sub_v2_v2(float r[2], const float a[2])
MINLINE void copy_v4_v4_char(char r[4], const char a[4])
MINLINE void mul_v2_fl(float r[2], float f)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
bool BLI_path_extension_check_array(const char *str, const char **ext_array) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
Definition: path_util.c:1326
void BLI_split_dir_part(const char *string, char *dir, size_t dirlen)
Definition: path_util.c:1490
const char * BLI_path_basename(const char *path) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
Definition: path_util.c:1653
bool BLI_path_is_rel(const char *path) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
Definition: path_util.c:347
#define FILE_MAX
void BLI_path_rel(char *file, const char *relfile) ATTR_NONNULL()
Definition: path_util.c:450
const char * BLI_path_slash_rfind(const char *string) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
Definition: path_util.c:1765
bool BLI_path_abs(char *path, const char *basepath) ATTR_NONNULL()
Definition: path_util.c:897
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition: BLI_rect.h:190
BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
Definition: BLI_rect.h:181
BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct)
Definition: BLI_rect.h:177
void BLI_rctf_scale(rctf *rect, float scale)
Definition: rct.c:655
void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax)
Definition: rct.c:407
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition: BLI_rect.h:186
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition: BLI_rect.h:194
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
Definition: BLI_rect.h:198
#define STR_ELEM(...)
Definition: BLI_string.h:539
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
Definition: string.c:42
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string.c:64
unsigned char uchar
Definition: BLI_sys_types.h:70
unsigned int uint
Definition: BLI_sys_types.h:67
#define CLAMP_MAX(a, c)
#define UNUSED(x)
#define POINTER_AS_INT(i)
#define ELEM(...)
#define STREQ(a, b)
#define TIP_(msgid)
#define IFACE_(msgid)
#define DATA_(msgid)
void DEG_id_tag_update(struct ID *id, int flag)
@ ID_RECALC_COPY_ON_WRITE
Definition: DNA_ID.h:834
@ ID_RECALC_FRAME_CHANGE
Definition: DNA_ID.h:841
#define ID_IS_LINKED(_id)
Definition: DNA_ID.h:566
#define MAX_ID_NAME
Definition: DNA_ID.h:337
#define ID_BLEND_PATH(_bmain, _id)
Definition: DNA_ID.h:559
@ ID_IM
Definition: DNA_ID_enums.h:53
@ HISTO_FLAG_SAMPLELINE
@ IMA_GENTYPE_BLANK
@ IMA_USE_VIEWS
@ IMA_SRC_FILE
@ IMA_SRC_MOVIE
@ IMA_SRC_GENERATED
@ IMA_SRC_VIEWER
@ IMA_SRC_TILED
@ IMA_SRC_SEQUENCE
@ IMA_TYPE_MULTILAYER
@ IMA_TYPE_R_RESULT
@ IMA_TYPE_COMPOSITE
Object is a sort of wrapper for general info.
#define R_BORDER
#define R_MULTIVIEW
#define R_CROP
#define MINAFRAME
#define MAXFRAME
@ RGN_TYPE_WINDOW
@ FILE_SORT_DEFAULT
@ FILE_SPECIAL
@ FILE_TYPE_MOVIE
@ FILE_TYPE_FOLDER
@ FILE_TYPE_IMAGE
@ SPACE_IMAGE
@ FILE_DEFAULTDISPLAY
@ SI_MODE_PAINT
#define FRAMENUMBER_MIN_CLAMP(cfra)
@ USER_ZOOM_INVERT
@ USER_ZOOM_TO_MOUSEPOS
@ USER_ZOOM_HORIZ
#define NDOF_PIXELS_PER_SECOND
@ USER_ZOOM_SCALE
@ USER_ZOOM_CONTINUE
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
@ OPERATOR_RUNNING_MODAL
@ OPERATOR_PASS_THROUGH
void ED_space_image_release_buffer(struct SpaceImage *sima, struct ImBuf *ibuf, void *lock)
Definition: image_edit.c:158
bool ED_space_image_check_show_maskedit(struct SpaceImage *sima, struct Object *obedit)
Definition: image_edit.c:458
bool ED_space_image_has_buffer(struct SpaceImage *sima)
Definition: image_edit.c:188
bool ED_space_image_show_uvedit(const struct SpaceImage *sima, struct Object *obedit)
struct Image * ED_space_image(const struct SpaceImage *sima)
ListBase ED_image_filesel_detect_sequences(struct Main *bmain, struct wmOperator *op, bool detect_udim)
void ED_image_view_center_to_point(struct SpaceImage *sima, float x, float y)
Definition: image_edit.c:313
bool ED_space_image_show_cache_and_mval_over(const struct SpaceImage *sima, struct ARegion *region, const int mval[2])
void ED_space_image_set(struct Main *bmain, struct SpaceImage *sima, struct Image *ima, bool automatic)
Definition: image_edit.c:45
bool ED_image_slot_cycle(struct Image *image, int direction)
Definition: image_edit.c:357
void ED_space_image_get_size(struct SpaceImage *sima, int *r_width, int *r_height)
Definition: image_edit.c:201
void ED_space_image_get_aspect(struct SpaceImage *sima, float *r_aspx, float *r_aspy)
Definition: image_edit.c:236
struct ImBuf * ED_space_image_acquire_buffer(struct SpaceImage *sima, void **r_lock, int tile)
Definition: image_edit.c:118
bool ED_space_image_cursor_poll(struct bContext *C)
Definition: image_edit.c:526
bool ED_maskedit_poll(struct bContext *C)
Definition: mask_edit.c:29
bool ED_mask_selected_minmax(const struct bContext *C, float min[2], float max[2], bool handles_as_control_point)
void ED_imapaint_clear_partial_redraw(void)
Definition: paint_image.cc:91
void ED_image_undo_push_end(void)
Definition: image_undo.cc:1133
void ED_image_undo_push_begin_with_image(const char *name, struct Image *image, struct ImBuf *ibuf, struct ImageUser *iuser)
Definition: image_undo.cc:1100
void ED_preview_kill_jobs(struct wmWindowManager *wm, struct Main *bmain)
void ED_area_tag_redraw(ScrArea *area)
Definition: area.c:729
void ED_region_tag_redraw(struct ARegion *region)
Definition: area.c:655
bool ED_operator_uvedit(struct bContext *C)
Definition: screen_ops.c:557
void unpack_menu(struct bContext *C, const char *opname, const char *id_name, const char *abs_name, const char *folder, struct PackedFile *pf)
Definition: ed_util.c:357
int ED_imbuf_sample_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event)
bool ED_imbuf_sample_poll(struct bContext *C)
void ED_imbuf_sample_cancel(struct bContext *C, struct wmOperator *op)
int ED_imbuf_sample_modal(struct bContext *C, struct wmOperator *op, const struct wmEvent *event)
bool ED_uvedit_minmax_multi(const struct Scene *scene, struct Object **objects_edit, uint objects_len, float r_min[2], float r_max[2])
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], struct ColorSpace *colorspace)
bool IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy)
Definition: scaling.c:1644
void IMB_rect_from_float(struct ImBuf *ibuf)
Definition: divers.c:696
bool IMB_saveiff(struct ImBuf *ibuf, const char *filepath, int flags)
Definition: writeimage.c:22
int IMB_anim_get_duration(struct anim *anim, IMB_Timecode_Type tc)
Definition: anim_movie.c:1658
@ IMB_TC_RECORD_RUN
Definition: IMB_imbuf.h:324
Contains defines and structs used throughout the imbuf module.
@ IMB_COLORMANAGE_IS_DATA
@ IB_BITMAPDIRTY
@ IB_MIPMAP_INVALID
@ IB_DISPLAY_BUFFER_INVALID
const char * imb_ext_movie[]
Definition: util.c:81
@ IB_zbuf
@ IB_zbuffloat
@ IB_rect
void IMB_moviecacheIter_free(struct MovieCacheIter *iter)
Definition: moviecache.cc:585
struct MovieCacheIter * IMB_moviecacheIter_new(struct MovieCache *cache)
Definition: moviecache.cc:575
bool IMB_moviecacheIter_done(struct MovieCacheIter *iter)
Definition: moviecache.cc:590
void IMB_moviecacheIter_step(struct MovieCacheIter *iter)
Definition: moviecache.cc:595
struct ImBuf * IMB_moviecacheIter_getImBuf(struct MovieCacheIter *iter)
Definition: moviecache.cc:600
Read Guarded memory(de)allocation.
#define MEM_SAFE_FREE(v)
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position CLAMP
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block TEX_IMAGE
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
Platform independent time functions.
void StructOrFunctionRNA
Definition: RNA_define.h:82
@ PROP_SKIP_SAVE
Definition: RNA_types.h:218
@ PROP_HIDDEN
Definition: RNA_types.h:216
@ PROP_PIXEL
Definition: RNA_types.h:141
@ PROP_COLOR_GAMMA
Definition: RNA_types.h:165
#define C
Definition: RandGen.cpp:25
uiLayout * uiLayoutColumn(uiLayout *layout, bool align)
void uiItemL(uiLayout *layout, const char *name, int icon)
void uiTemplateImageSettings(uiLayout *layout, struct PointerRNA *imfptr, bool color_management)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
void uiItemS(uiLayout *layout)
@ UI_BUT_LABEL_ALIGN_NONE
void UI_context_active_but_prop_get_templateID(struct bContext *C, struct PointerRNA *r_ptr, struct PropertyRNA **r_prop)
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
void uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep)
eAutoPropButsReturn uiDefAutoButsRNA(uiLayout *layout, struct PointerRNA *ptr, bool(*check_prop)(struct PointerRNA *ptr, struct PropertyRNA *prop, void *user_data), void *user_data, struct PropertyRNA *prop_activate_init, eButLabelAlign label_align, bool compact)
void uiTemplateImageFormatViews(uiLayout *layout, struct PointerRNA *imfptr, struct PointerRNA *ptr)
void UI_view2d_region_to_view_rctf(const struct View2D *v2d, const struct rctf *rect_src, struct rctf *rect_dst) ATTR_NONNULL()
void UI_view2d_region_to_view(const struct View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
@ WM_FILESEL_FILES
Definition: WM_api.h:756
@ WM_FILESEL_DIRECTORY
Definition: WM_api.h:753
@ WM_FILESEL_RELPATH
Definition: WM_api.h:752
@ WM_FILESEL_SHOW_PROPS
Definition: WM_api.h:758
@ WM_FILESEL_FILEPATH
Definition: WM_api.h:755
@ FILE_OPENFILE
Definition: WM_api.h:764
@ FILE_SAVE
Definition: WM_api.h:765
@ KM_RELEASE
Definition: WM_types.h:268
@ OPTYPE_INTERNAL
Definition: WM_types.h:168
@ OPTYPE_BLOCKING
Definition: WM_types.h:150
@ OPTYPE_LOCK_BYPASS
Definition: WM_types.h:171
@ OPTYPE_UNDO
Definition: WM_types.h:148
@ OPTYPE_GRAB_CURSOR_XY
Definition: WM_types.h:154
@ OPTYPE_REGISTER
Definition: WM_types.h:146
#define ND_DRAW
Definition: WM_types.h:410
#define ND_RENDER_OPTIONS
Definition: WM_types.h:383
#define NC_SCENE
Definition: WM_types.h:328
#define NA_ADDED
Definition: WM_types.h:525
#define ND_SPACE_IMAGE
Definition: WM_types.h:465
#define NA_EDITED
Definition: WM_types.h:523
#define NC_IMAGE
Definition: WM_types.h:334
#define ND_FRAME
Definition: WM_types.h:382
@ WM_OP_INVOKE_DEFAULT
Definition: WM_types.h:201
@ WM_OP_EXEC_DEFAULT
Definition: WM_types.h:208
@ KM_ALT
Definition: WM_types.h:240
@ KM_SHIFT
Definition: WM_types.h:238
#define NC_SPACE
Definition: WM_types.h:342
volatile int lock
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
Definition: btDbvt.cpp:299
unsigned int U
Definition: btGjkEpa3.h:78
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
struct ListBase packedfiles
short last_render_slot
ListBase anims
ListBase renderslots
char views_format
char filepath[1024]
ListBase tiles
short type
short source
short render_slot
struct Stereo3dFormat * stereo3d_format
int active_tile_index
#define powf(x, y)
Definition: cuda/compat.h:103
OperationNode * node
double time
const char * label
Scene scene
void * user_data
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img image(1, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D_ARRAY, "out_weight_img") .image(3
RenderData * RE_engine_get_render_data(Render *re)
Definition: engine.c:690
#define str(s)
uint col
static int image_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
Definition: image_ops.c:1946
void IMAGE_OT_view_cursor_center(wmOperatorType *ot)
Definition: image_ops.c:870
static bool tile_remove_poll(bContext *C)
Definition: image_ops.c:4058
void IMAGE_OT_change_frame(wmOperatorType *ot)
Definition: image_ops.c:3673
int ED_image_save_all_modified_info(const Main *bmain, ReportList *reports)
Definition: image_ops.c:2328
static void image_filesel(bContext *C, wmOperator *op, const char *path)
Definition: image_ops.c:1223
void IMAGE_OT_save_sequence(wmOperatorType *ot)
Definition: image_ops.c:2267
static bool save_image_op(Main *bmain, Image *ima, ImageUser *iuser, wmOperator *op, const ImageSaveOptions *opts)
Definition: image_ops.c:1833
static bool image_has_valid_path(Image *ima)
Definition: image_ops.c:2302
void IMAGE_OT_view_zoom(wmOperatorType *ot)
Definition: image_ops.c:706
static int tile_fill_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
Definition: image_ops.c:4128
static bool image_should_be_saved(Image *ima, bool *is_format_writable)
Definition: image_ops.c:2293
void IMAGE_OT_cycle_render_slot(wmOperatorType *ot)
Definition: image_ops.c:3451
static int image_scale_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:2965
void IMAGE_OT_match_movie_length(wmOperatorType *ot)
Definition: image_ops.c:1702
static int image_open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
Definition: image_ops.c:1424
void IMAGE_OT_save_all_modified(wmOperatorType *ot)
Definition: image_ops.c:2426
void IMAGE_OT_save_as(wmOperatorType *ot)
Definition: image_ops.c:2032
static void image_save_options_from_op(Main *bmain, ImageSaveOptions *opts, wmOperator *op)
Definition: image_ops.c:1818
static int image_sample_line_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: image_ops.c:3346
static bool image_view_selected_poll(bContext *C)
Definition: image_ops.c:973
void IMAGE_OT_sample(wmOperatorType *ot)
Definition: image_ops.c:3266
static int image_new_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
Definition: image_ops.c:2603
static int image_save_sequence_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:2192
static void sima_zoom_set_factor(SpaceImage *sima, ARegion *region, float zoomfac, const float location[2], const bool zoom_to_pos)
Definition: image_ops.c:134
static int change_frame_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: image_ops.c:3630
static void image_view_pan_exit(bContext *C, wmOperator *op, bool cancel)
Definition: image_ops.c:381
static int image_view_zoom_in_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: image_ops.c:1012
#define IMA_DEF_NAME
Definition: image_ops.c:2488
bool ED_image_should_save_modified(const Main *bmain)
Definition: image_ops.c:2315
static void image_view_zoom_cancel(bContext *C, wmOperator *op)
Definition: image_ops.c:701
static void def_fill_tile(StructOrFunctionRNA *srna)
Definition: image_ops.c:3903
static Image * image_from_context(const bContext *C)
Definition: image_ops.c:171
void IMAGE_OT_tile_fill(wmOperatorType *ot)
Definition: image_ops.c:4140
static bool tile_add_poll(bContext *C)
Definition: image_ops.c:3928
bool ED_space_image_get_position(SpaceImage *sima, struct ARegion *region, int mval[2], float fpos[2])
Definition: image_ops.c:3196
static int image_view_zoom_out_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:1055
void IMAGE_OT_remove_render_slot(wmOperatorType *ot)
Definition: image_ops.c:3556
static void image_save_as_draw(bContext *UNUSED(C), wmOperator *op)
Definition: image_ops.c:1979
static bool image_save_as_check(bContext *C, wmOperator *op)
Definition: image_ops.c:1935
static void image_view_all(struct SpaceImage *sima, struct ARegion *region, struct wmOperator *op)
Definition: image_ops.c:256
static bool image_from_context_has_data_poll_active_tile(bContext *C)
Definition: image_ops.c:241
static bool do_fill_tile(PointerRNA *ptr, Image *ima, ImageTile *tile)
Definition: image_ops.c:3849
static bool image_save_as_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop, void *UNUSED(user_data))
Definition: image_ops.c:1967
static int image_file_browse_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:1564
static int image_view_zoom_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:568
void IMAGE_OT_view_zoom_border(wmOperatorType *ot)
Definition: image_ops.c:1203
static int image_sample_line_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:3294
static int image_view_zoom_in_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:996
static int image_replace_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
Definition: image_ops.c:1760
@ GEN_CONTEXT_NONE
Definition: image_ops.c:2491
@ GEN_CONTEXT_PAINT_CANVAS
Definition: image_ops.c:2492
@ GEN_CONTEXT_PAINT_STENCIL
Definition: image_ops.c:2493
static int tile_remove_exec(bContext *C, wmOperator *UNUSED(op))
Definition: image_ops.c:4065
static int image_open_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:1318
static bool image_from_context_has_data_poll(bContext *C)
Definition: image_ops.c:222
static bool tile_fill_poll(bContext *C)
Definition: image_ops.c:4103
static void image_save_as_cancel(bContext *UNUSED(C), wmOperator *op)
Definition: image_ops.c:1962
static int image_match_len_exec(bContext *C, wmOperator *UNUSED(op))
Definition: image_ops.c:1673
void IMAGE_OT_reload(wmOperatorType *ot)
Definition: image_ops.c:2468
static int image_save_as_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:1906
void IMAGE_OT_unpack(wmOperatorType *ot)
Definition: image_ops.c:3168
void IMAGE_OT_view_selected(wmOperatorType *ot)
Definition: image_ops.c:978
void IMAGE_OT_tile_add(wmOperatorType *ot)
Definition: image_ops.c:4021
static void image_open_draw(bContext *UNUSED(C), wmOperator *op)
Definition: image_ops.c:1491
void IMAGE_OT_pack(wmOperatorType *ot)
Definition: image_ops.c:3072
void IMAGE_OT_open(wmOperatorType *ot)
Definition: image_ops.c:1518
@ VIEW_CONFIRM
Definition: image_ops.c:583
@ VIEW_PASS
Definition: image_ops.c:581
@ VIEW_APPLY
Definition: image_ops.c:582
static int image_add_render_slot_exec(bContext *C, wmOperator *UNUSED(op))
Definition: image_ops.c:3509
void IMAGE_OT_read_viewlayers(wmOperatorType *ot)
Definition: image_ops.c:3713
static void image_operator_prop_allow_tokens(wmOperatorType *ot)
Definition: image_ops.c:1511
static bool image_save_as_poll(bContext *C)
Definition: image_ops.c:2013
static int image_clear_render_slot_exec(bContext *C, wmOperator *UNUSED(op))
Definition: image_ops.c:3474
void IMAGE_OT_invert(wmOperatorType *ot)
Definition: image_ops.c:2918
void IMAGE_OT_resize(wmOperatorType *ot)
Definition: image_ops.c:3010
void IMAGE_OT_clear_render_slot(wmOperatorType *ot)
Definition: image_ops.c:3488
static int image_view_zoom_ratio_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:1120
void IMAGE_OT_view_zoom_in(wmOperatorType *ot)
Definition: image_ops.c:1024
void IMAGE_OT_view_zoom_out(wmOperatorType *ot)
Definition: image_ops.c:1083
static int image_file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: image_ops.c:1591
static int image_cycle_render_slot_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:3431
void IMAGE_OT_view_all(wmOperatorType *ot)
Definition: image_ops.c:824
void IMAGE_OT_render_border(wmOperatorType *ot)
Definition: image_ops.c:3792
void IMAGE_OT_view_pan(wmOperatorType *ot)
Definition: image_ops.c:461
static void image_open_cancel(bContext *UNUSED(C), wmOperator *op)
Definition: image_ops.c:1249
static int image_invert_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:2827
static int frame_from_event(bContext *C, const wmEvent *event)
Definition: image_ops.c:3608
struct ImageNewData ImageNewData
struct ViewZoomData ViewZoomData
static void draw_fill_tile(PointerRNA *ptr, uiLayout *layout)
Definition: image_ops.c:3862
static int image_reload_exec(bContext *C, wmOperator *UNUSED(op))
Definition: image_ops.c:2447
static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
Definition: image_ops.c:924
struct ImageSaveData ImageSaveData
static int image_view_zoom_out_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: image_ops.c:1071
static int image_view_zoom_border_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:1168
static ImageNewData * image_new_init(bContext *C, wmOperator *op)
Definition: image_ops.c:2500
static Image * image_open_single(Main *bmain, wmOperator *op, ImageFrameRange *range, const char *relbase, bool is_relative_path, bool use_multiview)
Definition: image_ops.c:1255
static void image_view_zoom_init(bContext *C, wmOperator *op, const wmEvent *event)
Definition: image_ops.c:513
static bool image_not_packed_poll(bContext *C)
Definition: image_ops.c:249
static void image_new_draw(bContext *UNUSED(C), wmOperator *op)
Definition: image_ops.c:2615
static int image_unpack_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
Definition: image_ops.c:3133
static void image_save_as_free(wmOperator *op)
Definition: image_ops.c:1895
static int change_frame_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:3601
static bool image_file_format_writable(Image *ima, ImageUser *iuser)
Definition: image_ops.c:2084
static bool image_should_be_saved_when_modified(Image *ima)
Definition: image_ops.c:2288
void IMAGE_OT_save(wmOperatorType *ot)
Definition: image_ops.c:2170
static int image_view_all_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:808
void IMAGE_OT_file_browse(wmOperatorType *ot)
Definition: image_ops.c:1640
static void image_view_pan_init(bContext *C, wmOperator *op, const wmEvent *event)
Definition: image_ops.c:358
static void image_view_zoom_exit(bContext *C, wmOperator *op, bool cancel)
Definition: image_ops.c:548
static int tile_fill_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:4114
static bool image_cycle_render_slot_poll(bContext *C)
Definition: image_ops.c:3424
static int image_view_pan_modal(bContext *C, wmOperator *op, const wmEvent *event)
Definition: image_ops.c:430
static void image_new_cancel(bContext *UNUSED(C), wmOperator *op)
Definition: image_ops.c:2647
static int image_save_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: image_ops.c:2156
void IMAGE_OT_add_render_slot(wmOperatorType *ot)
Definition: image_ops.c:3521
void IMAGE_OT_tile_remove(wmOperatorType *ot)
Definition: image_ops.c:4082
static int render_border_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:3732
struct ViewPanData ViewPanData
static void image_open_init(bContext *C, wmOperator *op)
Definition: image_ops.c:1241
static void tile_fill_init(PointerRNA *ptr, Image *ima, ImageTile *tile)
Definition: image_ops.c:3876
static int image_view_pan_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:398
static int image_save_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:2113
static int image_scale_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
Definition: image_ops.c:2951
static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event)
Definition: image_ops.c:3651
bool space_image_main_region_poll(bContext *C)
Definition: image_ops.c:320
static int view_center_cursor_exec(bContext *C, wmOperator *UNUSED(op))
Definition: image_ops.c:894
static ImageSaveData * image_save_as_init(bContext *C, wmOperator *op)
Definition: image_ops.c:1850
static int image_view_pan_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: image_ops.c:412
static int clear_render_border_exec(bContext *C, wmOperator *UNUSED(op))
Definition: image_ops.c:3819
static int tile_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
Definition: image_ops.c:3978
static void tile_add_draw(bContext *UNUSED(C), wmOperator *op)
Definition: image_ops.c:4002
void IMAGE_OT_flip(wmOperatorType *ot)
Definition: image_ops.c:2798
static bool image_save_all_modified_poll(bContext *C)
Definition: image_ops.c:2414
static void tile_fill_draw(bContext *UNUSED(C), wmOperator *op)
Definition: image_ops.c:4135
static bool image_open_draw_check_prop(PointerRNA *UNUSED(ptr), PropertyRNA *prop, void *UNUSED(user_data))
Definition: image_ops.c:1482
static bool image_should_pack_during_save_all(const Image *ima)
Definition: image_ops.c:2307
void IMAGE_OT_sample_line(wmOperatorType *ot)
Definition: image_ops.c:3360
void IMAGE_OT_replace(wmOperatorType *ot)
Definition: image_ops.c:1781
static void sima_zoom_set_from_bounds(SpaceImage *sima, ARegion *region, const rctf *bounds)
Definition: image_ops.c:146
static int image_read_viewlayers_exec(bContext *C, wmOperator *UNUSED(op))
Definition: image_ops.c:3695
static int image_new_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:2517
static bool change_frame_poll(bContext *C)
Definition: image_ops.c:3577
struct ImageOpenData ImageOpenData
static bool image_save_poll(bContext *C)
Definition: image_ops.c:2098
static void image_view_pan_cancel(bContext *C, wmOperator *op)
Definition: image_ops.c:456
static void sima_zoom_set(SpaceImage *sima, ARegion *region, float zoom, const float location[2], const bool zoom_to_pos)
Definition: image_ops.c:94
static int image_unpack_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:3092
static int image_view_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: image_ops.c:586
static int image_replace_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:1723
void IMAGE_OT_view_center_cursor(wmOperatorType *ot)
Definition: image_ops.c:906
bool ED_image_save_all_modified(const bContext *C, ReportList *reports)
Definition: image_ops.c:2383
void IMAGE_OT_view_zoom_ratio(wmOperatorType *ot)
Definition: image_ops.c:1136
static int image_save_all_modified_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:2420
static int image_pack_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:3051
static ImageUser image_user_from_context_and_active_tile(const bContext *C, Image *ima)
Definition: image_ops.c:201
void IMAGE_OT_new(wmOperatorType *ot)
Definition: image_ops.c:2652
static int image_view_zoom_modal(bContext *C, wmOperator *op, const wmEvent *event)
Definition: image_ops.c:666
static void change_frame_apply(bContext *C, wmOperator *op)
Definition: image_ops.c:3587
static int view_cursor_center_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:851
bool ED_space_image_color_sample(SpaceImage *sima, ARegion *region, const int mval[2], float r_col[3], bool *r_is_data)
Definition: image_ops.c:3215
static bool image_file_browse_poll(bContext *C)
Definition: image_ops.c:1635
static void image_new_free(wmOperator *op)
Definition: image_ops.c:2512
void IMAGE_OT_clear_render_border(wmOperatorType *ot)
Definition: image_ops.c:3828
static bool space_image_main_area_not_uv_brush_poll(bContext *C)
Definition: image_ops.c:332
static int tile_add_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:3935
static bool image_pack_test(bContext *C, wmOperator *op)
Definition: image_ops.c:3035
void IMAGE_OT_curves_point_set(wmOperatorType *ot)
Definition: image_ops.c:3386
static ImageUser * image_user_from_context(const bContext *C)
Definition: image_ops.c:186
static int image_flip_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:2706
static void image_zoom_apply(ViewZoomData *vpd, wmOperator *op, const int x, const int y, const short viewzoom, const short zoom_invert, const bool zoom_to_pos)
Definition: image_ops.c:619
static int image_remove_render_slot_exec(bContext *C, wmOperator *UNUSED(op))
Definition: image_ops.c:3542
IconTextureDrawCall border
#define GS(x)
Definition: iris.c:225
ccl_global const KernelWorkTile * tile
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_dupallocN)(const void *vmemh)
Definition: mallocn.c:28
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
#define G(x, y, z)
#define ceilf(x)
Definition: metal/compat.h:225
#define floorf(x)
Definition: metal/compat.h:224
static unsigned a[3]
Definition: RandGen.cpp:78
static void area(int d1, int d2, int e1, int e2, float weights[2])
bool active
all scheduled work for the GPU.
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
static const pxr::TfToken g("g", pxr::TfToken::Immortal)
Render * RE_GetSceneRender(const Scene *scene)
Definition: pipeline.c:551
bool RE_ReadRenderResult(Scene *scene, Scene *scenode)
Definition: pipeline.c:2447
return ret
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
Definition: rna_access.c:136
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
Definition: rna_access.c:5155
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:5167
void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
Definition: rna_access.c:112
const char * RNA_property_identifier(const PropertyRNA *prop)
Definition: rna_access.c:1000
void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA ptr_value, ReportList *reports)
Definition: rna_access.c:3532
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
Definition: rna_access.c:4874
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:5271
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
Definition: rna_access.c:4921
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:3493
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:717
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
Definition: rna_access.c:4980
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:2138
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
Definition: rna_access.c:5116
int RNA_int_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4910
void RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop, char *value)
Definition: rna_access.c:3149
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
Definition: rna_access.c:2180
float RNA_float_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4957
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
Definition: rna_access.c:4968
char * RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen, int *r_len)
Definition: rna_access.c:5129
void RNA_property_int_set_array(PointerRNA *ptr, PropertyRNA *prop, const int *values)
Definition: rna_access.c:2605
void RNA_property_int_get_array(PointerRNA *ptr, PropertyRNA *prop, int *values)
Definition: rna_access.c:2512
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:5301
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4863
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
Definition: rna_access.c:4992
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:5004
void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value)
Definition: rna_access.c:3239
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:3836
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3493
PropertyRNA * RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:3862
PropertyRNA * RNA_def_int_vector(StructOrFunctionRNA *cont_, const char *identifier, int len, const int *default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
Definition: rna_define.c:3623
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3687
PropertyRNA * RNA_def_float_color(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:3922
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1490
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
Definition: rna_define.c:3597
void RNA_def_property_subtype(PropertyRNA *prop, PropertySubType subtype)
Definition: rna_define.c:1534
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3783
void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array)
Definition: rna_define.c:2043
const EnumPropertyItem rna_enum_image_generated_type_items[]
Definition: rna_image.c:31
const EnumPropertyItem rna_enum_unpack_method_items[]
#define min(a, b)
Definition: sort.c:35
short regiontype
struct ListBase bg_images
float co[2][2]
Definition: DNA_ID.h:368
char name[66]
Definition: DNA_ID.h:378
struct ImBuf * mipmap[IMB_MIPMAP_LEVELS]
int channels
int userflags
struct ColorSpace * rect_colorspace
int colormanage_flag
unsigned char planes
char name[IMB_FILENAME_SIZE]
unsigned int * rect
float * rect_float
Stereo3dFormat stereo3d_format
char filepath[FILE_MAX]
Definition: ED_image.h:206
bool udims_detected
Definition: ED_image.h:211
ListBase udim_tiles
Definition: ED_image.h:212
PropertyPointerRNA pprop
Definition: image_ops.c:2497
ImageUser * iuser
Definition: image_ops.c:1237
ImageFormatData im_format
Definition: image_ops.c:1238
PropertyPointerRNA pprop
Definition: image_ops.c:1236
ImageSaveOptions opts
Definition: image_ops.c:1815
ImageUser * iuser
Definition: image_ops.c:1813
Image * image
Definition: image_ops.c:1814
struct ImageFormatData im_format
char filepath[1024]
struct Scene * scene
void * first
Definition: DNA_listBase.h:31
Definition: BKE_main.h:121
ListBase images
Definition: BKE_main.h:176
void * data
Definition: RNA_types.h:38
struct ID * owner_id
Definition: RNA_types.h:36
struct PropertyRNA * prop
Definition: RNA_types.h:43
PointerRNA ptr
Definition: RNA_types.h:42
struct RenderResult * render
struct ToolSettings * toolsettings
ColorManagedViewSettings view_settings
struct RenderData r
ColorManagedDisplaySettings display_settings
float cursor[2]
int tile_grid_shape[2]
struct Histogram sample_line_hist
struct ImageUser iuser
struct Image * image
struct ImageUser iuser
short type
struct Image * ima
UvSculpt * uvsculpt
int launch_event
Definition: clip_ops.c:362
float y
Definition: clip_ops.c:360
float xof
Definition: clip_ops.c:361
float x
Definition: clip_ops.c:360
float yof
Definition: clip_ops.c:361
bool own_cursor
Definition: clip_ops.c:363
SpaceImage * sima
Definition: image_ops.c:509
float location[2]
Definition: clip_ops.c:536
double timer_lastdraw
Definition: clip_ops.c:538
float origy
Definition: image_ops.c:498
ARegion * region
Definition: image_ops.c:510
int launch_event
Definition: clip_ops.c:535
float origx
Definition: image_ops.c:498
wmTimer * timer
Definition: clip_ops.c:537
float zoom
Definition: clip_ops.c:534
bool own_cursor
Definition: clip_ops.c:539
Definition: IMB_anim.h:71
float xmax
Definition: DNA_vec_types.h:69
float xmin
Definition: DNA_vec_types.h:69
float ymax
Definition: DNA_vec_types.h:70
float ymin
Definition: DNA_vec_types.h:70
short val
Definition: WM_types.h:680
int xy[2]
Definition: WM_types.h:682
int mval[2]
Definition: WM_types.h:684
int prev_xy[2]
Definition: WM_types.h:728
uint8_t modifier
Definition: WM_types.h:693
short type
Definition: WM_types.h:678
void * customdata
Definition: WM_types.h:715
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:919
const char * name
Definition: WM_types.h:888
int(* modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:935
const char * idname
Definition: WM_types.h:890
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:943
void(* cancel)(struct bContext *, struct wmOperator *)
Definition: WM_types.h:927
struct StructRNA * srna
Definition: WM_types.h:969
const char * description
Definition: WM_types.h:893
void(* ui)(struct bContext *, struct wmOperator *)
Definition: WM_types.h:954
bool(* check)(struct bContext *, struct wmOperator *)
Definition: WM_types.h:911
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:903
struct ReportList * reports
struct uiLayout * layout
struct wmOperatorType * type
struct PointerRNA * ptr
struct wmWindow * win
Definition: WM_types.h:860
double PIL_check_seconds_timer(void)
Definition: time.c:64
float max
void WM_cursor_modal_set(wmWindow *win, int val)
Definition: wm_cursors.c:191
void WM_cursor_modal_restore(wmWindow *win)
Definition: wm_cursors.c:200
void WM_cursor_wait(bool val)
Definition: wm_cursors.c:209
@ WM_CURSOR_NSEW_SCROLL
Definition: wm_cursors.h:51
@ WM_CURSOR_EDIT
Definition: wm_cursors.h:22
int WM_userdef_event_type_from_keymap_type(int kmitype)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void WM_main_add_notifier(unsigned int type, void *reference)
void WM_event_add_fileselect(bContext *C, wmOperator *op)
int WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, wmOperatorCallContext context, PointerRNA *properties, const wmEvent *event)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
int WM_operator_name_call(bContext *C, const char *opstring, wmOperatorCallContext context, PointerRNA *properties, const wmEvent *event)
@ MOUSEPAN
@ RIGHTMOUSE
@ TIMER
@ MOUSEZOOM
@ MOUSEMOVE
@ LEFTMOUSE
@ NDOF_MOTION
@ EVT_ESCKEY
PointerRNA * ptr
Definition: wm_files.c:3480
wmOperatorType * ot
Definition: wm_files.c:3479
void WM_gesture_box_cancel(bContext *C, wmOperator *op)
int WM_gesture_straightline_invoke(bContext *C, wmOperator *op, const wmEvent *event)
int WM_gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void WM_gesture_straightline_cancel(bContext *C, wmOperator *op)
int WM_gesture_straightline_modal(bContext *C, wmOperator *op, const wmEvent *event)
int WM_gesture_box_modal(bContext *C, wmOperator *op, const wmEvent *event)
void WM_operator_properties_gesture_straightline(wmOperatorType *ot, int cursor)
void WM_operator_properties_border(wmOperatorType *ot)
void WM_operator_properties_filesel(wmOperatorType *ot, const int filter, const short type, const eFileSel_Action action, const eFileSel_Flag flag, const short display, const short sort)
void WM_operator_properties_use_cursor_init(wmOperatorType *ot)
void WM_operator_properties_border_to_rctf(struct wmOperator *op, rctf *rect)
void WM_operator_properties_gesture_box_zoom(wmOperatorType *ot)
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
bool WM_operator_filesel_ensure_ext_imtype(wmOperator *op, const struct ImageFormatData *im_format)
void WM_operator_properties_create_ptr(PointerRNA *ptr, wmOperatorType *ot)
Definition: wm_operators.c:661
int WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width)
void WM_operator_properties_free(PointerRNA *ptr)
Definition: wm_operators.c:783
void WM_event_remove_timer(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *timer)
Definition: wm_window.c:1682
wmTimer * WM_event_add_timer(wmWindowManager *wm, wmWindow *win, int event_type, double timestep)
Definition: wm_window.c:1630