Blender  V2.93
image_ops.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
24 #include <errno.h>
25 #include <fcntl.h>
26 #include <stddef.h>
27 #include <stdlib.h>
28 #include <string.h>
29 #ifndef WIN32
30 # include <unistd.h>
31 #else
32 # include <io.h>
33 #endif
34 
35 #include "MEM_guardedalloc.h"
36 
37 #include "BLI_blenlib.h"
38 #include "BLI_fileops.h"
39 #include "BLI_ghash.h"
40 #include "BLI_math.h"
41 #include "BLI_string.h"
42 #include "BLI_utildefines.h"
43 
44 #include "BLT_translation.h"
45 
46 #include "DNA_camera_types.h"
47 #include "DNA_node_types.h"
48 #include "DNA_object_types.h"
49 #include "DNA_scene_types.h"
50 #include "DNA_screen_types.h"
51 
52 #include "BKE_colortools.h"
53 #include "BKE_context.h"
54 #include "BKE_global.h"
55 #include "BKE_icons.h"
56 #include "BKE_image.h"
57 #include "BKE_image_save.h"
58 #include "BKE_layer.h"
59 #include "BKE_lib_id.h"
60 #include "BKE_main.h"
61 #include "BKE_packedFile.h"
62 #include "BKE_report.h"
63 
64 #include "DEG_depsgraph.h"
65 
66 #include "GPU_state.h"
67 
68 #include "IMB_colormanagement.h"
69 #include "IMB_imbuf.h"
70 #include "IMB_imbuf_types.h"
71 #include "IMB_moviecache.h"
73 
74 #include "RE_pipeline.h"
75 
76 #include "RNA_access.h"
77 #include "RNA_define.h"
78 #include "RNA_enum_types.h"
79 
80 #include "ED_image.h"
81 #include "ED_mask.h"
82 #include "ED_paint.h"
83 #include "ED_render.h"
84 #include "ED_screen.h"
85 #include "ED_space_api.h"
86 #include "ED_util.h"
87 #include "ED_util_imbuf.h"
88 #include "ED_uvedit.h"
89 
90 #include "UI_interface.h"
91 #include "UI_resources.h"
92 #include "UI_view2d.h"
93 
94 #include "WM_api.h"
95 #include "WM_types.h"
96 
97 #include "PIL_time.h"
98 
99 #include "RE_engine.h"
100 
101 #include "image_intern.h"
102 
103 /* -------------------------------------------------------------------- */
107 static void sima_zoom_set(
108  SpaceImage *sima, ARegion *region, float zoom, const float location[2], const bool zoom_to_pos)
109 {
110  float oldzoom = sima->zoom;
111  int width, height;
112 
113  sima->zoom = zoom;
114 
115  if (sima->zoom < 0.1f || sima->zoom > 4.0f) {
116  /* check zoom limits */
118 
119  width *= sima->zoom;
120  height *= sima->zoom;
121 
122  if ((width < 4) && (height < 4) && sima->zoom < oldzoom) {
123  sima->zoom = oldzoom;
124  }
125  else if (BLI_rcti_size_x(&region->winrct) <= sima->zoom) {
126  sima->zoom = oldzoom;
127  }
128  else if (BLI_rcti_size_y(&region->winrct) <= sima->zoom) {
129  sima->zoom = oldzoom;
130  }
131  }
132 
133  if (zoom_to_pos && location) {
134  float aspx, aspy, w, h;
135 
137  ED_space_image_get_aspect(sima, &aspx, &aspy);
138 
139  w = width * aspx;
140  h = height * aspy;
141 
142  sima->xof += ((location[0] - 0.5f) * w - sima->xof) * (sima->zoom - oldzoom) / sima->zoom;
143  sima->yof += ((location[1] - 0.5f) * h - sima->yof) * (sima->zoom - oldzoom) / sima->zoom;
144  }
145 }
146 
148  ARegion *region,
149  float zoomfac,
150  const float location[2],
151  const bool zoom_to_pos)
152 {
153  sima_zoom_set(sima, region, sima->zoom * zoomfac, location, zoom_to_pos);
154 }
155 
159 static void sima_zoom_set_from_bounds(SpaceImage *sima, ARegion *region, const rctf *bounds)
160 {
161  int image_size[2];
162  float aspx, aspy;
163 
164  ED_space_image_get_size(sima, &image_size[0], &image_size[1]);
165  ED_space_image_get_aspect(sima, &aspx, &aspy);
166 
167  image_size[0] = image_size[0] * aspx;
168  image_size[1] = image_size[1] * aspy;
169 
170  /* adjust offset and zoom */
171  sima->xof = roundf((BLI_rctf_cent_x(bounds) - 0.5f) * image_size[0]);
172  sima->yof = roundf((BLI_rctf_cent_y(bounds) - 0.5f) * image_size[1]);
173 
174  float size_xy[2], size;
175  size_xy[0] = BLI_rcti_size_x(&region->winrct) / (BLI_rctf_size_x(bounds) * image_size[0]);
176  size_xy[1] = BLI_rcti_size_y(&region->winrct) / (BLI_rctf_size_y(bounds) * image_size[1]);
177 
178  size = min_ff(size_xy[0], size_xy[1]);
179  CLAMP_MAX(size, 100.0f);
180 
181  sima_zoom_set(sima, region, size, NULL, false);
182 }
183 
185 {
186  /* Edit image is set by templates used throughout the interface, so image
187  * operations work outside the image editor. */
188  Image *ima = CTX_data_pointer_get_type(C, "edit_image", &RNA_Image).data;
189 
190  if (ima) {
191  return ima;
192  }
193 
194  /* Image editor. */
196  return (sima) ? sima->image : NULL;
197 }
198 
200 {
201  /* Edit image user is set by templates used throughout the interface, so
202  * image operations work outside the image editor. */
203  ImageUser *iuser = CTX_data_pointer_get_type(C, "edit_image_user", &RNA_ImageUser).data;
204 
205  if (iuser) {
206  return iuser;
207  }
208 
209  /* Image editor. */
211  return (sima) ? &sima->iuser : NULL;
212 }
213 
215 {
216  Image *ima = image_from_context(C);
218 
219  if (ima == NULL) {
220  return false;
221  }
222 
223  void *lock;
224  ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock);
225  const bool has_buffer = (ibuf && (ibuf->rect || ibuf->rect_float));
226  BKE_image_release_ibuf(ima, ibuf, lock);
227  return has_buffer;
228 }
229 
234 {
235  Image *ima = image_from_context(C);
236 
237  return BKE_image_has_ibuf(ima, NULL);
238 }
239 
241 {
242  /* Do not run 'replace' on packed images, it does not give user expected results at all. */
243  Image *ima = image_from_context(C);
244  return (ima && BLI_listbase_is_empty(&ima->packedfiles));
245 }
246 
247 static void image_view_all(struct SpaceImage *sima, struct ARegion *region, struct wmOperator *op)
248 {
249  float aspx, aspy, zoomx, zoomy, w, h;
250  int width, height;
251  const bool fit_view = RNA_boolean_get(op->ptr, "fit_view");
252 
254  ED_space_image_get_aspect(sima, &aspx, &aspy);
255 
256  w = width * aspx;
257  h = height * aspy;
258 
259  float xof = 0.0f, yof = 0.0f;
260  if ((sima->image == NULL) || (sima->image->source == IMA_SRC_TILED)) {
261  /* Extend the shown area to cover all UDIM tiles. */
262  int x_tiles, y_tiles;
263  if (sima->image == NULL) {
264  x_tiles = sima->tile_grid_shape[0];
265  y_tiles = sima->tile_grid_shape[1];
266  }
267  else {
268  x_tiles = y_tiles = 1;
269  LISTBASE_FOREACH (ImageTile *, tile, &sima->image->tiles) {
270  int tile_x = (tile->tile_number - 1001) % 10;
271  int tile_y = (tile->tile_number - 1001) / 10;
272  x_tiles = max_ii(x_tiles, tile_x + 1);
273  y_tiles = max_ii(y_tiles, tile_y + 1);
274  }
275  }
276  xof = 0.5f * (x_tiles - 1.0f) * w;
277  yof = 0.5f * (y_tiles - 1.0f) * h;
278  w *= x_tiles;
279  h *= y_tiles;
280  }
281 
282  /* check if the image will fit in the image with (zoom == 1) */
283  width = BLI_rcti_size_x(&region->winrct) + 1;
284  height = BLI_rcti_size_y(&region->winrct) + 1;
285 
286  if (fit_view) {
287  const int margin = 5; /* margin from border */
288 
289  zoomx = (float)width / (w + 2 * margin);
290  zoomy = (float)height / (h + 2 * margin);
291 
292  sima_zoom_set(sima, region, min_ff(zoomx, zoomy), NULL, false);
293  }
294  else {
295  if ((w >= width || h >= height) && (width > 0 && height > 0)) {
296  zoomx = (float)width / w;
297  zoomy = (float)height / h;
298 
299  /* find the zoom value that will fit the image in the image space */
300  sima_zoom_set(sima, region, 1.0f / power_of_2(1.0f / min_ff(zoomx, zoomy)), NULL, false);
301  }
302  else {
303  sima_zoom_set(sima, region, 1.0f, NULL, false);
304  }
305  }
306 
307  sima->xof = xof;
308  sima->yof = yof;
309 }
310 
312 {
314  /* XXX ARegion *region = CTX_wm_region(C); */
315 
316  if (sima) {
317  return true; /* XXX (region && region->type->regionid == RGN_TYPE_WINDOW); */
318  }
319  return false;
320 }
321 
322 /* For IMAGE_OT_curves_point_set to avoid sampling when in uv smooth mode or editmode */
324 {
327  ToolSettings *toolsettings = scene->toolsettings;
328 
329  if (sima && !toolsettings->uvsculpt && (CTX_data_edit_object(C) == NULL)) {
330  return true;
331  }
332 
333  return false;
334 }
335 
338 /* -------------------------------------------------------------------- */
342 typedef struct ViewPanData {
343  float x, y;
344  float xof, yof;
345  int launch_event;
346  bool own_cursor;
348 
349 static void image_view_pan_init(bContext *C, wmOperator *op, const wmEvent *event)
350 {
351  wmWindow *win = CTX_wm_window(C);
353  ViewPanData *vpd;
354 
355  op->customdata = vpd = MEM_callocN(sizeof(ViewPanData), "ImageViewPanData");
356 
357  /* Grab will be set when running from gizmo. */
358  vpd->own_cursor = (win->grabcursor == 0);
359  if (vpd->own_cursor) {
361  }
362 
363  vpd->x = event->x;
364  vpd->y = event->y;
365  vpd->xof = sima->xof;
366  vpd->yof = sima->yof;
368 
370 }
371 
372 static void image_view_pan_exit(bContext *C, wmOperator *op, bool cancel)
373 {
375  ViewPanData *vpd = op->customdata;
376 
377  if (cancel) {
378  sima->xof = vpd->xof;
379  sima->yof = vpd->yof;
381  }
382 
383  if (vpd->own_cursor) {
385  }
386  MEM_freeN(op->customdata);
387 }
388 
390 {
392  float offset[2];
393 
394  RNA_float_get_array(op->ptr, "offset", offset);
395  sima->xof += offset[0];
396  sima->yof += offset[1];
397 
399 
400  return OPERATOR_FINISHED;
401 }
402 
403 static int image_view_pan_invoke(bContext *C, wmOperator *op, const wmEvent *event)
404 {
405  if (event->type == MOUSEPAN) {
407  float offset[2];
408 
409  offset[0] = (event->prevx - event->x) / sima->zoom;
410  offset[1] = (event->prevy - event->y) / sima->zoom;
411  RNA_float_set_array(op->ptr, "offset", offset);
412 
413  image_view_pan_exec(C, op);
414  return OPERATOR_FINISHED;
415  }
416 
417  image_view_pan_init(C, op, event);
418  return OPERATOR_RUNNING_MODAL;
419 }
420 
421 static int image_view_pan_modal(bContext *C, wmOperator *op, const wmEvent *event)
422 {
424  ViewPanData *vpd = op->customdata;
425  float offset[2];
426 
427  switch (event->type) {
428  case MOUSEMOVE:
429  sima->xof = vpd->xof;
430  sima->yof = vpd->yof;
431  offset[0] = (vpd->x - event->x) / sima->zoom;
432  offset[1] = (vpd->y - event->y) / sima->zoom;
433  RNA_float_set_array(op->ptr, "offset", offset);
434  image_view_pan_exec(C, op);
435  break;
436  default:
437  if (event->type == vpd->launch_event && event->val == KM_RELEASE) {
438  image_view_pan_exit(C, op, false);
439  return OPERATOR_FINISHED;
440  }
441  break;
442  }
443 
444  return OPERATOR_RUNNING_MODAL;
445 }
446 
448 {
449  image_view_pan_exit(C, op, true);
450 }
451 
453 {
454  /* identifiers */
455  ot->name = "Pan View";
456  ot->idname = "IMAGE_OT_view_pan";
457  ot->description = "Pan the view";
458 
459  /* api callbacks */
465 
466  /* flags */
468 
469  /* properties */
471  "offset",
472  2,
473  NULL,
474  -FLT_MAX,
475  FLT_MAX,
476  "Offset",
477  "Offset in floating-point units, 1.0 is the width and height of the image",
478  -FLT_MAX,
479  FLT_MAX);
480 }
481 
484 /* -------------------------------------------------------------------- */
488 typedef struct ViewZoomData {
489  float origx, origy;
490  float zoom;
491  int launch_event;
492  float location[2];
493 
494  /* needed for continuous zoom */
495  wmTimer *timer;
496  double timer_lastdraw;
497  bool own_cursor;
498 
499  /* */
503 
504 static void image_view_zoom_init(bContext *C, wmOperator *op, const wmEvent *event)
505 {
506  wmWindow *win = CTX_wm_window(C);
508  ARegion *region = CTX_wm_region(C);
509  ViewZoomData *vpd;
510 
511  op->customdata = vpd = MEM_callocN(sizeof(ViewZoomData), "ImageViewZoomData");
512 
513  /* Grab will be set when running from gizmo. */
514  vpd->own_cursor = (win->grabcursor == 0);
515  if (vpd->own_cursor) {
517  }
518 
519  vpd->origx = event->x;
520  vpd->origy = event->y;
521  vpd->zoom = sima->zoom;
523 
525  &region->v2d, event->mval[0], event->mval[1], &vpd->location[0], &vpd->location[1]);
526 
527  if (U.viewzoom == USER_ZOOM_CONTINUE) {
528  /* needs a timer to continue redrawing */
531  }
532 
533  vpd->sima = sima;
534  vpd->region = region;
535 
537 }
538 
539 static void image_view_zoom_exit(bContext *C, wmOperator *op, bool cancel)
540 {
542  ViewZoomData *vpd = op->customdata;
543 
544  if (cancel) {
545  sima->zoom = vpd->zoom;
547  }
548 
549  if (vpd->timer) {
551  }
552 
553  if (vpd->own_cursor) {
555  }
556  MEM_freeN(op->customdata);
557 }
558 
560 {
562  ARegion *region = CTX_wm_region(C);
563 
564  sima_zoom_set_factor(sima, region, RNA_float_get(op->ptr, "factor"), NULL, false);
565 
566  ED_region_tag_redraw(region);
567 
568  return OPERATOR_FINISHED;
569 }
570 
571 enum {
575 };
576 
577 static int image_view_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *event)
578 {
579  if (ELEM(event->type, MOUSEZOOM, MOUSEPAN)) {
581  ARegion *region = CTX_wm_region(C);
582  float delta, factor, location[2];
583 
585  &region->v2d, event->mval[0], event->mval[1], &location[0], &location[1]);
586 
587  delta = event->prevx - event->x + event->prevy - event->y;
588 
589  if (U.uiflag & USER_ZOOM_INVERT) {
590  delta *= -1;
591  }
592 
593  factor = 1.0f + delta / 300.0f;
594  RNA_float_set(op->ptr, "factor", factor);
595  const bool use_cursor_init = RNA_boolean_get(op->ptr, "use_cursor_init");
596  sima_zoom_set(sima,
597  region,
598  sima->zoom * factor,
599  location,
600  (use_cursor_init && (U.uiflag & USER_ZOOM_TO_MOUSEPOS)));
601  ED_region_tag_redraw(region);
602 
603  return OPERATOR_FINISHED;
604  }
605 
606  image_view_zoom_init(C, op, event);
607  return OPERATOR_RUNNING_MODAL;
608 }
609 
611  wmOperator *op,
612  const int x,
613  const int y,
614  const short viewzoom,
615  const short zoom_invert,
616  const bool zoom_to_pos)
617 {
618  float factor;
619  float delta;
620 
621  if (viewzoom != USER_ZOOM_SCALE) {
622  if (U.uiflag & USER_ZOOM_HORIZ) {
623  delta = (float)(x - vpd->origx);
624  }
625  else {
626  delta = (float)(y - vpd->origy);
627  }
628  }
629  else {
630  delta = x - vpd->origx + y - vpd->origy;
631  }
632 
633  delta /= U.pixelsize;
634 
635  if (zoom_invert) {
636  delta = -delta;
637  }
638 
639  if (viewzoom == USER_ZOOM_CONTINUE) {
640  double time = PIL_check_seconds_timer();
641  float time_step = (float)(time - vpd->timer_lastdraw);
642  float zfac;
643  zfac = 1.0f + ((delta / 20.0f) * time_step);
644  vpd->timer_lastdraw = time;
645  /* this is the final zoom, but instead make it into a factor */
646  factor = (vpd->sima->zoom * zfac) / vpd->zoom;
647  }
648  else {
649  factor = 1.0f + delta / 300.0f;
650  }
651 
652  RNA_float_set(op->ptr, "factor", factor);
653  sima_zoom_set(vpd->sima, vpd->region, vpd->zoom * factor, vpd->location, zoom_to_pos);
655 }
656 
657 static int image_view_zoom_modal(bContext *C, wmOperator *op, const wmEvent *event)
658 {
659  ViewZoomData *vpd = op->customdata;
660  short event_code = VIEW_PASS;
661 
662  /* execute the events */
663  if (event->type == TIMER && event->customdata == vpd->timer) {
664  /* continuous zoom */
665  event_code = VIEW_APPLY;
666  }
667  else if (event->type == MOUSEMOVE) {
668  event_code = VIEW_APPLY;
669  }
670  else if (event->type == vpd->launch_event && event->val == KM_RELEASE) {
671  event_code = VIEW_CONFIRM;
672  }
673 
674  if (event_code == VIEW_APPLY) {
675  const bool use_cursor_init = RNA_boolean_get(op->ptr, "use_cursor_init");
676  image_zoom_apply(vpd,
677  op,
678  event->x,
679  event->y,
680  U.viewzoom,
681  (U.uiflag & USER_ZOOM_INVERT) != 0,
682  (use_cursor_init && (U.uiflag & USER_ZOOM_TO_MOUSEPOS)));
683  }
684  else if (event_code == VIEW_CONFIRM) {
685  image_view_zoom_exit(C, op, false);
686  return OPERATOR_FINISHED;
687  }
688 
689  return OPERATOR_RUNNING_MODAL;
690 }
691 
693 {
694  image_view_zoom_exit(C, op, true);
695 }
696 
698 {
699  PropertyRNA *prop;
700 
701  /* identifiers */
702  ot->name = "Zoom View";
703  ot->idname = "IMAGE_OT_view_zoom";
704  ot->description = "Zoom in/out the image";
705 
706  /* api callbacks */
712 
713  /* flags */
715 
716  /* properties */
717  prop = RNA_def_float(ot->srna,
718  "factor",
719  0.0f,
720  -FLT_MAX,
721  FLT_MAX,
722  "Factor",
723  "Zoom factor, values higher than 1.0 zoom in, lower values zoom out",
724  -FLT_MAX,
725  FLT_MAX);
727 
729 }
730 
731 #ifdef WITH_INPUT_NDOF
732 
735 /* -------------------------------------------------------------------- */
739 /* Combined pan/zoom from a 3D mouse device.
740  * Z zooms, XY pans
741  * "view" (not "paper") control -- user moves the viewpoint, not the image being viewed
742  * that explains the negative signs in the code below
743  */
744 
745 static int image_view_ndof_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
746 {
747  if (event->type != NDOF_MOTION) {
748  return OPERATOR_CANCELLED;
749  }
750 
752  ARegion *region = CTX_wm_region(C);
753  float pan_vec[3];
754 
755  const wmNDOFMotionData *ndof = event->customdata;
756  const float speed = NDOF_PIXELS_PER_SECOND;
757 
758  WM_event_ndof_pan_get(ndof, pan_vec, true);
759 
760  mul_v2_fl(pan_vec, (speed * ndof->dt) / sima->zoom);
761  pan_vec[2] *= -ndof->dt;
762 
763  sima_zoom_set_factor(sima, region, 1.0f + pan_vec[2], NULL, false);
764  sima->xof += pan_vec[0];
765  sima->yof += pan_vec[1];
766 
767  ED_region_tag_redraw(region);
768 
769  return OPERATOR_FINISHED;
770 }
771 
772 void IMAGE_OT_view_ndof(wmOperatorType *ot)
773 {
774  /* identifiers */
775  ot->name = "NDOF Pan/Zoom";
776  ot->idname = "IMAGE_OT_view_ndof";
777  ot->description = "Use a 3D mouse device to pan/zoom the view";
778 
779  /* api callbacks */
780  ot->invoke = image_view_ndof_invoke;
782 
783  /* flags */
785 }
786 
789 #endif /* WITH_INPUT_NDOF */
790 
791 /* -------------------------------------------------------------------- */
795 /* Updates the fields of the View2D member of the SpaceImage struct.
796  * Default behavior is to reset the position of the image and set the zoom to 1
797  * If the image will not fit within the window rectangle, the zoom is adjusted */
798 
800 {
801  SpaceImage *sima;
802  ARegion *region;
803 
804  /* retrieve state */
805  sima = CTX_wm_space_image(C);
806  region = CTX_wm_region(C);
807 
808  image_view_all(sima, region, op);
809 
810  ED_region_tag_redraw(region);
811 
812  return OPERATOR_FINISHED;
813 }
814 
816 {
817  PropertyRNA *prop;
818 
819  /* identifiers */
820  ot->name = "Frame All";
821  ot->idname = "IMAGE_OT_view_all";
822  ot->description = "View the entire image";
823 
824  /* api callbacks */
827 
828  /* flags */
830 
831  /* properties */
832  prop = RNA_def_boolean(ot->srna, "fit_view", 0, "Fit View", "Fit frame to the viewport");
834 }
835 
838 /* -------------------------------------------------------------------- */
843 {
844  SpaceImage *sima;
845  ARegion *region;
846 
847  sima = CTX_wm_space_image(C);
848  region = CTX_wm_region(C);
849 
850  image_view_all(sima, region, op);
851 
852  sima->cursor[0] = 0.5f;
853  sima->cursor[1] = 0.5f;
854 
855  /* Needed for updating the cursor. */
857 
858  return OPERATOR_FINISHED;
859 }
860 
862 {
863  PropertyRNA *prop;
864 
865  /* identifiers */
866  ot->name = "Cursor To Center View";
867  ot->description = "Set 2D Cursor To Center View location";
868  ot->idname = "IMAGE_OT_view_cursor_center";
869 
870  /* api callbacks */
873 
874  /* properties */
875  prop = RNA_def_boolean(ot->srna, "fit_view", 0, "Fit View", "Fit frame to the viewport");
877 }
878 
881 /* -------------------------------------------------------------------- */
886 {
888  ARegion *region = CTX_wm_region(C);
889 
890  ED_image_view_center_to_point(sima, sima->cursor[0], sima->cursor[1]);
891 
892  ED_region_tag_redraw(region);
893 
894  return OPERATOR_FINISHED;
895 }
896 
898 {
899  /* identifiers */
900  ot->name = "Center View to Cursor";
901  ot->description = "Center the view so that the cursor is in the middle of the view";
902  ot->idname = "IMAGE_OT_view_center_cursor";
903 
904  /* api callbacks */
907 }
908 
911 /* -------------------------------------------------------------------- */
916 {
917  SpaceImage *sima;
918  ARegion *region;
919  Scene *scene;
920  ViewLayer *view_layer;
921  Object *obedit;
922 
923  /* retrieve state */
924  sima = CTX_wm_space_image(C);
925  region = CTX_wm_region(C);
927  view_layer = CTX_data_view_layer(C);
928  obedit = CTX_data_edit_object(C);
929 
930  /* get bounds */
931  float min[2], max[2];
932  if (ED_space_image_show_uvedit(sima, obedit)) {
933  uint objects_len = 0;
935  view_layer, ((View3D *)NULL), &objects_len);
936  bool success = ED_uvedit_minmax_multi(scene, objects, objects_len, min, max);
937  MEM_freeN(objects);
938  if (!success) {
939  return OPERATOR_CANCELLED;
940  }
941  }
942  else if (ED_space_image_check_show_maskedit(sima, obedit)) {
943  if (!ED_mask_selected_minmax(C, min, max, false)) {
944  return OPERATOR_CANCELLED;
945  }
946  }
947  rctf bounds = {
948  .xmin = min[0],
949  .ymin = min[1],
950  .xmax = max[0],
951  .ymax = max[1],
952  };
953 
954  /* add some margin */
955  BLI_rctf_scale(&bounds, 1.4f);
956 
957  sima_zoom_set_from_bounds(sima, region, &bounds);
958 
959  ED_region_tag_redraw(region);
960 
961  return OPERATOR_FINISHED;
962 }
963 
965 {
967 }
968 
970 {
971  /* identifiers */
972  ot->name = "View Center";
973  ot->idname = "IMAGE_OT_view_selected";
974  ot->description = "View all selected UVs";
975 
976  /* api callbacks */
979 }
980 
983 /* -------------------------------------------------------------------- */
988 {
990  ARegion *region = CTX_wm_region(C);
991  float location[2];
992 
993  RNA_float_get_array(op->ptr, "location", location);
994 
996  sima, region, powf(2.0f, 1.0f / 3.0f), location, U.uiflag & USER_ZOOM_TO_MOUSEPOS);
997 
998  ED_region_tag_redraw(region);
999 
1000  return OPERATOR_FINISHED;
1001 }
1002 
1003 static int image_view_zoom_in_invoke(bContext *C, wmOperator *op, const wmEvent *event)
1004 {
1005  ARegion *region = CTX_wm_region(C);
1006  float location[2];
1007 
1009  &region->v2d, event->mval[0], event->mval[1], &location[0], &location[1]);
1010  RNA_float_set_array(op->ptr, "location", location);
1011 
1012  return image_view_zoom_in_exec(C, op);
1013 }
1014 
1016 {
1017  PropertyRNA *prop;
1018 
1019  /* identifiers */
1020  ot->name = "Zoom In";
1021  ot->idname = "IMAGE_OT_view_zoom_in";
1022  ot->description = "Zoom in the image (centered around 2D cursor)";
1023 
1024  /* api callbacks */
1028 
1029  /* flags */
1031 
1032  /* properties */
1033  prop = RNA_def_float_vector(ot->srna,
1034  "location",
1035  2,
1036  NULL,
1037  -FLT_MAX,
1038  FLT_MAX,
1039  "Location",
1040  "Cursor location in screen coordinates",
1041  -10.0f,
1042  10.0f);
1044 }
1045 
1047 {
1048  SpaceImage *sima = CTX_wm_space_image(C);
1049  ARegion *region = CTX_wm_region(C);
1050  float location[2];
1051 
1052  RNA_float_get_array(op->ptr, "location", location);
1053 
1055  sima, region, powf(0.5f, 1.0f / 3.0f), location, U.uiflag & USER_ZOOM_TO_MOUSEPOS);
1056 
1057  ED_region_tag_redraw(region);
1058 
1059  return OPERATOR_FINISHED;
1060 }
1061 
1062 static int image_view_zoom_out_invoke(bContext *C, wmOperator *op, const wmEvent *event)
1063 {
1064  ARegion *region = CTX_wm_region(C);
1065  float location[2];
1066 
1068  &region->v2d, event->mval[0], event->mval[1], &location[0], &location[1]);
1069  RNA_float_set_array(op->ptr, "location", location);
1070 
1071  return image_view_zoom_out_exec(C, op);
1072 }
1073 
1075 {
1076  PropertyRNA *prop;
1077 
1078  /* identifiers */
1079  ot->name = "Zoom Out";
1080  ot->idname = "IMAGE_OT_view_zoom_out";
1081  ot->description = "Zoom out the image (centered around 2D cursor)";
1082 
1083  /* api callbacks */
1087 
1088  /* flags */
1090 
1091  /* properties */
1092  prop = RNA_def_float_vector(ot->srna,
1093  "location",
1094  2,
1095  NULL,
1096  -FLT_MAX,
1097  FLT_MAX,
1098  "Location",
1099  "Cursor location in screen coordinates",
1100  -10.0f,
1101  10.0f);
1103 }
1104 
1107 /* -------------------------------------------------------------------- */
1112 {
1113  SpaceImage *sima = CTX_wm_space_image(C);
1114  ARegion *region = CTX_wm_region(C);
1115 
1116  sima_zoom_set(sima, region, RNA_float_get(op->ptr, "ratio"), NULL, false);
1117 
1118  /* ensure pixel exact locations for draw */
1119  sima->xof = (int)sima->xof;
1120  sima->yof = (int)sima->yof;
1121 
1122  ED_region_tag_redraw(region);
1123 
1124  return OPERATOR_FINISHED;
1125 }
1126 
1128 {
1129  /* identifiers */
1130  ot->name = "View Zoom Ratio";
1131  ot->idname = "IMAGE_OT_view_zoom_ratio";
1132  ot->description = "Set zoom ratio of the view";
1133 
1134  /* api callbacks */
1137 
1138  /* flags */
1140 
1141  /* properties */
1143  "ratio",
1144  0.0f,
1145  -FLT_MAX,
1146  FLT_MAX,
1147  "Ratio",
1148  "Zoom ratio, 1.0 is 1:1, higher is zoomed in, lower is zoomed out",
1149  -FLT_MAX,
1150  FLT_MAX);
1151 }
1152 
1155 /* -------------------------------------------------------------------- */
1160 {
1161  SpaceImage *sima = CTX_wm_space_image(C);
1162  ARegion *region = CTX_wm_region(C);
1163  rctf bounds;
1164  const bool zoom_in = !RNA_boolean_get(op->ptr, "zoom_out");
1165 
1167 
1169 
1170  const struct {
1171  float xof;
1172  float yof;
1173  float zoom;
1174  } sima_view_prev = {
1175  .xof = sima->xof,
1176  .yof = sima->yof,
1177  .zoom = sima->zoom,
1178  };
1179 
1180  sima_zoom_set_from_bounds(sima, region, &bounds);
1181 
1182  /* zoom out */
1183  if (!zoom_in) {
1184  sima->xof = sima_view_prev.xof + (sima->xof - sima_view_prev.xof);
1185  sima->yof = sima_view_prev.yof + (sima->yof - sima_view_prev.yof);
1186  sima->zoom = sima_view_prev.zoom * (sima_view_prev.zoom / sima->zoom);
1187  }
1188 
1189  ED_region_tag_redraw(region);
1190 
1191  return OPERATOR_FINISHED;
1192 }
1193 
1195 {
1196  /* identifiers */
1197  ot->name = "Zoom to Border";
1198  ot->description = "Zoom in the view to the nearest item contained in the border";
1199  ot->idname = "IMAGE_OT_view_zoom_border";
1200 
1201  /* api callbacks */
1206 
1208 
1209  /* rna */
1211 }
1212 
1213 /* load/replace/save callbacks */
1214 static void image_filesel(bContext *C, wmOperator *op, const char *path)
1215 {
1216  RNA_string_set(op->ptr, "filepath", path);
1218 }
1219 
1222 /* -------------------------------------------------------------------- */
1226 typedef struct ImageOpenData {
1231 
1233 {
1234  ImageOpenData *iod;
1235  op->customdata = iod = MEM_callocN(sizeof(ImageOpenData), __func__);
1236  iod->iuser = CTX_data_pointer_get_type(C, "image_user", &RNA_ImageUser).data;
1238 }
1239 
1241 {
1242  MEM_freeN(op->customdata);
1243  op->customdata = NULL;
1244 }
1245 
1247  wmOperator *op,
1248  ImageFrameRange *range,
1249  const char *relbase,
1250  bool is_relative_path,
1251  bool use_multiview)
1252 {
1253  bool exists = false;
1254  Image *ima = NULL;
1255 
1256  errno = 0;
1257  ima = BKE_image_load_exists_ex(bmain, range->filepath, &exists);
1258 
1259  if (!ima) {
1260  if (op->customdata) {
1261  MEM_freeN(op->customdata);
1262  }
1263  BKE_reportf(op->reports,
1264  RPT_ERROR,
1265  "Cannot read '%s': %s",
1266  range->filepath,
1267  errno ? strerror(errno) : TIP_("unsupported image format"));
1268  return NULL;
1269  }
1270 
1271  if (!exists) {
1272  /* only image path after save, never ibuf */
1273  if (is_relative_path) {
1274  BLI_path_rel(ima->filepath, relbase);
1275  }
1276 
1277  /* handle multiview images */
1278  if (use_multiview) {
1279  ImageOpenData *iod = op->customdata;
1280  ImageFormatData *imf = &iod->im_format;
1281 
1282  ima->flag |= IMA_USE_VIEWS;
1283  ima->views_format = imf->views_format;
1284  *ima->stereo3d_format = imf->stereo3d_format;
1285  }
1286  else {
1287  ima->flag &= ~IMA_USE_VIEWS;
1288  BKE_image_free_views(ima);
1289  }
1290 
1291  if ((range->length > 1) && (ima->source == IMA_SRC_FILE)) {
1292  if (range->udim_tiles.first && range->offset == 1001) {
1293  ima->source = IMA_SRC_TILED;
1294  LISTBASE_FOREACH (LinkData *, node, &range->udim_tiles) {
1296  }
1297  }
1298  else {
1299  ima->source = IMA_SRC_SEQUENCE;
1300  }
1301  }
1302  }
1303 
1304  return ima;
1305 }
1306 
1308 {
1309  Main *bmain = CTX_data_main(C);
1310  ScrArea *area = CTX_wm_area(C);
1312  Object *obedit = CTX_data_edit_object(C);
1313  ImageUser *iuser = NULL;
1314  ImageOpenData *iod = op->customdata;
1315  Image *ima = NULL;
1316  int frame_seq_len = 0;
1317  int frame_ofs = 1;
1318 
1319  const bool is_relative_path = RNA_boolean_get(op->ptr, "relative_path");
1320  const bool use_multiview = RNA_boolean_get(op->ptr, "use_multiview");
1321  const bool use_udim = RNA_boolean_get(op->ptr, "use_udim_detecting");
1322 
1323  if (!op->customdata) {
1324  image_open_init(C, op);
1325  }
1326 
1327  ListBase ranges = ED_image_filesel_detect_sequences(bmain, op, use_udim);
1328  LISTBASE_FOREACH (ImageFrameRange *, range, &ranges) {
1329  Image *ima_range = image_open_single(
1330  bmain, op, range, BKE_main_blendfile_path(bmain), is_relative_path, use_multiview);
1331 
1332  /* take the first image */
1333  if ((ima == NULL) && ima_range) {
1334  ima = ima_range;
1335  frame_seq_len = range->length;
1336  frame_ofs = range->offset;
1337  }
1338 
1339  BLI_freelistN(&range->udim_tiles);
1340  }
1341  BLI_freelistN(&ranges);
1342 
1343  if (ima == NULL) {
1344  return OPERATOR_CANCELLED;
1345  }
1346 
1347  /* hook into UI */
1348  iod = op->customdata;
1349 
1350  if (iod->pprop.prop) {
1351  /* when creating new ID blocks, use is already 1, but RNA
1352  * pointer use also increases user, so this compensates it */
1353  id_us_min(&ima->id);
1354 
1355  PointerRNA imaptr;
1356  RNA_id_pointer_create(&ima->id, &imaptr);
1357  RNA_property_pointer_set(&iod->pprop.ptr, iod->pprop.prop, imaptr, NULL);
1358  RNA_property_update(C, &iod->pprop.ptr, iod->pprop.prop);
1359  }
1360 
1361  if (iod->iuser) {
1362  iuser = iod->iuser;
1363  }
1364  else if (area && area->spacetype == SPACE_IMAGE) {
1365  SpaceImage *sima = area->spacedata.first;
1366  ED_space_image_set(bmain, sima, obedit, ima, false);
1367  iuser = &sima->iuser;
1368  }
1369  else {
1371  if (tex && tex->type == TEX_IMAGE) {
1372  iuser = &tex->iuser;
1373  }
1374 
1375  if (iuser == NULL) {
1376  Camera *cam = CTX_data_pointer_get_type(C, "camera", &RNA_Camera).data;
1377  if (cam) {
1378  LISTBASE_FOREACH (CameraBGImage *, bgpic, &cam->bg_images) {
1379  if (bgpic->ima == ima) {
1380  iuser = &bgpic->iuser;
1381  break;
1382  }
1383  }
1384  }
1385  }
1386  }
1387 
1388  /* initialize because of new image */
1389  if (iuser) {
1390  /* If the sequence was a tiled image, we only have one frame. */
1391  iuser->frames = (ima->source == IMA_SRC_SEQUENCE) ? frame_seq_len : 1;
1392  iuser->sfra = 1;
1393  iuser->framenr = 1;
1394  if (ima->source == IMA_SRC_MOVIE) {
1395  iuser->offset = 0;
1396  }
1397  else {
1398  iuser->offset = frame_ofs - 1;
1399  }
1400  iuser->scene = scene;
1401  BKE_image_init_imageuser(ima, iuser);
1402  }
1403 
1404  /* XXX BKE_packedfile_unpack_image frees image buffers */
1406 
1407  BKE_image_signal(bmain, ima, iuser, IMA_SIGNAL_RELOAD);
1409 
1410  MEM_freeN(op->customdata);
1411 
1412  return OPERATOR_FINISHED;
1413 }
1414 
1415 static int image_open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
1416 {
1417  SpaceImage *sima = CTX_wm_space_image(C); /* XXX other space types can call */
1418  const char *path = U.textudir;
1419  Image *ima = NULL;
1421 
1422  if (sima) {
1423  ima = sima->image;
1424  }
1425 
1426  if (ima == NULL) {
1428  if (tex && tex->type == TEX_IMAGE) {
1429  ima = tex->ima;
1430  }
1431  }
1432 
1433  if (ima == NULL) {
1434  PointerRNA ptr;
1435  PropertyRNA *prop;
1436 
1437  /* hook into UI */
1439 
1440  if (prop) {
1441  PointerRNA oldptr;
1442  Image *oldima;
1443 
1444  oldptr = RNA_property_pointer_get(&ptr, prop);
1445  oldima = (Image *)oldptr.owner_id;
1446  /* unlikely to fail but better avoid strange crash */
1447  if (oldima && GS(oldima->id.name) == ID_IM) {
1448  ima = oldima;
1449  }
1450  }
1451  }
1452 
1453  if (ima) {
1454  path = ima->filepath;
1455  }
1456 
1457  if (RNA_struct_property_is_set(op->ptr, "filepath")) {
1458  return image_open_exec(C, op);
1459  }
1460 
1461  image_open_init(C, op);
1462 
1463  /* show multiview save options only if scene has multiviews */
1464  PropertyRNA *prop;
1465  prop = RNA_struct_find_property(op->ptr, "show_multiview");
1466  RNA_property_boolean_set(op->ptr, prop, (scene->r.scemode & R_MULTIVIEW) != 0);
1467 
1468  image_filesel(C, op, path);
1469 
1470  return OPERATOR_RUNNING_MODAL;
1471 }
1472 
1474  PropertyRNA *prop,
1475  void *UNUSED(user_data))
1476 {
1477  const char *prop_id = RNA_property_identifier(prop);
1478 
1479  return !(STR_ELEM(prop_id, "filepath", "directory", "filename"));
1480 }
1481 
1483 {
1484  uiLayout *layout = op->layout;
1486  ImageOpenData *iod = op->customdata;
1487  ImageFormatData *imf = &iod->im_format;
1488  PointerRNA imf_ptr, ptr;
1489 
1490  /* main draw call */
1491  RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
1494 
1495  /* image template */
1497 
1498  /* multiview template */
1499  if (RNA_boolean_get(op->ptr, "show_multiview")) {
1500  uiTemplateImageFormatViews(layout, &imf_ptr, op->ptr);
1501  }
1502 }
1503 
1504 /* called by other space types too */
1506 {
1507  /* identifiers */
1508  ot->name = "Open Image";
1509  ot->description = "Open image";
1510  ot->idname = "IMAGE_OT_open";
1511 
1512  /* api callbacks */
1513  ot->exec = image_open_exec;
1516  ot->ui = image_open_draw;
1517 
1518  /* flags */
1520 
1521  /* properties */
1524  FILE_SPECIAL,
1525  FILE_OPENFILE,
1530 
1532  ot->srna,
1533  "use_sequence_detection",
1534  true,
1535  "Detect Sequences",
1536  "Automatically detect animated sequences in selected images (based on file names)");
1538  "use_udim_detecting",
1539  true,
1540  "Detect UDIMs",
1541  "Detect selected UDIM files and load all matching tiles");
1542 }
1543 
1546 /* -------------------------------------------------------------------- */
1551 {
1553  Image *ima = image_from_context(C);
1555 
1556  if (!ima || !iuser) {
1557  /* Try to get a Texture, or a SpaceImage from context... */
1559  if (tex && tex->type == TEX_IMAGE) {
1560  ima = tex->ima;
1561  iuser = &tex->iuser;
1562  }
1563  }
1564 
1565  if (!ima || !iuser || !BKE_image_has_anim(ima)) {
1566  return OPERATOR_CANCELLED;
1567  }
1568 
1569  struct anim *anim = ((ImageAnim *)ima->anims.first)->anim;
1570  if (!anim) {
1571  return OPERATOR_CANCELLED;
1572  }
1574  BKE_image_user_frame_calc(ima, iuser, scene->r.cfra);
1575 
1576  return OPERATOR_FINISHED;
1577 }
1578 
1579 /* called by other space types too */
1581 {
1582  /* identifiers */
1583  ot->name = "Match Movie Length";
1584  ot->description = "Set image's user's length to the one of this video";
1585  ot->idname = "IMAGE_OT_match_movie_length";
1586 
1587  /* api callbacks */
1589 
1590  /* flags */
1591  /* Don't think we need undo for that. */
1592  ot->flag = OPTYPE_REGISTER | OPTYPE_INTERNAL /* | OPTYPE_UNDO */;
1593 }
1594 
1597 /* -------------------------------------------------------------------- */
1602 {
1603  Main *bmain = CTX_data_main(C);
1604  SpaceImage *sima = CTX_wm_space_image(C);
1605  char str[FILE_MAX];
1606 
1607  if (!sima->image) {
1608  return OPERATOR_CANCELLED;
1609  }
1610 
1611  RNA_string_get(op->ptr, "filepath", str);
1612 
1613  /* we cant do much if the str is longer than FILE_MAX :/ */
1614  BLI_strncpy(sima->image->filepath, str, sizeof(sima->image->filepath));
1615 
1616  if (sima->image->source == IMA_SRC_GENERATED) {
1617  sima->image->source = IMA_SRC_FILE;
1618  BKE_image_signal(bmain, sima->image, &sima->iuser, IMA_SIGNAL_SRC_CHANGE);
1619  }
1620 
1622  sima->image->source = IMA_SRC_MOVIE;
1623  }
1624  else {
1625  sima->image->source = IMA_SRC_FILE;
1626  }
1627 
1628  /* XXX BKE_packedfile_unpack_image frees image buffers */
1630 
1632  BKE_image_signal(bmain, sima->image, &sima->iuser, IMA_SIGNAL_RELOAD);
1634 
1635  return OPERATOR_FINISHED;
1636 }
1637 
1638 static int image_replace_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
1639 {
1640  SpaceImage *sima = CTX_wm_space_image(C);
1641 
1642  if (!sima->image) {
1643  return OPERATOR_CANCELLED;
1644  }
1645 
1646  if (RNA_struct_property_is_set(op->ptr, "filepath")) {
1647  return image_replace_exec(C, op);
1648  }
1649 
1650  if (!RNA_struct_property_is_set(op->ptr, "relative_path")) {
1651  RNA_boolean_set(op->ptr, "relative_path", BLI_path_is_rel(sima->image->filepath));
1652  }
1653 
1654  image_filesel(C, op, sima->image->filepath);
1655 
1656  return OPERATOR_RUNNING_MODAL;
1657 }
1658 
1660 {
1661  /* identifiers */
1662  ot->name = "Replace Image";
1663  ot->idname = "IMAGE_OT_replace";
1664  ot->description = "Replace current image by another one from disk";
1665 
1666  /* api callbacks */
1670 
1671  /* flags */
1673 
1674  /* properties */
1677  FILE_SPECIAL,
1678  FILE_OPENFILE,
1682 }
1683 
1686 /* -------------------------------------------------------------------- */
1690 typedef struct ImageSaveData {
1695 
1696 static char imtype_best_depth(ImBuf *ibuf, const char imtype)
1697 {
1698  const char depth_ok = BKE_imtype_valid_depths(imtype);
1699 
1700  if (ibuf->rect_float) {
1701  if (depth_ok & R_IMF_CHAN_DEPTH_32) {
1702  return R_IMF_CHAN_DEPTH_32;
1703  }
1704  if (depth_ok & R_IMF_CHAN_DEPTH_24) {
1705  return R_IMF_CHAN_DEPTH_24;
1706  }
1707  if (depth_ok & R_IMF_CHAN_DEPTH_16) {
1708  return R_IMF_CHAN_DEPTH_16;
1709  }
1710  if (depth_ok & R_IMF_CHAN_DEPTH_12) {
1711  return R_IMF_CHAN_DEPTH_12;
1712  }
1713  return R_IMF_CHAN_DEPTH_8;
1714  }
1715 
1716  if (depth_ok & R_IMF_CHAN_DEPTH_8) {
1717  return R_IMF_CHAN_DEPTH_8;
1718  }
1719  if (depth_ok & R_IMF_CHAN_DEPTH_12) {
1720  return R_IMF_CHAN_DEPTH_12;
1721  }
1722  if (depth_ok & R_IMF_CHAN_DEPTH_16) {
1723  return R_IMF_CHAN_DEPTH_16;
1724  }
1725  if (depth_ok & R_IMF_CHAN_DEPTH_24) {
1726  return R_IMF_CHAN_DEPTH_24;
1727  }
1728  if (depth_ok & R_IMF_CHAN_DEPTH_32) {
1729  return R_IMF_CHAN_DEPTH_32;
1730  }
1731  return R_IMF_CHAN_DEPTH_8; /* fallback, should not get here */
1732 }
1733 
1734 static int image_save_options_init(Main *bmain,
1735  ImageSaveOptions *opts,
1736  Image *ima,
1737  ImageUser *iuser,
1738  const bool guess_path,
1739  const bool save_as_render)
1740 {
1741  void *lock;
1742  ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock);
1743 
1744  if (ibuf) {
1745  Scene *scene = opts->scene;
1746  bool is_depth_set = false;
1747 
1749  /* imtype */
1750  opts->im_format = scene->r.im_format;
1751  is_depth_set = true;
1752  if (!BKE_image_is_multiview(ima)) {
1753  /* In case multiview is disabled,
1754  * render settings would be invalid for render result in this area. */
1756  opts->im_format.views_format = ima->views_format;
1757  }
1758  }
1759  else {
1760  if (ima->source == IMA_SRC_GENERATED) {
1762  opts->im_format.compress = ibuf->foptions.quality;
1763  opts->im_format.planes = ibuf->planes;
1764  }
1765  else {
1766  BKE_imbuf_to_image_format(&opts->im_format, ibuf);
1767  }
1768 
1769  /* use the multiview image settings as the default */
1771  opts->im_format.views_format = ima->views_format;
1772  }
1773 
1774  BLI_strncpy(opts->filepath, ibuf->name, sizeof(opts->filepath));
1775 
1776  /* sanitize all settings */
1777 
1778  /* unlikely but just in case */
1781  }
1782 
1783  /* depth, account for float buffer and format support */
1784  if (is_depth_set == false) {
1785  opts->im_format.depth = imtype_best_depth(ibuf, opts->im_format.imtype);
1786  }
1787 
1788  /* some formats don't use quality so fallback to scenes quality */
1789  if (opts->im_format.quality == 0) {
1791  }
1792 
1793  /* check for empty path */
1794  if (guess_path && opts->filepath[0] == 0) {
1795  const bool is_prev_save = !STREQ(G.ima, "//");
1796  if (save_as_render) {
1797  if (is_prev_save) {
1798  BLI_strncpy(opts->filepath, G.ima, sizeof(opts->filepath));
1799  }
1800  else {
1801  BLI_strncpy(opts->filepath, "//untitled", sizeof(opts->filepath));
1803  }
1804  }
1805  else {
1806  BLI_snprintf(opts->filepath, sizeof(opts->filepath), "//%s", ima->id.name + 2);
1808  BLI_path_abs(opts->filepath, is_prev_save ? G.ima : BKE_main_blendfile_path(bmain));
1809  }
1810 
1811  /* append UDIM numbering if not present */
1812  if (ima->source == IMA_SRC_TILED &&
1813  (BLI_path_sequence_decode(ima->filepath, NULL, NULL, NULL) != 1001)) {
1814  int len = strlen(opts->filepath);
1815  STR_CONCAT(opts->filepath, len, ".1001");
1816  }
1817  }
1818 
1819  /* color management */
1822 
1825  }
1826 
1827  BKE_image_release_ibuf(ima, ibuf, lock);
1828 
1829  return (ibuf != NULL);
1830 }
1831 
1833  ImageSaveOptions *opts,
1834  wmOperator *op,
1835  ImageFormatData *imf)
1836 {
1837  if (imf) {
1839  opts->im_format = *imf;
1840  }
1841 
1842  if (RNA_struct_property_is_set(op->ptr, "filepath")) {
1843  RNA_string_get(op->ptr, "filepath", opts->filepath);
1845  }
1846 }
1847 
1849 {
1850  if (op->customdata) {
1851  ImageSaveData *isd = op->customdata;
1853  isd->im_format = opts->im_format;
1854  }
1855 
1856  RNA_string_set(op->ptr, "filepath", opts->filepath);
1857 }
1858 
1859 static bool save_image_op(
1860  Main *bmain, Image *ima, ImageUser *iuser, wmOperator *op, ImageSaveOptions *opts)
1861 {
1862  opts->relative = (RNA_struct_find_property(op->ptr, "relative_path") &&
1863  RNA_boolean_get(op->ptr, "relative_path"));
1864  opts->save_copy = (RNA_struct_find_property(op->ptr, "copy") &&
1865  RNA_boolean_get(op->ptr, "copy"));
1866  opts->save_as_render = (RNA_struct_find_property(op->ptr, "save_as_render") &&
1867  RNA_boolean_get(op->ptr, "save_as_render"));
1868 
1869  WM_cursor_wait(true);
1870 
1871  bool ok = BKE_image_save(op->reports, bmain, ima, iuser, opts);
1872 
1873  WM_cursor_wait(false);
1874 
1875  /* Remember file path for next save. */
1876  BLI_strncpy(G.ima, opts->filepath, sizeof(G.ima));
1877 
1879 
1880  return ok;
1881 }
1882 
1884 {
1885  if (op->customdata) {
1886  ImageSaveData *isd = op->customdata;
1888 
1889  MEM_freeN(op->customdata);
1890  op->customdata = NULL;
1891  }
1892 }
1893 
1895 {
1896  Main *bmain = CTX_data_main(C);
1898  ImageSaveOptions opts;
1899 
1900  Image *image = NULL;
1901  ImageUser *iuser = NULL;
1902  ImageFormatData *imf = NULL;
1903  if (op->customdata) {
1904  ImageSaveData *isd = op->customdata;
1905  image = isd->image;
1906  iuser = isd->iuser;
1907  imf = &isd->im_format;
1908  }
1909  else {
1910  image = image_from_context(C);
1911  iuser = image_user_from_context(C);
1912  }
1913 
1914  BKE_image_save_options_init(&opts, bmain, scene);
1915 
1916  /* just in case to initialize values,
1917  * these should be set on invoke or by the caller. */
1918  image_save_options_init(bmain, &opts, image, iuser, false, false);
1919 
1920  image_save_options_from_op(bmain, &opts, op, imf);
1921  opts.do_newpath = true;
1922 
1923  save_image_op(bmain, image, iuser, op, &opts);
1924 
1925  if (opts.save_copy == false) {
1927  }
1928 
1929  image_save_as_free(op);
1930 
1931  return OPERATOR_FINISHED;
1932 }
1933 
1935 {
1936  ImageSaveData *isd = op->customdata;
1938 }
1939 
1940 static int image_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
1941 {
1942  Main *bmain = CTX_data_main(C);
1943  Image *ima = image_from_context(C);
1946  ImageSaveOptions opts;
1947  PropertyRNA *prop;
1948  const bool save_as_render = (ima->source == IMA_SRC_VIEWER);
1949 
1950  if (RNA_struct_property_is_set(op->ptr, "filepath")) {
1951  return image_save_as_exec(C, op);
1952  }
1953 
1954  BKE_image_save_options_init(&opts, bmain, scene);
1955 
1956  if (image_save_options_init(bmain, &opts, ima, iuser, true, save_as_render) == 0) {
1957  return OPERATOR_CANCELLED;
1958  }
1959  image_save_options_to_op(&opts, op);
1960 
1961  /* enable save_copy by default for render results */
1963  !RNA_struct_property_is_set(op->ptr, "copy")) {
1964  RNA_boolean_set(op->ptr, "copy", true);
1965  }
1966 
1967  RNA_boolean_set(op->ptr, "save_as_render", save_as_render);
1968 
1969  ImageSaveData *isd = MEM_callocN(sizeof(*isd), __func__);
1970  isd->image = ima;
1971  isd->iuser = iuser;
1972 
1973  memcpy(&isd->im_format, &opts.im_format, sizeof(opts.im_format));
1974  op->customdata = isd;
1975 
1976  /* show multiview save options only if image has multiviews */
1977  prop = RNA_struct_find_property(op->ptr, "show_multiview");
1979  prop = RNA_struct_find_property(op->ptr, "use_multiview");
1981 
1982  image_filesel(C, op, opts.filepath);
1983 
1984  return OPERATOR_RUNNING_MODAL;
1985 }
1986 
1988 {
1989  image_save_as_free(op);
1990 }
1991 
1993  PropertyRNA *prop,
1994  void *UNUSED(user_data))
1995 {
1996  const char *prop_id = RNA_property_identifier(prop);
1997 
1998  return !(STREQ(prop_id, "filepath") || STREQ(prop_id, "directory") ||
1999  STREQ(prop_id, "filename") ||
2000  /* when saving a copy, relative path has no effect */
2001  ((STREQ(prop_id, "relative_path")) && RNA_boolean_get(ptr, "copy")));
2002 }
2003 
2005 {
2006  uiLayout *layout = op->layout;
2008  ImageSaveData *isd = op->customdata;
2009  PointerRNA imf_ptr, ptr;
2010  const bool is_multiview = RNA_boolean_get(op->ptr, "show_multiview");
2011 
2012  /* image template */
2014  uiTemplateImageSettings(layout, &imf_ptr, false);
2015 
2016  /* main draw call */
2017  RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
2020 
2021  /* multiview template */
2022  if (is_multiview) {
2023  uiTemplateImageFormatViews(layout, &imf_ptr, op->ptr);
2024  }
2025 }
2026 
2028 {
2030  return false;
2031  }
2032 
2033  if (G.is_rendering) {
2034  /* no need to NULL check here */
2035  Image *ima = image_from_context(C);
2036 
2037  if (ima->source == IMA_SRC_VIEWER) {
2038  CTX_wm_operator_poll_msg_set(C, "can't save image while rendering");
2039  return false;
2040  }
2041  }
2042 
2043  return true;
2044 }
2045 
2047 {
2048  /* identifiers */
2049  ot->name = "Save As Image";
2050  ot->idname = "IMAGE_OT_save_as";
2051  ot->description = "Save the image with another name and/or settings";
2052 
2053  /* api callbacks */
2060 
2061  /* flags */
2063 
2064  /* properties */
2066  "save_as_render",
2067  0,
2068  "Save As Render",
2069  "Apply render part of display transform when saving byte image");
2071  "copy",
2072  0,
2073  "Copy",
2074  "Create a new image file without modifying the current image in blender");
2075 
2078  FILE_SPECIAL,
2079  FILE_SAVE,
2083 }
2084 
2087 /* -------------------------------------------------------------------- */
2094 static bool image_file_format_writable(Image *ima, ImageUser *iuser)
2095 {
2096  void *lock;
2097  ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock);
2098  bool ret = false;
2099 
2100  if (ibuf && BKE_image_buffer_format_writable(ibuf)) {
2101  ret = true;
2102  }
2103 
2104  BKE_image_release_ibuf(ima, ibuf, lock);
2105  return ret;
2106 }
2107 
2109 {
2110  /* Can't save if there are no pixels. */
2111  if (image_from_context_has_data_poll(C) == false) {
2112  return false;
2113  }
2114 
2115  /* Check if there is a valid file path and image format we can write
2116  * outside of the 'poll' so we can show a report with a pop-up. */
2117 
2118  /* Can always repack images.
2119  * Images without a filepath will go to "Save As". */
2120  return true;
2121 }
2122 
2124 {
2125  Main *bmain = CTX_data_main(C);
2126  Image *image = image_from_context(C);
2129  ImageSaveOptions opts;
2130  bool ok = false;
2131 
2132  if (BKE_image_has_packedfile(image)) {
2133  /* Save packed files to memory. */
2134  BKE_image_memorypack(image);
2135  /* Report since this can be called from key shortcuts. */
2136  BKE_reportf(op->reports, RPT_INFO, "Packed to memory image \"%s\"", image->filepath);
2137  return OPERATOR_FINISHED;
2138  }
2139 
2140  BKE_image_save_options_init(&opts, bmain, scene);
2141  if (image_save_options_init(bmain, &opts, image, iuser, false, false) == 0) {
2142  return OPERATOR_CANCELLED;
2143  }
2144  image_save_options_from_op(bmain, &opts, op, NULL);
2145 
2146  /* Check if file write permission is ok. */
2147  if (BLI_exists(opts.filepath) && !BLI_file_is_writable(opts.filepath)) {
2148  BKE_reportf(
2149  op->reports, RPT_ERROR, "Cannot save image, path \"%s\" is not writable", opts.filepath);
2150  }
2151  else if (save_image_op(bmain, image, iuser, op, &opts)) {
2152  /* Report since this can be called from key shortcuts. */
2153  BKE_reportf(op->reports, RPT_INFO, "Saved image \"%s\"", opts.filepath);
2154  ok = true;
2155  }
2156 
2158 
2159  if (ok) {
2160  return OPERATOR_FINISHED;
2161  }
2162 
2163  return OPERATOR_CANCELLED;
2164 }
2165 
2166 static int image_save_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
2167 {
2168  Image *ima = image_from_context(C);
2170 
2171  /* Not writable formats or images without a file-path will go to "Save As". */
2172  if (!BKE_image_has_packedfile(ima) &&
2173  (!BKE_image_has_filepath(ima) || !image_file_format_writable(ima, iuser))) {
2174  WM_operator_name_call(C, "IMAGE_OT_save_as", WM_OP_INVOKE_DEFAULT, NULL);
2175  return OPERATOR_CANCELLED;
2176  }
2177  return image_save_exec(C, op);
2178 }
2179 
2181 {
2182  /* identifiers */
2183  ot->name = "Save Image";
2184  ot->idname = "IMAGE_OT_save";
2185  ot->description = "Save the image with current name and settings";
2186 
2187  /* api callbacks */
2188  ot->exec = image_save_exec;
2190  ot->poll = image_save_poll;
2191 
2192  /* flags */
2194 }
2195 
2198 /* -------------------------------------------------------------------- */
2203 {
2204  Main *bmain = CTX_data_main(C);
2205  Image *image = image_from_context(C);
2206  ImBuf *ibuf, *first_ibuf = NULL;
2207  int tot = 0;
2208  char di[FILE_MAX];
2209  struct MovieCacheIter *iter;
2210 
2211  if (image == NULL) {
2212  return OPERATOR_CANCELLED;
2213  }
2214 
2215  if (image->source != IMA_SRC_SEQUENCE) {
2216  BKE_report(op->reports, RPT_ERROR, "Can only save sequence on image sequences");
2217  return OPERATOR_CANCELLED;
2218  }
2219 
2220  if (image->type == IMA_TYPE_MULTILAYER) {
2221  BKE_report(op->reports, RPT_ERROR, "Cannot save multilayer sequences");
2222  return OPERATOR_CANCELLED;
2223  }
2224 
2225  /* get total dirty buffers and first dirty buffer which is used for menu */
2226  ibuf = NULL;
2227  if (image->cache != NULL) {
2228  iter = IMB_moviecacheIter_new(image->cache);
2229  while (!IMB_moviecacheIter_done(iter)) {
2230  ibuf = IMB_moviecacheIter_getImBuf(iter);
2231  if (ibuf->userflags & IB_BITMAPDIRTY) {
2232  if (first_ibuf == NULL) {
2233  first_ibuf = ibuf;
2234  }
2235  tot++;
2236  }
2238  }
2240  }
2241 
2242  if (tot == 0) {
2243  BKE_report(op->reports, RPT_WARNING, "No images have been changed");
2244  return OPERATOR_CANCELLED;
2245  }
2246 
2247  /* get a filename for menu */
2248  BLI_split_dir_part(first_ibuf->name, di, sizeof(di));
2249  BKE_reportf(op->reports, RPT_INFO, "%d image(s) will be saved in %s", tot, di);
2250 
2251  iter = IMB_moviecacheIter_new(image->cache);
2252  while (!IMB_moviecacheIter_done(iter)) {
2253  ibuf = IMB_moviecacheIter_getImBuf(iter);
2254 
2255  if (ibuf->userflags & IB_BITMAPDIRTY) {
2256  char name[FILE_MAX];
2257  BLI_strncpy(name, ibuf->name, sizeof(name));
2258 
2259  BLI_path_abs(name, BKE_main_blendfile_path(bmain));
2260 
2261  if (0 == IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat)) {
2262  BKE_reportf(op->reports, RPT_ERROR, "Could not write image: %s", strerror(errno));
2263  break;
2264  }
2265 
2266  BKE_reportf(op->reports, RPT_INFO, "Saved %s", ibuf->name);
2267  ibuf->userflags &= ~IB_BITMAPDIRTY;
2268  }
2269 
2271  }
2273 
2274  return OPERATOR_FINISHED;
2275 }
2276 
2278 {
2279  /* identifiers */
2280  ot->name = "Save Sequence";
2281  ot->idname = "IMAGE_OT_save_sequence";
2282  ot->description = "Save a sequence of images";
2283 
2284  /* api callbacks */
2287 
2288  /* flags */
2290 }
2291 
2294 /* -------------------------------------------------------------------- */
2299 {
2301 }
2302 
2303 static bool image_should_be_saved(Image *ima, bool *is_format_writable)
2304 {
2305  if (BKE_image_is_dirty_writable(ima, is_format_writable) &&
2308  }
2309  return false;
2310 }
2311 
2312 static bool image_has_valid_path(Image *ima)
2313 {
2314  return strchr(ima->filepath, '\\') || strchr(ima->filepath, '/');
2315 }
2316 
2318 {
2319  ReportList reports;
2320  BKE_reports_init(&reports, RPT_STORE);
2321 
2322  uint modified_images_count = ED_image_save_all_modified_info(bmain, &reports);
2323  bool should_save = modified_images_count || !BLI_listbase_is_empty(&reports.list);
2324 
2325  BKE_reports_clear(&reports);
2326 
2327  return should_save;
2328 }
2329 
2331 {
2332  GSet *unique_paths = BLI_gset_str_new(__func__);
2333 
2334  int num_saveable_images = 0;
2335 
2336  for (Image *ima = bmain->images.first; ima; ima = ima->id.next) {
2337  bool is_format_writable;
2338 
2339  if (image_should_be_saved(ima, &is_format_writable)) {
2340  if (BKE_image_has_packedfile(ima) || (ima->source == IMA_SRC_GENERATED)) {
2341  if (ima->id.lib == NULL) {
2342  num_saveable_images++;
2343  }
2344  else {
2345  BKE_reportf(reports,
2346  RPT_WARNING,
2347  "Packed library image can't be saved: \"%s\" from \"%s\"",
2348  ima->id.name + 2,
2349  ima->id.lib->filepath);
2350  }
2351  }
2352  else if (!is_format_writable) {
2353  BKE_reportf(reports,
2354  RPT_WARNING,
2355  "Image can't be saved, use a different file format: \"%s\"",
2356  ima->id.name + 2);
2357  }
2358  else {
2359  if (image_has_valid_path(ima)) {
2360  num_saveable_images++;
2361  if (BLI_gset_haskey(unique_paths, ima->filepath)) {
2362  BKE_reportf(reports,
2363  RPT_WARNING,
2364  "Multiple images can't be saved to an identical path: \"%s\"",
2365  ima->filepath);
2366  }
2367  else {
2368  BLI_gset_insert(unique_paths, BLI_strdup(ima->filepath));
2369  }
2370  }
2371  else {
2372  BKE_reportf(reports,
2373  RPT_WARNING,
2374  "Image can't be saved, no valid file path: \"%s\"",
2375  ima->filepath);
2376  }
2377  }
2378  }
2379  }
2380 
2381  BLI_gset_free(unique_paths, MEM_freeN);
2382  return num_saveable_images;
2383 }
2384 
2386 {
2387  Main *bmain = CTX_data_main(C);
2388 
2389  ED_image_save_all_modified_info(bmain, reports);
2390 
2391  bool ok = true;
2392 
2393  for (Image *ima = bmain->images.first; ima; ima = ima->id.next) {
2394  bool is_format_writable;
2395 
2396  if (image_should_be_saved(ima, &is_format_writable)) {
2397  if (BKE_image_has_packedfile(ima) || (ima->source == IMA_SRC_GENERATED)) {
2398  BKE_image_memorypack(ima);
2399  }
2400  else if (is_format_writable) {
2401  if (image_has_valid_path(ima)) {
2402  ImageSaveOptions opts;
2404  BKE_image_save_options_init(&opts, bmain, scene);
2405  if (image_save_options_init(bmain, &opts, ima, NULL, false, false)) {
2406  bool saved_successfully = BKE_image_save(reports, bmain, ima, NULL, &opts);
2407  ok = ok && saved_successfully;
2408  }
2409  }
2410  }
2411  }
2412  }
2413  return ok;
2414 }
2415 
2417 {
2419  return num_files > 0;
2420 }
2421 
2423 {
2425  return OPERATOR_FINISHED;
2426 }
2427 
2429 {
2430  /* identifiers */
2431  ot->name = "Save All Modified";
2432  ot->idname = "IMAGE_OT_save_all_modified";
2433  ot->description = "Save all modified images";
2434 
2435  /* api callbacks */
2438 
2439  /* flags */
2441 }
2442 
2445 /* -------------------------------------------------------------------- */
2450 {
2451  Main *bmain = CTX_data_main(C);
2452  Image *ima = image_from_context(C);
2454 
2455  if (!ima) {
2456  return OPERATOR_CANCELLED;
2457  }
2458 
2459  /* XXX BKE_packedfile_unpack_image frees image buffers */
2461 
2462  BKE_image_signal(bmain, ima, iuser, IMA_SIGNAL_RELOAD);
2463  DEG_id_tag_update(&ima->id, 0);
2464 
2466 
2467  return OPERATOR_FINISHED;
2468 }
2469 
2471 {
2472  /* identifiers */
2473  ot->name = "Reload Image";
2474  ot->idname = "IMAGE_OT_reload";
2475  ot->description = "Reload current image from disk";
2476 
2477  /* api callbacks */
2479 
2480  /* flags */
2481  ot->flag = OPTYPE_REGISTER; /* no undo, image buffer is not handled by undo */
2482 }
2483 
2486 /* -------------------------------------------------------------------- */
2490 #define IMA_DEF_NAME N_("Untitled")
2491 
2492 enum {
2496 };
2497 
2498 typedef struct ImageNewData {
2501 
2503 {
2504  if (op->customdata) {
2505  return op->customdata;
2506  }
2507 
2508  ImageNewData *data = MEM_callocN(sizeof(ImageNewData), __func__);
2509  UI_context_active_but_prop_get_templateID(C, &data->pprop.ptr, &data->pprop.prop);
2510  op->customdata = data;
2511  return data;
2512 }
2513 
2514 static void image_new_free(wmOperator *op)
2515 {
2516  if (op->customdata) {
2517  MEM_freeN(op->customdata);
2518  op->customdata = NULL;
2519  }
2520 }
2521 
2523 {
2524  SpaceImage *sima;
2525  Object *obedit;
2526  Image *ima;
2527  Main *bmain;
2528  PropertyRNA *prop;
2529  char name_buffer[MAX_ID_NAME - 2];
2530  const char *name;
2531  float color[4];
2532  int width, height, floatbuf, gen_type, alpha;
2533  int stereo3d;
2534 
2535  /* retrieve state */
2536  sima = CTX_wm_space_image(C);
2537  obedit = CTX_data_edit_object(C);
2538  bmain = CTX_data_main(C);
2539 
2540  prop = RNA_struct_find_property(op->ptr, "name");
2541  RNA_property_string_get(op->ptr, prop, name_buffer);
2542  if (!RNA_property_is_set(op->ptr, prop)) {
2543  /* Default value, we can translate! */
2544  name = DATA_(name_buffer);
2545  }
2546  else {
2547  name = name_buffer;
2548  }
2549  width = RNA_int_get(op->ptr, "width");
2550  height = RNA_int_get(op->ptr, "height");
2551  floatbuf = RNA_boolean_get(op->ptr, "float");
2552  gen_type = RNA_enum_get(op->ptr, "generated_type");
2553  RNA_float_get_array(op->ptr, "color", color);
2554  alpha = RNA_boolean_get(op->ptr, "alpha");
2555  stereo3d = RNA_boolean_get(op->ptr, "use_stereo_3d");
2556  bool tiled = RNA_boolean_get(op->ptr, "tiled");
2557 
2558  if (!alpha) {
2559  color[3] = 1.0f;
2560  }
2561 
2562  ima = BKE_image_add_generated(bmain,
2563  width,
2564  height,
2565  name,
2566  alpha ? 32 : 24,
2567  floatbuf,
2568  gen_type,
2569  color,
2570  stereo3d,
2571  false,
2572  tiled);
2573 
2574  if (!ima) {
2575  image_new_free(op);
2576  return OPERATOR_CANCELLED;
2577  }
2578 
2579  /* hook into UI */
2581 
2582  if (data->pprop.prop) {
2583  /* when creating new ID blocks, use is already 1, but RNA
2584  * pointer use also increases user, so this compensates it */
2585  id_us_min(&ima->id);
2586 
2587  PointerRNA imaptr;
2588  RNA_id_pointer_create(&ima->id, &imaptr);
2589  RNA_property_pointer_set(&data->pprop.ptr, data->pprop.prop, imaptr, NULL);
2590  RNA_property_update(C, &data->pprop.ptr, data->pprop.prop);
2591  }
2592  else if (sima) {
2593  ED_space_image_set(bmain, sima, obedit, ima, false);
2594  }
2595 
2596  BKE_image_signal(bmain, ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_USER_NEW_IMAGE);
2597 
2599 
2600  image_new_free(op);
2601 
2602  return OPERATOR_FINISHED;
2603 }
2604 
2605 static int image_new_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
2606 {
2607  /* Get property in advance, it doesn't work after WM_operator_props_dialog_popup. */
2608  ImageNewData *data;
2609  op->customdata = data = MEM_callocN(sizeof(ImageNewData), __func__);
2610  UI_context_active_but_prop_get_templateID(C, &data->pprop.ptr, &data->pprop.prop);
2611 
2612  /* Better for user feedback. */
2613  RNA_string_set(op->ptr, "name", DATA_(IMA_DEF_NAME));
2614  return WM_operator_props_dialog_popup(C, op, 300);
2615 }
2616 
2618 {
2619  uiLayout *col;
2620  uiLayout *layout = op->layout;
2622  PointerRNA ptr;
2623 #if 0
2625  const bool is_multiview = (scene->r.scemode & R_MULTIVIEW) != 0;
2626 #endif
2627 
2628  RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
2629 
2630  /* copy of WM_operator_props_dialog_popup() layout */
2631 
2632  uiLayoutSetPropSep(layout, true);
2633  uiLayoutSetPropDecorate(layout, false);
2634 
2635  col = uiLayoutColumn(layout, false);
2636  uiItemR(col, &ptr, "name", 0, NULL, ICON_NONE);
2637  uiItemR(col, &ptr, "width", 0, NULL, ICON_NONE);
2638  uiItemR(col, &ptr, "height", 0, NULL, ICON_NONE);
2639  uiItemR(col, &ptr, "color", 0, NULL, ICON_NONE);
2640  uiItemR(col, &ptr, "alpha", 0, NULL, ICON_NONE);
2641  uiItemR(col, &ptr, "generated_type", 0, NULL, ICON_NONE);
2642  uiItemR(col, &ptr, "float", 0, NULL, ICON_NONE);
2643  uiItemR(col, &ptr, "tiled", 0, NULL, ICON_NONE);
2644 
2645 #if 0
2646  if (is_multiview) {
2647  uiItemL(col[0], "", ICON_NONE);
2648  uiItemR(col[1], &ptr, "use_stereo_3d", 0, NULL, ICON_NONE);
2649  }
2650 #endif
2651 }
2652 
2654 {
2655  image_new_free(op);
2656 }
2657 
2659 {
2660  PropertyRNA *prop;
2661  static float default_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
2662 
2663  /* identifiers */
2664  ot->name = "New Image";
2665  ot->description = "Create a new image";
2666  ot->idname = "IMAGE_OT_new";
2667 
2668  /* api callbacks */
2669  ot->exec = image_new_exec;
2671  ot->ui = image_new_draw;
2673 
2674  /* flags */
2675  ot->flag = OPTYPE_UNDO;
2676 
2677  /* properties */
2678  RNA_def_string(ot->srna, "name", IMA_DEF_NAME, MAX_ID_NAME - 2, "Name", "Image data-block name");
2679  prop = RNA_def_int(ot->srna, "width", 1024, 1, INT_MAX, "Width", "Image width", 1, 16384);
2681  prop = RNA_def_int(ot->srna, "height", 1024, 1, INT_MAX, "Height", "Image height", 1, 16384);
2683  prop = RNA_def_float_color(
2684  ot->srna, "color", 4, NULL, 0.0f, FLT_MAX, "Color", "Default fill color", 0.0f, 1.0f);
2686  RNA_def_property_float_array_default(prop, default_color);
2687  RNA_def_boolean(ot->srna, "alpha", 1, "Alpha", "Create an image with an alpha channel");
2688  RNA_def_enum(ot->srna,
2689  "generated_type",
2692  "Generated Type",
2693  "Fill the image with a grid for UV map testing");
2695  ot->srna, "float", 0, "32-bit Float", "Create image with 32-bit floating-point bit depth");
2697  prop = RNA_def_boolean(
2698  ot->srna, "use_stereo_3d", 0, "Stereo 3D", "Create an image with left and right views");
2700  prop = RNA_def_boolean(ot->srna, "tiled", 0, "Tiled", "Create a tiled image");
2702 }
2703 
2704 #undef IMA_DEF_NAME
2705 
2708 /* -------------------------------------------------------------------- */
2713 {
2714  Image *ima = image_from_context(C);
2715  ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
2716  SpaceImage *sima = CTX_wm_space_image(C);
2717  const bool is_paint = ((sima != NULL) && (sima->mode == SI_MODE_PAINT));
2718 
2719  if (ibuf == NULL) {
2720  /* TODO: this should actually never happen, but does for render-results -> cleanup. */
2721  return OPERATOR_CANCELLED;
2722  }
2723 
2724  const bool flip_horizontal = RNA_boolean_get(op->ptr, "use_flip_horizontal");
2725  const bool flip_vertical = RNA_boolean_get(op->ptr, "use_flip_vertical");
2726 
2727  if (!flip_horizontal && !flip_vertical) {
2728  BKE_image_release_ibuf(ima, ibuf, NULL);
2729  return OPERATOR_FINISHED;
2730  }
2731 
2732  ED_image_undo_push_begin_with_image(op->type->name, ima, ibuf, &sima->iuser);
2733 
2734  if (is_paint) {
2736  }
2737 
2738  const int size_x = ibuf->x;
2739  const int size_y = ibuf->y;
2740 
2741  if (ibuf->rect_float) {
2742  float *float_pixels = (float *)ibuf->rect_float;
2743 
2744  float *orig_float_pixels = MEM_dupallocN(float_pixels);
2745  for (int x = 0; x < size_x; x++) {
2746  for (int y = 0; y < size_y; y++) {
2747  const int source_pixel_x = flip_horizontal ? size_x - x - 1 : x;
2748  const int source_pixel_y = flip_vertical ? size_y - y - 1 : y;
2749 
2750  float *source_pixel = &orig_float_pixels[4 * (source_pixel_x + source_pixel_y * size_x)];
2751  float *target_pixel = &float_pixels[4 * (x + y * size_x)];
2752 
2753  copy_v4_v4(target_pixel, source_pixel);
2754  }
2755  }
2756  MEM_freeN(orig_float_pixels);
2757 
2758  if (ibuf->rect) {
2759  IMB_rect_from_float(ibuf);
2760  }
2761  }
2762  else if (ibuf->rect) {
2763  char *char_pixels = (char *)ibuf->rect;
2764  char *orig_char_pixels = MEM_dupallocN(char_pixels);
2765  for (int x = 0; x < size_x; x++) {
2766  for (int y = 0; y < size_y; y++) {
2767  const int source_pixel_x = flip_horizontal ? size_x - x - 1 : x;
2768  const int source_pixel_y = flip_vertical ? size_y - y - 1 : y;
2769 
2770  char *source_pixel = &orig_char_pixels[4 * (source_pixel_x + source_pixel_y * size_x)];
2771  char *target_pixel = &char_pixels[4 * (x + y * size_x)];
2772 
2773  copy_v4_v4_char(target_pixel, source_pixel);
2774  }
2775  }
2776  MEM_freeN(orig_char_pixels);
2777  }
2778  else {
2779  BKE_image_release_ibuf(ima, ibuf, NULL);
2780  return OPERATOR_CANCELLED;
2781  }
2782 
2784  BKE_image_mark_dirty(ima, ibuf);
2785 
2786  if (ibuf->mipmap[0]) {
2787  ibuf->userflags |= IB_MIPMAP_INVALID;
2788  }
2789 
2791 
2792  /* force GPU re-upload, all image is invalid. */
2794 
2796 
2797  BKE_image_release_ibuf(ima, ibuf, NULL);
2798 
2799  return OPERATOR_FINISHED;
2800 }
2801 
2803 {
2804  /* identifiers */
2805  ot->name = "Flip Image";
2806  ot->idname = "IMAGE_OT_flip";
2807  ot->description = "Flip the image";
2808 
2809  /* api callbacks */
2810  ot->exec = image_flip_exec;
2812 
2813  /* properties */
2814  PropertyRNA *prop;
2815  prop = RNA_def_boolean(
2816  ot->srna, "use_flip_horizontal", false, "Horizontal", "Flip the image horizontally");
2818  prop = RNA_def_boolean(
2819  ot->srna, "use_flip_vertical", false, "Vertical", "Flip the image vertically");
2821 
2822  /* flags */
2823  ot->flag = OPTYPE_REGISTER;
2824 }
2825 
2828 /* -------------------------------------------------------------------- */
2833 {
2834  Image *ima = image_from_context(C);
2835  ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
2836  SpaceImage *sima = CTX_wm_space_image(C);
2837  const bool is_paint = ((sima != NULL) && (sima->mode == SI_MODE_PAINT));
2838 
2839  /* flags indicate if this channel should be inverted */
2840  const bool r = RNA_boolean_get(op->ptr, "invert_r");
2841  const bool g = RNA_boolean_get(op->ptr, "invert_g");
2842  const bool b = RNA_boolean_get(op->ptr, "invert_b");
2843  const bool a = RNA_boolean_get(op->ptr, "invert_a");
2844 
2845  size_t i;
2846 
2847  if (ibuf == NULL) {
2848  /* TODO: this should actually never happen, but does for render-results -> cleanup */
2849  return OPERATOR_CANCELLED;
2850  }
2851 
2852  ED_image_undo_push_begin_with_image(op->type->name, ima, ibuf, &sima->iuser);
2853 
2854  if (is_paint) {
2856  }
2857 
2858  /* TODO: make this into an IMB_invert_channels(ibuf,r,g,b,a) method!? */
2859  if (ibuf->rect_float) {
2860 
2861  float *fp = (float *)ibuf->rect_float;
2862  for (i = ((size_t)ibuf->x) * ibuf->y; i > 0; i--, fp += 4) {
2863  if (r) {
2864  fp[0] = 1.0f - fp[0];
2865  }
2866  if (g) {
2867  fp[1] = 1.0f - fp[1];
2868  }
2869  if (b) {
2870  fp[2] = 1.0f - fp[2];
2871  }
2872  if (a) {
2873  fp[3] = 1.0f - fp[3];
2874  }
2875  }
2876 
2877  if (ibuf->rect) {
2878  IMB_rect_from_float(ibuf);
2879  }
2880  }
2881  else if (ibuf->rect) {
2882 
2883  char *cp = (char *)ibuf->rect;
2884  for (i = ((size_t)ibuf->x) * ibuf->y; i > 0; i--, cp += 4) {
2885  if (r) {
2886  cp[0] = 255 - cp[0];
2887  }
2888  if (g) {
2889  cp[1] = 255 - cp[1];
2890  }
2891  if (b) {
2892  cp[2] = 255 - cp[2];
2893  }
2894  if (a) {
2895  cp[3] = 255 - cp[3];
2896  }
2897  }
2898  }
2899  else {
2900  BKE_image_release_ibuf(ima, ibuf, NULL);
2901  return OPERATOR_CANCELLED;
2902  }
2903 
2905  BKE_image_mark_dirty(ima, ibuf);
2906 
2907  if (ibuf->mipmap[0]) {
2908  ibuf->userflags |= IB_MIPMAP_INVALID;
2909  }
2910 
2912 
2913  /* Force GPU re-upload, all image is invalid. */
2915 
2917 
2918  BKE_image_release_ibuf(ima, ibuf, NULL);
2919 
2920  return OPERATOR_FINISHED;
2921 }
2922 
2924 {
2925  PropertyRNA *prop;
2926 
2927  /* identifiers */
2928  ot->name = "Invert Channels";
2929  ot->idname = "IMAGE_OT_invert";
2930  ot->description = "Invert image's channels";
2931 
2932  /* api callbacks */
2935 
2936  /* properties */
2937  prop = RNA_def_boolean(ot->srna, "invert_r", 0, "Red", "Invert red channel");
2939  prop = RNA_def_boolean(ot->srna, "invert_g", 0, "Green", "Invert green channel");
2941  prop = RNA_def_boolean(ot->srna, "invert_b", 0, "Blue", "Invert blue channel");
2943  prop = RNA_def_boolean(ot->srna, "invert_a", 0, "Alpha", "Invert alpha channel");
2945 
2946  /* flags */
2947  ot->flag = OPTYPE_REGISTER;
2948 }
2949 
2952 /* -------------------------------------------------------------------- */
2956 static int image_scale_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
2957 {
2958  Image *ima = image_from_context(C);
2959  PropertyRNA *prop = RNA_struct_find_property(op->ptr, "size");
2960  if (!RNA_property_is_set(op->ptr, prop)) {
2961  ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
2962  const int size[2] = {ibuf->x, ibuf->y};
2963  RNA_property_int_set_array(op->ptr, prop, size);
2964  BKE_image_release_ibuf(ima, ibuf, NULL);
2965  }
2966  return WM_operator_props_dialog_popup(C, op, 200);
2967 }
2968 
2970 {
2971  Image *ima = image_from_context(C);
2972  ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
2973  SpaceImage *sima = CTX_wm_space_image(C);
2974  const bool is_paint = ((sima != NULL) && (sima->mode == SI_MODE_PAINT));
2975 
2976  if (ibuf == NULL) {
2977  /* TODO: this should actually never happen, but does for render-results -> cleanup */
2978  return OPERATOR_CANCELLED;
2979  }
2980 
2981  if (is_paint) {
2983  }
2984 
2985  PropertyRNA *prop = RNA_struct_find_property(op->ptr, "size");
2986  int size[2];
2987  if (RNA_property_is_set(op->ptr, prop)) {
2988  RNA_property_int_get_array(op->ptr, prop, size);
2989  }
2990  else {
2991  size[0] = ibuf->x;
2992  size[1] = ibuf->y;
2993  RNA_property_int_set_array(op->ptr, prop, size);
2994  }
2995 
2996  ED_image_undo_push_begin_with_image(op->type->name, ima, ibuf, &sima->iuser);
2997 
2999  IMB_scaleImBuf(ibuf, size[0], size[1]);
3000  BKE_image_release_ibuf(ima, ibuf, NULL);
3001 
3003 
3004  /* Force GPU re-upload, all image is invalid. */
3006 
3007  DEG_id_tag_update(&ima->id, 0);
3009 
3010  return OPERATOR_FINISHED;
3011 }
3012 
3014 {
3015  /* identifiers */
3016  ot->name = "Resize Image";
3017  ot->idname = "IMAGE_OT_resize";
3018  ot->description = "Resize the image";
3019 
3020  /* api callbacks */
3024 
3025  /* properties */
3026  RNA_def_int_vector(ot->srna, "size", 2, NULL, 1, INT_MAX, "Size", "", 1, SHRT_MAX);
3027 
3028  /* flags */
3029  ot->flag = OPTYPE_REGISTER;
3030 }
3031 
3034 /* -------------------------------------------------------------------- */
3039 {
3040  Image *ima = image_from_context(C);
3041 
3042  if (!ima) {
3043  return false;
3044  }
3045 
3047  BKE_report(
3048  op->reports, RPT_ERROR, "Packing movies, image sequences or tiled images not supported");
3049  return false;
3050  }
3051 
3052  return true;
3053 }
3054 
3056 {
3057  struct Main *bmain = CTX_data_main(C);
3058  Image *ima = image_from_context(C);
3059 
3060  if (!image_pack_test(C, op)) {
3061  return OPERATOR_CANCELLED;
3062  }
3063 
3064  if (BKE_image_is_dirty(ima)) {
3065  BKE_image_memorypack(ima);
3066  }
3067  else {
3068  BKE_image_packfiles(op->reports, ima, ID_BLEND_PATH(bmain, &ima->id));
3069  }
3070 
3072 
3073  return OPERATOR_FINISHED;
3074 }
3075 
3077 {
3078  /* identifiers */
3079  ot->name = "Pack Image";
3080  ot->description = "Pack an image as embedded data into the .blend file";
3081  ot->idname = "IMAGE_OT_pack";
3082 
3083  /* api callbacks */
3084  ot->exec = image_pack_exec;
3085 
3086  /* flags */
3088 }
3089 
3092 /* -------------------------------------------------------------------- */
3097 {
3098  Main *bmain = CTX_data_main(C);
3099  Image *ima = image_from_context(C);
3100  int method = RNA_enum_get(op->ptr, "method");
3101 
3102  /* find the supplied image by name */
3103  if (RNA_struct_property_is_set(op->ptr, "id")) {
3104  char imaname[MAX_ID_NAME - 2];
3105  RNA_string_get(op->ptr, "id", imaname);
3106  ima = BLI_findstring(&bmain->images, imaname, offsetof(ID, name) + 2);
3107  if (!ima) {
3108  ima = image_from_context(C);
3109  }
3110  }
3111 
3112  if (!ima || !BKE_image_has_packedfile(ima)) {
3113  return OPERATOR_CANCELLED;
3114  }
3115 
3117  BKE_report(
3118  op->reports, RPT_ERROR, "Unpacking movies, image sequences or tiled images not supported");
3119  return OPERATOR_CANCELLED;
3120  }
3121 
3122  if (G.fileflags & G_FILE_AUTOPACK) {
3123  BKE_report(op->reports,
3124  RPT_WARNING,
3125  "AutoPack is enabled, so image will be packed again on file save");
3126  }
3127 
3128  /* XXX BKE_packedfile_unpack_image frees image buffers */
3130 
3131  BKE_packedfile_unpack_image(CTX_data_main(C), op->reports, ima, method);
3132 
3134 
3135  return OPERATOR_FINISHED;
3136 }
3137 
3138 static int image_unpack_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
3139 {
3140  Image *ima = image_from_context(C);
3141 
3142  if (RNA_struct_property_is_set(op->ptr, "id")) {
3143  return image_unpack_exec(C, op);
3144  }
3145 
3146  if (!ima || !BKE_image_has_packedfile(ima)) {
3147  return OPERATOR_CANCELLED;
3148  }
3149 
3151  BKE_report(
3152  op->reports, RPT_ERROR, "Unpacking movies, image sequences or tiled images not supported");
3153  return OPERATOR_CANCELLED;
3154  }
3155 
3156  if (G.fileflags & G_FILE_AUTOPACK) {
3157  BKE_report(op->reports,
3158  RPT_WARNING,
3159  "AutoPack is enabled, so image will be packed again on file save");
3160  }
3161 
3162  unpack_menu(C,
3163  "IMAGE_OT_unpack",
3164  ima->id.name + 2,
3165  ima->filepath,
3166  "textures",
3168  ((ImagePackedFile *)ima->packedfiles.first)->packedfile :
3169  NULL);
3170 
3171  return OPERATOR_FINISHED;
3172 }
3173 
3175 {
3176  /* identifiers */
3177  ot->name = "Unpack Image";
3178  ot->description = "Save an image packed in the .blend file to disk";
3179  ot->idname = "IMAGE_OT_unpack";
3180 
3181  /* api callbacks */
3184 
3185  /* flags */
3187 
3188  /* properties */
3189  RNA_def_enum(
3190  ot->srna, "method", rna_enum_unpack_method_items, PF_USE_LOCAL, "Method", "How to unpack");
3191  /* XXX, weak!, will fail with library, name collisions */
3193  ot->srna, "id", NULL, MAX_ID_NAME - 2, "Image Name", "Image data-block name to unpack");
3194 }
3195 
3198 /* -------------------------------------------------------------------- */
3202 /* Returns mouse position in image space. */
3203 bool ED_space_image_get_position(SpaceImage *sima, struct ARegion *ar, int mval[2], float fpos[2])
3204 {
3205  void *lock;
3206  ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock, 0);
3207 
3208  if (ibuf == NULL) {
3209  ED_space_image_release_buffer(sima, ibuf, lock);
3210  return false;
3211  }
3212 
3213  UI_view2d_region_to_view(&ar->v2d, mval[0], mval[1], &fpos[0], &fpos[1]);
3214 
3215  ED_space_image_release_buffer(sima, ibuf, lock);
3216  return true;
3217 }
3218 
3219 /* Returns color in linear space, matching ED_space_node_color_sample(). */
3221  SpaceImage *sima, ARegion *region, int mval[2], float r_col[3], bool *r_is_data)
3222 {
3223  if (r_is_data) {
3224  *r_is_data = false;
3225  }
3226  if (sima->image == NULL) {
3227  return false;
3228  }
3229  float uv[2];
3230  UI_view2d_region_to_view(&region->v2d, mval[0], mval[1], &uv[0], &uv[1]);
3231  int tile = BKE_image_get_tile_from_pos(sima->image, uv, uv, NULL);
3232 
3233  void *lock;
3234  ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock, tile);
3235  bool ret = false;
3236 
3237  if (ibuf == NULL) {
3238  ED_space_image_release_buffer(sima, ibuf, lock);
3239  return false;
3240  }
3241 
3242  if (uv[0] >= 0.0f && uv[1] >= 0.0f && uv[0] < 1.0f && uv[1] < 1.0f) {
3243  const float *fp;
3244  uchar *cp;
3245  int x = (int)(uv[0] * ibuf->x), y = (int)(uv[1] * ibuf->y);
3246 
3247  CLAMP(x, 0, ibuf->x - 1);
3248  CLAMP(y, 0, ibuf->y - 1);
3249 
3250  if (ibuf->rect_float) {
3251  fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
3252  copy_v3_v3(r_col, fp);
3253  ret = true;
3254  }
3255  else if (ibuf->rect) {
3256  cp = (uchar *)(ibuf->rect + y * ibuf->x + x);
3257  rgb_uchar_to_float(r_col, cp);
3259  ret = true;
3260  }
3261  }
3262 
3263  if (r_is_data) {
3264  *r_is_data = (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) != 0;
3265  }
3266 
3267  ED_space_image_release_buffer(sima, ibuf, lock);
3268  return ret;
3269 }
3270 
3272 {
3273  /* identifiers */
3274  ot->name = "Sample Color";
3275  ot->idname = "IMAGE_OT_sample";
3276  ot->description = "Use mouse to sample a color in current image";
3277 
3278  /* api callbacks */
3283 
3284  /* flags */
3285  ot->flag = OPTYPE_BLOCKING;
3286 
3287  PropertyRNA *prop;
3288  prop = RNA_def_int(ot->srna, "size", 1, 1, 128, "Sample Size", "", 1, 64);
3291 }
3292 
3295 /* -------------------------------------------------------------------- */
3300 {
3301  SpaceImage *sima = CTX_wm_space_image(C);
3302  ARegion *region = CTX_wm_region(C);
3304  Image *ima = ED_space_image(sima);
3305 
3306  int x_start = RNA_int_get(op->ptr, "xstart");
3307  int y_start = RNA_int_get(op->ptr, "ystart");
3308  int x_end = RNA_int_get(op->ptr, "xend");
3309  int y_end = RNA_int_get(op->ptr, "yend");
3310 
3311  float uv1[2], uv2[2], ofs[2];
3312  UI_view2d_region_to_view(&region->v2d, x_start, y_start, &uv1[0], &uv1[1]);
3313  UI_view2d_region_to_view(&region->v2d, x_end, y_end, &uv2[0], &uv2[1]);
3314 
3315  /* If the image has tiles, shift the positions accordingly. */
3316  int tile = BKE_image_get_tile_from_pos(ima, uv1, uv1, ofs);
3317  sub_v2_v2(uv2, ofs);
3318 
3319  void *lock;
3320  ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock, tile);
3321  Histogram *hist = &sima->sample_line_hist;
3322 
3323  if (ibuf == NULL) {
3324  ED_space_image_release_buffer(sima, ibuf, lock);
3325  return OPERATOR_CANCELLED;
3326  }
3327  /* hmmmm */
3328  if (ibuf->channels < 3) {
3329  ED_space_image_release_buffer(sima, ibuf, lock);
3330  return OPERATOR_CANCELLED;
3331  }
3332 
3333  copy_v2_v2(hist->co[0], uv1);
3334  copy_v2_v2(hist->co[1], uv2);
3335 
3336  /* enable line drawing */
3337  hist->flag |= HISTO_FLAG_SAMPLELINE;
3338 
3340 
3341  /* reset y zoom */
3342  hist->ymax = 1.0f;
3343 
3344  ED_space_image_release_buffer(sima, ibuf, lock);
3345 
3347 
3348  return OPERATOR_FINISHED;
3349 }
3350 
3351 static int image_sample_line_invoke(bContext *C, wmOperator *op, const wmEvent *event)
3352 {
3353  SpaceImage *sima = CTX_wm_space_image(C);
3354 
3355  Histogram *hist = &sima->sample_line_hist;
3356  hist->flag &= ~HISTO_FLAG_SAMPLELINE;
3357 
3358  if (!ED_space_image_has_buffer(sima)) {
3359  return OPERATOR_CANCELLED;
3360  }
3361 
3362  return WM_gesture_straightline_invoke(C, op, event);
3363 }
3364 
3366 {
3367  /* identifiers */
3368  ot->name = "Sample Line";
3369  ot->idname = "IMAGE_OT_sample_line";
3370  ot->description = "Sample a line and show it in Scope panels";
3371 
3372  /* api callbacks */
3378 
3379  /* flags */
3380  ot->flag = 0; /* no undo/register since this operates on the space */
3381 
3383 }
3384 
3387 /* -------------------------------------------------------------------- */
3392 {
3393  static const EnumPropertyItem point_items[] = {
3394  {0, "BLACK_POINT", 0, "Black Point", ""},
3395  {1, "WHITE_POINT", 0, "White Point", ""},
3396  {0, NULL, 0, NULL, NULL},
3397  };
3398 
3399  /* identifiers */
3400  ot->name = "Set Curves Point";
3401  ot->idname = "IMAGE_OT_curves_point_set";
3402  ot->description = "Set black point or white point for curves";
3403 
3404  /* flags */
3406 
3407  /* api callbacks */
3412 
3413  /* properties */
3414  RNA_def_enum(
3415  ot->srna, "point", point_items, 0, "Point", "Set black point or white point for curves");
3416 
3417  PropertyRNA *prop;
3418  prop = RNA_def_int(ot->srna, "size", 1, 1, 128, "Sample Size", "", 1, 64);
3421 }
3422 
3425 /* -------------------------------------------------------------------- */
3430 {
3431  Image *ima = image_from_context(C);
3432 
3433  return (ima && ima->type == IMA_TYPE_R_RESULT);
3434 }
3435 
3437 {
3438  Image *ima = image_from_context(C);
3439  const int direction = RNA_boolean_get(op->ptr, "reverse") ? -1 : 1;
3440 
3441  if (!ED_image_slot_cycle(ima, direction)) {
3442  return OPERATOR_CANCELLED;
3443  }
3444 
3446 
3447  /* no undo push for browsing existing */
3448  RenderSlot *slot = BKE_image_get_renderslot(ima, ima->render_slot);
3449  if ((slot && slot->render) || ima->render_slot == ima->last_render_slot) {
3450  return OPERATOR_CANCELLED;
3451  }
3452 
3453  return OPERATOR_FINISHED;
3454 }
3455 
3457 {
3458  /* identifiers */
3459  ot->name = "Cycle Render Slot";
3460  ot->idname = "IMAGE_OT_cycle_render_slot";
3461  ot->description = "Cycle through all non-void render slots";
3462 
3463  /* api callbacks */
3466 
3467  /* flags */
3468  ot->flag = OPTYPE_REGISTER;
3469 
3470  RNA_def_boolean(ot->srna, "reverse", 0, "Cycle in Reverse", "");
3471 }
3472 
3475 /* -------------------------------------------------------------------- */
3480 {
3481  SpaceImage *sima = CTX_wm_space_image(C);
3482  Image *ima = image_from_context(C);
3483 
3484  if (!BKE_image_clear_renderslot(ima, &sima->iuser, ima->render_slot)) {
3485  return OPERATOR_CANCELLED;
3486  }
3487 
3489 
3490  return OPERATOR_FINISHED;
3491 }
3492 
3494 {
3495  /* identifiers */
3496  ot->name = "Clear Render Slot";
3497  ot->idname = "IMAGE_OT_clear_render_slot";
3498  ot->description = "Clear the currently selected render slot";
3499 
3500  /* api callbacks */
3503 
3504  /* flags */
3505  ot->flag = OPTYPE_REGISTER;
3506 }
3507 
3510 /* -------------------------------------------------------------------- */
3515 {
3516  Image *ima = image_from_context(C);
3517 
3519  ima->render_slot = BLI_findindex(&ima->renderslots, slot);
3520 
3522 
3523  return OPERATOR_FINISHED;
3524 }
3525 
3527 {
3528  /* identifiers */
3529  ot->name = "Add Render Slot";
3530  ot->idname = "IMAGE_OT_add_render_slot";
3531  ot->description = "Add a new render slot";
3532 
3533  /* api callbacks */
3536 
3537  /* flags */
3538  ot->flag = OPTYPE_REGISTER;
3539 }
3540 
3543 /* -------------------------------------------------------------------- */
3548 {
3549  SpaceImage *sima = CTX_wm_space_image(C);
3550  Image *ima = image_from_context(C);
3551 
3552  if (!BKE_image_remove_renderslot(ima, &sima->iuser, ima->render_slot)) {
3553  return OPERATOR_CANCELLED;
3554  }
3555 
3557 
3558  return OPERATOR_FINISHED;
3559 }
3560 
3562 {
3563  /* identifiers */
3564  ot->name = "Remove Render Slot";
3565  ot->idname = "IMAGE_OT_remove_render_slot";
3566  ot->description = "Remove the current render slot";
3567 
3568  /* api callbacks */
3571 
3572  /* flags */
3573  ot->flag = OPTYPE_REGISTER;
3574 }
3575 
3578 /* -------------------------------------------------------------------- */
3583 {
3584  /* prevent changes during render */
3585  if (G.is_rendering) {
3586  return 0;
3587  }
3588 
3590 }
3591 
3593 {
3595 
3596  /* set the new frame number */
3597  CFRA = RNA_int_get(op->ptr, "frame");
3599  SUBFRA = 0.0f;
3600 
3601  /* do updates */
3604 }
3605 
3607 {
3608  change_frame_apply(C, op);
3609 
3610  return OPERATOR_FINISHED;
3611 }
3612 
3613 static int frame_from_event(bContext *C, const wmEvent *event)
3614 {
3615  ARegion *region = CTX_wm_region(C);
3617  int framenr = 0;
3618 
3619  if (region->regiontype == RGN_TYPE_WINDOW) {
3620  float sfra = SFRA, efra = EFRA, framelen = region->winx / (efra - sfra + 1);
3621 
3622  framenr = sfra + event->mval[0] / framelen;
3623  }
3624  else {
3625  float viewx, viewy;
3626 
3627  UI_view2d_region_to_view(&region->v2d, event->mval[0], event->mval[1], &viewx, &viewy);
3628 
3629  framenr = round_fl_to_int(viewx);
3630  }
3631 
3632  return framenr;
3633 }
3634 
3635 static int change_frame_invoke(bContext *C, wmOperator *op, const wmEvent *event)
3636 {
3637  ARegion *region = CTX_wm_region(C);
3638 
3639  if (region->regiontype == RGN_TYPE_WINDOW) {
3640  SpaceImage *sima = CTX_wm_space_image(C);
3641 
3642  /* Local coordinate visible rect inside region, to accommodate overlapping ui. */
3643  const rcti *rect_visible = ED_region_visible_rect(region);
3644  const int region_bottom = rect_visible->ymin;
3645 
3646  if (event->mval[1] > (region_bottom + 16 * UI_DPI_FAC) || !ED_space_image_show_cache(sima)) {
3647  return OPERATOR_PASS_THROUGH;
3648  }
3649  }
3650 
3651  RNA_int_set(op->ptr, "frame", frame_from_event(C, event));
3652 
3653  change_frame_apply(C, op);
3654 
3655  /* add temp handler */
3657 
3658  return OPERATOR_RUNNING_MODAL;
3659 }
3660 
3661 static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event)
3662 {
3663  switch (event->type) {
3664  case EVT_ESCKEY:
3665  return OPERATOR_FINISHED;
3666 
3667  case MOUSEMOVE:
3668  RNA_int_set(op->ptr, "frame", frame_from_event(C, event));
3669  change_frame_apply(C, op);
3670  break;
3671 
3672  case LEFTMOUSE:
3673  case RIGHTMOUSE:
3674  if (event->val == KM_RELEASE) {
3675  return OPERATOR_FINISHED;
3676  }
3677  break;
3678  }
3679 
3680  return OPERATOR_RUNNING_MODAL;
3681 }
3682 
3684 {
3685  /* identifiers */
3686  ot->name = "Change Frame";
3687  ot->idname = "IMAGE_OT_change_frame";
3688  ot->description = "Interactively change the current frame number";
3689 
3690  /* api callbacks */
3695 
3696  /* flags */
3698 
3699  /* rna */
3700  RNA_def_int(ot->srna, "frame", 0, MINAFRAME, MAXFRAME, "Frame", "", MINAFRAME, MAXFRAME);
3701 }
3702 
3703 /* Reload cached render results... */
3704 /* goes over all scenes, reads render layers */
3706 {
3707  Main *bmain = CTX_data_main(C);
3709  SpaceImage *sima = CTX_wm_space_image(C);
3710  Image *ima;
3711 
3712  ima = BKE_image_ensure_viewer(bmain, IMA_TYPE_R_RESULT, "Render Result");
3713  if (sima->image == NULL) {
3714  ED_space_image_set(bmain, sima, NULL, ima, false);
3715  }
3716 
3718 
3720  return OPERATOR_FINISHED;
3721 }
3722 
3724 {
3725  ot->name = "Open Cached Render";
3726  ot->idname = "IMAGE_OT_read_viewlayers";
3727  ot->description = "Read all the current scene's view layers from cache, as needed";
3728 
3731 
3732  /* flags */
3733  ot->flag = 0;
3734 }
3735 
3738 /* -------------------------------------------------------------------- */
3743 {
3744  ARegion *region = CTX_wm_region(C);
3747  RenderData *rd;
3748  rctf border;
3749 
3750  if (re == NULL) {
3751  /* Shouldn't happen, but better be safe close to the release. */
3752  return OPERATOR_CANCELLED;
3753  }
3754 
3755  rd = RE_engine_get_render_data(re);
3756  if ((rd->mode & (R_BORDER | R_CROP)) == (R_BORDER | R_CROP)) {
3757  BKE_report(op->reports, RPT_INFO, "Can not set border from a cropped render");
3758  return OPERATOR_CANCELLED;
3759  }
3760 
3761  /* get rectangle from operator */
3764 
3765  /* actually set border */
3766  CLAMP(border.xmin, 0.0f, 1.0f);
3767  CLAMP(border.ymin, 0.0f, 1.0f);
3768  CLAMP(border.xmax, 0.0f, 1.0f);
3769  CLAMP(border.ymax, 0.0f, 1.0f);
3770  scene->r.border = border;
3771 
3772  /* drawing a border surrounding the entire camera view switches off border rendering
3773  * or the border covers no pixels */
3774  if ((border.xmin <= 0.0f && border.xmax >= 1.0f && border.ymin <= 0.0f && border.ymax >= 1.0f) ||
3775  (border.xmin == border.xmax || border.ymin == border.ymax)) {
3776  scene->r.mode &= ~R_BORDER;
3777  }
3778  else {
3779  scene->r.mode |= R_BORDER;
3780  }
3781 
3784 
3785  return OPERATOR_FINISHED;
3786 }
3787 
3789 {
3790  /* identifiers */
3791  ot->name = "Render Region";
3792  ot->description = "Set the boundaries of the render region and enable render region";
3793  ot->idname = "IMAGE_OT_render_border";
3794 
3795  /* api callbacks */
3801 
3802  /* flags */
3804 
3805  /* rna */
3807 }
3808 
3811 /* -------------------------------------------------------------------- */
3816 {
3818  scene->r.mode &= ~R_BORDER;
3820  BLI_rctf_init(&scene->r.border, 0.0f, 1.0f, 0.0f, 1.0f);
3821  return OPERATOR_FINISHED;
3822 }
3823 
3825 {
3826  /* identifiers */
3827  ot->name = "Clear Render Region";
3828  ot->description = "Clear the boundaries of the render region and disable render region";
3829  ot->idname = "IMAGE_OT_clear_render_border";
3830 
3831  /* api callbacks */
3834 
3835  /* flags */
3837 }
3838 
3841 /* -------------------------------------------------------------------- */
3845 static bool do_fill_tile(PointerRNA *ptr, Image *ima, ImageTile *tile)
3846 {
3847  float color[4];
3848  RNA_float_get_array(ptr, "color", color);
3849  int gen_type = RNA_enum_get(ptr, "generated_type");
3850  int width = RNA_int_get(ptr, "width");
3851  int height = RNA_int_get(ptr, "height");
3852  bool is_float = RNA_boolean_get(ptr, "float");
3853  int planes = RNA_boolean_get(ptr, "alpha") ? 32 : 24;
3854 
3855  return BKE_image_fill_tile(ima, tile, width, height, color, gen_type, planes, is_float);
3856 }
3857 
3858 static void draw_fill_tile(PointerRNA *ptr, uiLayout *layout)
3859 {
3860  uiLayoutSetPropSep(layout, true);
3861  uiLayoutSetPropDecorate(layout, false);
3862 
3863  uiLayout *col = uiLayoutColumn(layout, false);
3864  uiItemR(col, ptr, "color", 0, NULL, ICON_NONE);
3865  uiItemR(col, ptr, "width", 0, NULL, ICON_NONE);
3866  uiItemR(col, ptr, "height", 0, NULL, ICON_NONE);
3867  uiItemR(col, ptr, "alpha", 0, NULL, ICON_NONE);
3868  uiItemR(col, ptr, "generated_type", 0, NULL, ICON_NONE);
3869  uiItemR(col, ptr, "float", 0, NULL, ICON_NONE);
3870 }
3871 
3872 static void tile_fill_init(PointerRNA *ptr, Image *ima, ImageTile *tile)
3873 {
3874  ImageUser iuser;
3875  BKE_imageuser_default(&iuser);
3876  if (tile != NULL) {
3877  iuser.tile = tile->tile_number;
3878  }
3879 
3880  /* Acquire ibuf to get the default values.
3881  * If the specified tile has no ibuf, try acquiring the main tile instead
3882  * (unless the specified tile already was the main tile).*/
3883  ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
3884  if (ibuf == NULL && (tile != NULL) && (tile->tile_number != 1001)) {
3885  ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
3886  }
3887 
3888  if (ibuf != NULL) {
3889  /* Initialize properties from reference tile. */
3890  RNA_int_set(ptr, "width", ibuf->x);
3891  RNA_int_set(ptr, "height", ibuf->y);
3892  RNA_boolean_set(ptr, "float", ibuf->rect_float != NULL);
3893  RNA_boolean_set(ptr, "alpha", ibuf->planes > 24);
3894 
3895  BKE_image_release_ibuf(ima, ibuf, NULL);
3896  }
3897 }
3898 
3900 {
3901  PropertyRNA *prop;
3902  static float default_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
3903  prop = RNA_def_float_color(
3904  srna, "color", 4, NULL, 0.0f, FLT_MAX, "Color", "Default fill color", 0.0f, 1.0f);
3906  RNA_def_property_float_array_default(prop, default_color);
3907  RNA_def_enum(srna,
3908  "generated_type",
3911  "Generated Type",
3912  "Fill the image with a grid for UV map testing");
3913  prop = RNA_def_int(srna, "width", 1024, 1, INT_MAX, "Width", "Image width", 1, 16384);
3915  prop = RNA_def_int(srna, "height", 1024, 1, INT_MAX, "Height", "Image height", 1, 16384);
3917 
3918  /* Only needed when filling the first tile. */
3920  srna, "float", 0, "32-bit Float", "Create image with 32-bit floating-point bit depth");
3921  RNA_def_boolean(srna, "alpha", 1, "Alpha", "Create an image with an alpha channel");
3922 }
3923 
3924 static bool tile_add_poll(bContext *C)
3925 {
3926  Image *ima = CTX_data_edit_image(C);
3927 
3928  return (ima != NULL && ima->source == IMA_SRC_TILED && BKE_image_has_ibuf(ima, NULL));
3929 }
3930 
3932 {
3933  Image *ima = CTX_data_edit_image(C);
3934 
3935  int start_tile = RNA_int_get(op->ptr, "number");
3936  int end_tile = start_tile + RNA_int_get(op->ptr, "count");
3937 
3938  if (start_tile < 1001 || end_tile > IMA_UDIM_MAX) {
3939  BKE_report(op->reports, RPT_ERROR, "Invalid UDIM index range was specified");
3940  return OPERATOR_CANCELLED;
3941  }
3942 
3943  bool fill_tile = RNA_boolean_get(op->ptr, "fill");
3944  char *label = RNA_string_get_alloc(op->ptr, "label", NULL, 0);
3945 
3946  bool created_tile = false;
3947  for (int tile_number = start_tile; tile_number < end_tile; tile_number++) {
3948  ImageTile *tile = BKE_image_add_tile(ima, tile_number, label);
3949 
3950  if (tile != NULL) {
3951  ima->active_tile_index = BLI_findindex(&ima->tiles, tile);
3952 
3953  if (fill_tile) {
3954  do_fill_tile(op->ptr, ima, tile);
3955  }
3956 
3957  created_tile = true;
3958  }
3959  }
3960  MEM_freeN(label);
3961 
3962  if (!created_tile) {
3963  return OPERATOR_CANCELLED;
3964  }
3965 
3967  return OPERATOR_FINISHED;
3968 }
3969 
3970 static int tile_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
3971 {
3972  Image *ima = CTX_data_edit_image(C);
3973 
3974  /* Find the first gap in tile numbers or the number after the last if
3975  * no gap exists. */
3976  int next_number = 0;
3977  LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
3978  next_number = tile->tile_number + 1;
3979  if (tile->next == NULL || tile->next->tile_number > next_number) {
3980  break;
3981  }
3982  }
3983 
3984  ImageTile *tile = BLI_findlink(&ima->tiles, ima->active_tile_index);
3985  tile_fill_init(op->ptr, ima, tile);
3986 
3987  RNA_int_set(op->ptr, "number", next_number);
3988  RNA_int_set(op->ptr, "count", 1);
3989  RNA_string_set(op->ptr, "label", "");
3990 
3991  return WM_operator_props_dialog_popup(C, op, 300);
3992 }
3993 
3995 {
3996  uiLayout *col;
3997  uiLayout *layout = op->layout;
3999  PointerRNA ptr;
4000 
4001  RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
4002 
4003  uiLayoutSetPropSep(layout, true);
4004  uiLayoutSetPropDecorate(layout, false);
4005 
4006  col = uiLayoutColumn(layout, false);
4007  uiItemR(col, &ptr, "number", 0, NULL, ICON_NONE);
4008  uiItemR(col, &ptr, "count", 0, NULL, ICON_NONE);
4009  uiItemR(col, &ptr, "label", 0, NULL, ICON_NONE);
4010  uiItemR(layout, &ptr, "fill", 0, NULL, ICON_NONE);
4011 
4012  if (RNA_boolean_get(&ptr, "fill")) {
4013  draw_fill_tile(&ptr, layout);
4014  }
4015 }
4016 
4018 {
4019  /* identifiers */
4020  ot->name = "Add Tile";
4021  ot->description = "Adds a tile to the image";
4022  ot->idname = "IMAGE_OT_tile_add";
4023 
4024  /* api callbacks */
4025  ot->poll = tile_add_poll;
4026  ot->exec = tile_add_exec;
4028  ot->ui = tile_add_draw;
4029 
4030  /* flags */
4032 
4033  RNA_def_int(ot->srna,
4034  "number",
4035  1002,
4036  1001,
4037  IMA_UDIM_MAX,
4038  "Number",
4039  "UDIM number of the tile",
4040  1001,
4041  1099);
4042  RNA_def_int(ot->srna, "count", 1, 1, INT_MAX, "Count", "How many tiles to add", 1, 1000);
4043  RNA_def_string(ot->srna, "label", NULL, 0, "Label", "Optional tile label");
4044  RNA_def_boolean(ot->srna, "fill", true, "Fill", "Fill new tile with a generated image");
4045  def_fill_tile(ot->srna);
4046 }
4047 
4050 /* -------------------------------------------------------------------- */
4055 {
4056  Image *ima = CTX_data_edit_image(C);
4057 
4058  return (ima != NULL && ima->source == IMA_SRC_TILED && ima->active_tile_index != 0);
4059 }
4060 
4062 {
4063  Image *ima = CTX_data_edit_image(C);
4064 
4065  ImageTile *tile = BLI_findlink(&ima->tiles, ima->active_tile_index);
4066  if (!BKE_image_remove_tile(ima, tile)) {
4067  return OPERATOR_CANCELLED;
4068  }
4069 
4070  /* Ensure that the active index is valid. */
4072 
4074 
4075  return OPERATOR_FINISHED;
4076 }
4077 
4079 {
4080  /* identifiers */
4081  ot->name = "Remove Tile";
4082  ot->description = "Removes a tile from the image";
4083  ot->idname = "IMAGE_OT_tile_remove";
4084 
4085  /* api callbacks */
4088 
4089  /* flags */
4091 }
4092 
4095 /* -------------------------------------------------------------------- */
4100 {
4101  Image *ima = CTX_data_edit_image(C);
4102 
4103  if (ima != NULL && ima->source == IMA_SRC_TILED) {
4104  /* Filling secondary tiles is only allowed if the primary tile exists. */
4105  return (ima->active_tile_index == 0) || BKE_image_has_ibuf(ima, NULL);
4106  }
4107  return false;
4108 }
4109 
4111 {
4112  Image *ima = CTX_data_edit_image(C);
4113 
4114  ImageTile *tile = BLI_findlink(&ima->tiles, ima->active_tile_index);
4115  if (!do_fill_tile(op->ptr, ima, tile)) {
4116  return OPERATOR_CANCELLED;
4117  }
4118 
4120 
4121  return OPERATOR_FINISHED;
4122 }
4123 
4124 static int tile_fill_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
4125 {
4127 
4128  return WM_operator_props_dialog_popup(C, op, 300);
4129 }
4130 
4132 {
4134  PointerRNA ptr;
4135  RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
4136 
4137  draw_fill_tile(&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 }
typedef float(TangentPoint)[2]
void BKE_color_managed_display_settings_copy(struct ColorManagedDisplaySettings *new_settings, const struct ColorManagedDisplaySettings *settings)
void BKE_histogram_update_sample_line(struct Histogram *hist, struct ImBuf *ibuf, const struct ColorManagedViewSettings *view_settings, const struct ColorManagedDisplaySettings *display_settings)
void BKE_color_managed_view_settings_free(struct ColorManagedViewSettings *settings)
Definition: colortools.c:1820
void BKE_color_managed_view_settings_copy(struct ColorManagedViewSettings *new_settings, const struct ColorManagedViewSettings *settings)
struct ScrArea * CTX_wm_area(const bContext *C)
Definition: context.c:714
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1034
struct Object * CTX_data_edit_object(const bContext *C)
Definition: context.c:1296
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:689
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
Definition: context.c:456
struct ViewLayer * CTX_data_view_layer(const bContext *C)
Definition: context.c:1044
struct Image * CTX_data_edit_image(const bContext *C)
Definition: context.c:1301
struct ARegion * CTX_wm_region(const bContext *C)
Definition: context.c:725
void CTX_wm_operator_poll_msg_set(struct bContext *C, const char *msg)
Definition: context.c:1006
struct SpaceImage * CTX_wm_space_image(const bContext *C)
Definition: context.c:800
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1018
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:699
@ G_FILE_AUTOPACK
Definition: BKE_global.h:166
void BKE_icon_changed(const int icon_id)
Definition: icons.cc:678
int BKE_icon_id_ensure(struct ID *id)
Definition: icons.cc:740
bool BKE_image_remove_renderslot(struct Image *ima, struct ImageUser *iuser, int slot)
Definition: image.c:5882
bool BKE_image_remove_tile(struct Image *ima, struct ImageTile *tile)
Definition: image.c:3765
void BKE_image_release_ibuf(struct Image *ima, struct ImBuf *ibuf, void *lock)
Definition: image.c:5113
bool BKE_image_has_filepath(struct Image *ima)
Definition: image.c:5632
bool BKE_image_has_ibuf(struct Image *ima, struct ImageUser *iuser)
Definition: image.c:5134
bool BKE_image_has_packedfile(struct Image *image)
Definition: image.c:5627
struct ImBuf * BKE_image_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, void **r_lock)
Definition: image.c:5100
struct RenderSlot * BKE_image_add_renderslot(struct Image *ima, const char *name)
Definition: image.c:5868
char BKE_imtype_valid_depths(const char imtype)
Definition: image.c:1541
void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const struct ImBuf *imbuf)
bool BKE_image_is_multiview(struct Image *ima)
Definition: image.c:3883
#define IMA_UDIM_MAX
Definition: BKE_image.h:48
void BKE_image_packfiles(struct ReportList *reports, struct Image *ima, const char *basepath)
Definition: image.c:1134
bool BKE_image_memorypack(struct Image *ima)
Definition: image.c:1083
bool BKE_image_clear_renderslot(struct Image *ima, struct ImageUser *iuser, int slot)
Definition: image.c:5948
struct Image * BKE_image_ensure_viewer(struct Main *bmain, int type, const char *name)
Definition: image.c:3162
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], const bool stereo3d, const bool is_data, const bool tiled)
Definition: image.c:963
void BKE_image_free_gputextures(struct Image *ima)
Definition: image_gpu.c:517
void BKE_image_mark_dirty(struct Image *image, struct ImBuf *ibuf)
#define IMA_SIGNAL_SRC_CHANGE
Definition: BKE_image.h:165
bool BKE_image_has_anim(struct Image *image)
Definition: image.c:5622
#define IMA_SIGNAL_USER_NEW_IMAGE
Definition: BKE_image.h:167
bool BKE_image_is_dirty(struct Image *image)
Definition: image.c:5681
#define IMA_SIGNAL_RELOAD
Definition: BKE_image.h:162
void BKE_image_signal(struct Main *bmain, struct Image *ima, struct ImageUser *iuser, int signal)
Definition: image.c:3499
int BKE_image_get_tile_from_pos(struct Image *ima, const float uv[2], float r_uv[2], float r_ofs[2])
Definition: image.c:707
bool BKE_image_buffer_format_writable(struct ImBuf *ibuf)
Definition: image.c:5691
void BKE_image_free_views(struct Image *image)
Definition: image.c:468
void BKE_image_init_imageuser(struct Image *ima, struct ImageUser *iuser)
Definition: image.c:3459
bool BKE_image_is_dirty_writable(struct Image *image, bool *is_format_writable)
Definition: image.c:5652
void BKE_image_free_packedfiles(struct Image *image)
Definition: image.c:463
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)
Definition: image.c:3783
struct ImageTile * BKE_image_add_tile(struct Image *ima, int tile_number, const char *label)
Definition: image.c:3712
struct Image * BKE_image_load_exists_ex(struct Main *bmain, const char *filepath, bool *r_exists)
Definition: image.c:843
void BKE_image_user_frame_calc(struct Image *ima, struct ImageUser *iuser, int cfra)
Definition: image.c:5335
void BKE_imageuser_default(struct ImageUser *iuser)
Definition: image.c:3451
struct RenderSlot * BKE_image_get_renderslot(struct Image *ima, int index)
Definition: image.c:5976
void BKE_image_save_options_init(struct ImageSaveOptions *opts, struct Main *bmain, struct Scene *scene)
Definition: image_save.c:46
bool BKE_image_save(struct ReportList *reports, struct Main *bmain, struct Image *ima, struct ImageUser *iuser, struct ImageSaveOptions *opts)
Definition: image_save.c:397
#define BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, v3d, r_len)
Definition: BKE_layer.h:434
void id_us_min(struct ID *id)
Definition: lib_id.c:297
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:635
@ PF_USE_LOCAL
void BKE_report(ReportList *reports, ReportType type, const char *message)
Definition: report.c:104
void BKE_reports_clear(ReportList *reports)
Definition: report.c:84
void BKE_reportf(ReportList *reports, ReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_reports_init(ReportList *reports, int flag)
Definition: report.c:66
File and directory operations.
int BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: storage.c:349
bool BLI_file_is_writable(const char *file) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: fileops.c:265
GSet * BLI_gset_str_new(const char *info)
struct GSet GSet
Definition: BLI_ghash.h:189
void BLI_gset_insert(GSet *gs, void *key)
Definition: BLI_ghash.c:1147
bool BLI_gset_haskey(GSet *gs, const void *key) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.c:1216
void BLI_gset_free(GSet *gs, GSetKeyFreeFP keyfreefp)
Definition: BLI_ghash.c:1253
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
Definition: BLI_listbase.h:124
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:172
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:547
void * BLI_findstring(const struct ListBase *listbase, const char *id, const int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
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)
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:407
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:1487
bool BLI_path_make_safe(char *path) ATTR_NONNULL(1)
Definition: path_util.c:374
bool BLI_path_is_rel(const char *path) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
Definition: path_util.c:411
void BLI_split_dir_part(const char *string, char *dir, const size_t dirlen)
Definition: path_util.c:1682
#define FILE_MAX
int BLI_path_sequence_decode(const char *string, char *head, char *tail, unsigned short *r_num_len)
Definition: path_util.c:83
void BLI_path_rel(char *file, const char *relfile) ATTR_NONNULL()
Definition: path_util.c:519
bool BLI_path_abs(char *path, const char *basepath) ATTR_NONNULL()
Definition: path_util.c:1016
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition: BLI_rect.h:157
BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
Definition: BLI_rect.h:148
BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct)
Definition: BLI_rect.h:144
void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax)
Definition: rct.c:436
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition: BLI_rect.h:153
void BLI_rctf_scale(rctf *rect, const float scale)
Definition: rct.c:694
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition: BLI_rect.h:161
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
Definition: BLI_rect.h:165
#define STR_ELEM(...)
Definition: BLI_string.h:218
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
Definition: string.c:70
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
Definition: string.c:108
#define STR_CONCAT(dst, len, suffix)
Definition: BLI_string.h:168
unsigned char uchar
Definition: BLI_sys_types.h:86
unsigned int uint
Definition: BLI_sys_types.h:83
#define CLAMP_MAX(a, c)
#define UNUSED(x)
#define POINTER_AS_INT(i)
#define ELEM(...)
#define STREQ(a, b)
#define TIP_(msgid)
#define DATA_(msgid)
void DEG_id_tag_update(struct ID *id, int flag)
@ ID_RECALC_COPY_ON_WRITE
Definition: DNA_ID.h:654
@ ID_RECALC_AUDIO_SEEK
Definition: DNA_ID.h:660
#define MAX_ID_NAME
Definition: DNA_ID.h:269
#define ID_BLEND_PATH(_bmain, _id)
Definition: DNA_ID.h:419
@ ID_IM
Definition: DNA_ID_enums.h:65
@ HISTO_FLAG_SAMPLELINE
@ IMA_USE_VIEWS
@ IMA_GENTYPE_BLANK
@ IMA_TYPE_MULTILAYER
@ IMA_TYPE_R_RESULT
@ IMA_TYPE_COMPOSITE
@ IMA_SRC_FILE
@ IMA_SRC_MOVIE
@ IMA_SRC_GENERATED
@ IMA_SRC_VIEWER
@ IMA_SRC_TILED
@ IMA_SRC_SEQUENCE
Object is a sort of wrapper for general info.
#define SUBFRA
#define R_BORDER
#define R_MULTIVIEW
#define R_IMF_PLANES_BW
#define R_CROP
#define MINAFRAME
#define CFRA
#define SFRA
#define R_IMF_IMTYPE_PNG
@ R_IMF_CHAN_DEPTH_24
@ R_IMF_CHAN_DEPTH_8
@ R_IMF_CHAN_DEPTH_16
@ R_IMF_CHAN_DEPTH_12
@ R_IMF_CHAN_DEPTH_32
#define R_IMF_PLANES_RGBA
#define EFRA
#define R_IMF_PLANES_RGB
#define MAXFRAME
@ RGN_TYPE_WINDOW
@ FILE_SORT_DEFAULT
@ FILE_SPECIAL
@ FILE_TYPE_MOVIE
@ FILE_TYPE_FOLDER
@ FILE_TYPE_IMAGE
@ SPACE_IMAGE
@ FILE_OPENFILE
@ FILE_SAVE
@ 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:171
bool ED_space_image_check_show_maskedit(struct SpaceImage *sima, struct Object *obedit)
Definition: image_edit.c:484
bool ED_space_image_has_buffer(struct SpaceImage *sima)
Definition: image_edit.c:202
struct Image * ED_space_image(struct SpaceImage *sima)
Definition: image_edit.c:55
void ED_image_view_center_to_point(struct SpaceImage *sima, float x, float y)
Definition: image_edit.c:334
ListBase ED_image_filesel_detect_sequences(struct Main *bmain, struct wmOperator *op, const bool detect_udim)
void ED_space_image_set(struct Main *bmain, struct SpaceImage *sima, struct Object *obedit, struct Image *ima, bool automatic)
Definition: image_edit.c:60
bool ED_space_image_show_uvedit(struct SpaceImage *sima, struct Object *obedit)
Definition: image_edit.c:460
bool ED_space_image_show_cache(struct SpaceImage *sima)
Definition: image_draw.c:982
bool ED_image_slot_cycle(struct Image *image, int direction)
Definition: image_edit.c:382
void ED_space_image_get_size(struct SpaceImage *sima, int *r_width, int *r_height)
Definition: image_edit.c:215
void ED_space_image_get_aspect(struct SpaceImage *sima, float *r_aspx, float *r_aspy)
Definition: image_edit.c:256
struct ImBuf * ED_space_image_acquire_buffer(struct SpaceImage *sima, void **r_lock, int tile)
Definition: image_edit.c:139
bool ED_space_image_cursor_poll(struct bContext *C)
Definition: image_edit.c:532
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.c:104
void ED_image_undo_push_end(void)
Definition: image_undo.c:1103
void ED_image_undo_push_begin_with_image(const char *name, struct Image *image, struct ImBuf *ibuf, struct ImageUser *iuser)
Definition: image_undo.c:1071
void ED_preview_kill_jobs(struct wmWindowManager *wm, struct Main *bmain)
void ED_area_tag_redraw(ScrArea *area)
Definition: area.c:745
void ED_region_tag_redraw(struct ARegion *region)
Definition: area.c:667
bool ED_operator_uvedit(struct bContext *C)
Definition: screen_ops.c:511
bool ED_operator_mask(struct bContext *C)
Definition: screen_ops.c:616
const rcti * ED_region_visible_rect(ARegion *region)
Definition: area.c:3682
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:329
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 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
_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
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:1667
void IMB_rect_from_float(struct ImBuf *ibuf)
Definition: divers.c:720
bool IMB_saveiff(struct ImBuf *ibuf, const char *filepath, int flags)
Definition: writeimage.c:44
int IMB_anim_get_duration(struct anim *anim, IMB_Timecode_Type tc)
Definition: anim_movie.c:1671
@ IMB_TC_RECORD_RUN
Definition: IMB_imbuf.h:304
Contains defines and structs used throughout the imbuf module.
@ IB_BITMAPDIRTY
@ IB_MIPMAP_INVALID
@ IB_DISPLAY_BUFFER_INVALID
@ IMB_COLORMANAGE_IS_DATA
const char * imb_ext_movie[]
Definition: util.c:95
@ IB_zbuf
@ IB_zbuffloat
@ IB_rect
void IMB_moviecacheIter_free(struct MovieCacheIter *iter)
Definition: moviecache.c:580
struct MovieCacheIter * IMB_moviecacheIter_new(struct MovieCache *cache)
Definition: moviecache.c:570
bool IMB_moviecacheIter_done(struct MovieCacheIter *iter)
Definition: moviecache.c:585
void IMB_moviecacheIter_step(struct MovieCacheIter *iter)
Definition: moviecache.c:590
struct ImBuf * IMB_moviecacheIter_getImBuf(struct MovieCacheIter *iter)
Definition: moviecache.c:595
Read Guarded memory(de)allocation.
Group RGB to Bright Vector Camera CLAMP
Group RGB to Bright Vector Camera Vector Combine Material Light Line Style Layer Add Ambient Diffuse Glossy Refraction Transparent Toon Principled Hair Volume Principled Light Particle Volume TEX_IMAGE
Platform independent time functions.
StructRNA RNA_ImageFormatSettings
StructRNA RNA_ImageUser
StructRNA RNA_Camera
StructRNA RNA_Texture
StructRNA RNA_Image
void StructOrFunctionRNA
Definition: RNA_define.h:86
@ PROP_SKIP_SAVE
Definition: RNA_types.h:204
@ PROP_HIDDEN
Definition: RNA_types.h:202
@ PROP_PIXEL
Definition: RNA_types.h:128
@ PROP_COLOR_GAMMA
Definition: RNA_types.h:151
#define C
Definition: RandGen.cpp:39
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, const bool compact)
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)
@ UI_BUT_LABEL_ALIGN_NONE
void UI_context_active_but_prop_get_templateID(struct bContext *C, struct PointerRNA *r_ptr, struct PropertyRNA **r_prop)
#define UI_DPI_FAC
Definition: UI_interface.h:309
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
void uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep)
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()
#define WM_FILESEL_DIRECTORY
Definition: WM_api.h:535
#define WM_FILESEL_SHOW_PROPS
Definition: WM_api.h:540
#define WM_FILESEL_RELPATH
Definition: WM_api.h:533
#define WM_FILESEL_FILEPATH
Definition: WM_api.h:537
#define WM_FILESEL_FILES
Definition: WM_api.h:538
#define ND_DRAW
Definition: WM_types.h:362
@ OPTYPE_INTERNAL
Definition: WM_types.h:175
@ OPTYPE_BLOCKING
Definition: WM_types.h:157
@ OPTYPE_LOCK_BYPASS
Definition: WM_types.h:178
@ OPTYPE_UNDO
Definition: WM_types.h:155
@ OPTYPE_GRAB_CURSOR_XY
Definition: WM_types.h:161
@ OPTYPE_REGISTER
Definition: WM_types.h:153
#define ND_RENDER_OPTIONS
Definition: WM_types.h:335
@ WM_OP_INVOKE_DEFAULT
Definition: WM_types.h:197
#define NC_SCENE
Definition: WM_types.h:279
#define NA_ADDED
Definition: WM_types.h:464
#define ND_SPACE_IMAGE
Definition: WM_types.h:417
#define NA_EDITED
Definition: WM_types.h:462
#define NC_IMAGE
Definition: WM_types.h:285
#define ND_FRAME
Definition: WM_types.h:334
#define NC_SPACE
Definition: WM_types.h:293
#define KM_RELEASE
Definition: WM_types.h:243
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 MovieCache * cache
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
OperationNode * node
double time
const char * label
Scene scene
void * user_data
static CCL_NAMESPACE_BEGIN const double alpha
RenderData * RE_engine_get_render_data(Render *re)
Definition: engine.c:616
#define str(s)
uint col
static int image_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
Definition: image_ops.c:1940
void IMAGE_OT_view_cursor_center(wmOperatorType *ot)
Definition: image_ops.c:861
static bool tile_remove_poll(bContext *C)
Definition: image_ops.c:4054
void IMAGE_OT_change_frame(wmOperatorType *ot)
Definition: image_ops.c:3683
int ED_image_save_all_modified_info(const Main *bmain, ReportList *reports)
Definition: image_ops.c:2330
static void image_filesel(bContext *C, wmOperator *op, const char *path)
Definition: image_ops.c:1214
void IMAGE_OT_save_sequence(wmOperatorType *ot)
Definition: image_ops.c:2277
static bool image_has_valid_path(Image *ima)
Definition: image_ops.c:2312
static void image_new_draw(bContext *C, wmOperator *op)
Definition: image_ops.c:2617
static void image_save_options_to_op(ImageSaveOptions *opts, wmOperator *op)
Definition: image_ops.c:1848
void IMAGE_OT_view_zoom(wmOperatorType *ot)
Definition: image_ops.c:697
static int tile_fill_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
Definition: image_ops.c:4124
static bool image_should_be_saved(Image *ima, bool *is_format_writable)
Definition: image_ops.c:2303
static void tile_fill_draw(bContext *C, wmOperator *op)
Definition: image_ops.c:4131
static bool image_from_context_has_data_poll_no_image_user(bContext *C)
Definition: image_ops.c:233
void IMAGE_OT_cycle_render_slot(wmOperatorType *ot)
Definition: image_ops.c:3456
static int image_scale_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:2969
void IMAGE_OT_match_movie_length(wmOperatorType *ot)
Definition: image_ops.c:1580
static int image_open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
Definition: image_ops.c:1415
void IMAGE_OT_save_all_modified(wmOperatorType *ot)
Definition: image_ops.c:2428
void IMAGE_OT_save_as(wmOperatorType *ot)
Definition: image_ops.c:2046
static int image_sample_line_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: image_ops.c:3351
static bool image_view_selected_poll(bContext *C)
Definition: image_ops.c:964
void IMAGE_OT_sample(wmOperatorType *ot)
Definition: image_ops.c:3271
static int image_new_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
Definition: image_ops.c:2605
static int image_save_sequence_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:2202
@ VIEW_CONFIRM
Definition: image_ops.c:574
@ VIEW_PASS
Definition: image_ops.c:572
@ VIEW_APPLY
Definition: image_ops.c:573
static bool image_save_as_check(bContext *UNUSED(C), wmOperator *op)
Definition: image_ops.c:1934
@ GEN_CONTEXT_NONE
Definition: image_ops.c:2493
@ GEN_CONTEXT_PAINT_CANVAS
Definition: image_ops.c:2494
@ GEN_CONTEXT_PAINT_STENCIL
Definition: image_ops.c:2495
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:147
static int change_frame_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: image_ops.c:3635
static void image_view_pan_exit(bContext *C, wmOperator *op, bool cancel)
Definition: image_ops.c:372
static int image_view_zoom_in_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: image_ops.c:1003
#define IMA_DEF_NAME
Definition: image_ops.c:2490
bool ED_image_should_save_modified(const Main *bmain)
Definition: image_ops.c:2317
static void image_view_zoom_cancel(bContext *C, wmOperator *op)
Definition: image_ops.c:692
static bool save_image_op(Main *bmain, Image *ima, ImageUser *iuser, wmOperator *op, ImageSaveOptions *opts)
Definition: image_ops.c:1859
static void def_fill_tile(StructOrFunctionRNA *srna)
Definition: image_ops.c:3899
static Image * image_from_context(const bContext *C)
Definition: image_ops.c:184
void IMAGE_OT_tile_fill(wmOperatorType *ot)
Definition: image_ops.c:4140
static bool tile_add_poll(bContext *C)
Definition: image_ops.c:3924
static int image_view_zoom_out_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:1046
void IMAGE_OT_remove_render_slot(wmOperatorType *ot)
Definition: image_ops.c:3561
static void image_view_all(struct SpaceImage *sima, struct ARegion *region, struct wmOperator *op)
Definition: image_ops.c:247
static bool do_fill_tile(PointerRNA *ptr, Image *ima, ImageTile *tile)
Definition: image_ops.c:3845
static bool image_save_as_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop, void *UNUSED(user_data))
Definition: image_ops.c:1992
static int image_view_zoom_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:559
void IMAGE_OT_view_zoom_border(wmOperatorType *ot)
Definition: image_ops.c:1194
static int image_sample_line_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:3299
static int image_view_zoom_in_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:987
static int image_replace_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
Definition: image_ops.c:1638
static int tile_remove_exec(bContext *C, wmOperator *UNUSED(op))
Definition: image_ops.c:4061
static int image_open_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:1307
static bool image_from_context_has_data_poll(bContext *C)
Definition: image_ops.c:214
static bool tile_fill_poll(bContext *C)
Definition: image_ops.c:4099
static void image_save_as_cancel(bContext *UNUSED(C), wmOperator *op)
Definition: image_ops.c:1987
static int image_match_len_exec(bContext *C, wmOperator *UNUSED(op))
Definition: image_ops.c:1550
void IMAGE_OT_reload(wmOperatorType *ot)
Definition: image_ops.c:2470
static int image_save_as_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:1894
void IMAGE_OT_unpack(wmOperatorType *ot)
Definition: image_ops.c:3174
void IMAGE_OT_view_selected(wmOperatorType *ot)
Definition: image_ops.c:969
void IMAGE_OT_tile_add(wmOperatorType *ot)
Definition: image_ops.c:4017
static char imtype_best_depth(ImBuf *ibuf, const char imtype)
Definition: image_ops.c:1696
void IMAGE_OT_pack(wmOperatorType *ot)
Definition: image_ops.c:3076
void IMAGE_OT_open(wmOperatorType *ot)
Definition: image_ops.c:1505
static int image_add_render_slot_exec(bContext *C, wmOperator *UNUSED(op))
Definition: image_ops.c:3514
void IMAGE_OT_read_viewlayers(wmOperatorType *ot)
Definition: image_ops.c:3723
static bool image_save_as_poll(bContext *C)
Definition: image_ops.c:2027
static int image_save_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
Definition: image_ops.c:2166
static int image_clear_render_slot_exec(bContext *C, wmOperator *UNUSED(op))
Definition: image_ops.c:3479
void IMAGE_OT_invert(wmOperatorType *ot)
Definition: image_ops.c:2923
void IMAGE_OT_resize(wmOperatorType *ot)
Definition: image_ops.c:3013
void IMAGE_OT_clear_render_slot(wmOperatorType *ot)
Definition: image_ops.c:3493
static int image_view_zoom_ratio_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:1111
void IMAGE_OT_view_zoom_in(wmOperatorType *ot)
Definition: image_ops.c:1015
void IMAGE_OT_view_zoom_out(wmOperatorType *ot)
Definition: image_ops.c:1074
static int image_cycle_render_slot_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:3436
void IMAGE_OT_view_all(wmOperatorType *ot)
Definition: image_ops.c:815
void IMAGE_OT_render_border(wmOperatorType *ot)
Definition: image_ops.c:3788
void IMAGE_OT_view_pan(wmOperatorType *ot)
Definition: image_ops.c:452
static void image_open_cancel(bContext *UNUSED(C), wmOperator *op)
Definition: image_ops.c:1240
static int image_invert_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:2832
static int frame_from_event(bContext *C, const wmEvent *event)
Definition: image_ops.c:3613
struct ImageNewData ImageNewData
struct ViewZoomData ViewZoomData
static int image_save_options_init(Main *bmain, ImageSaveOptions *opts, Image *ima, ImageUser *iuser, const bool guess_path, const bool save_as_render)
Definition: image_ops.c:1734
static void draw_fill_tile(PointerRNA *ptr, uiLayout *layout)
Definition: image_ops.c:3858
static int image_reload_exec(bContext *C, wmOperator *UNUSED(op))
Definition: image_ops.c:2449
static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
Definition: image_ops.c:915
struct ImageSaveData ImageSaveData
static int image_view_zoom_out_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: image_ops.c:1062
static int image_view_zoom_border_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:1159
static ImageNewData * image_new_init(bContext *C, wmOperator *op)
Definition: image_ops.c:2502
bool ED_space_image_get_position(SpaceImage *sima, struct ARegion *ar, int mval[2], float fpos[2])
Definition: image_ops.c:3203
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:1246
static void image_view_zoom_init(bContext *C, wmOperator *op, const wmEvent *event)
Definition: image_ops.c:504
static bool image_not_packed_poll(bContext *C)
Definition: image_ops.c:240
static int image_unpack_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
Definition: image_ops.c:3138
static void image_save_as_free(wmOperator *op)
Definition: image_ops.c:1883
static void image_open_draw(bContext *C, wmOperator *op)
Definition: image_ops.c:1482
static int change_frame_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:3606
static bool image_file_format_writable(Image *ima, ImageUser *iuser)
Definition: image_ops.c:2094
static bool image_should_be_saved_when_modified(Image *ima)
Definition: image_ops.c:2298
void IMAGE_OT_save(wmOperatorType *ot)
Definition: image_ops.c:2180
static void image_save_as_draw(bContext *C, wmOperator *op)
Definition: image_ops.c:2004
static int image_view_all_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:799
static void image_view_pan_init(bContext *C, wmOperator *op, const wmEvent *event)
Definition: image_ops.c:349
bool ED_space_image_color_sample(SpaceImage *sima, ARegion *region, int mval[2], float r_col[3], bool *r_is_data)
Definition: image_ops.c:3220
static void image_view_zoom_exit(bContext *C, wmOperator *op, bool cancel)
Definition: image_ops.c:539
static void image_save_options_from_op(Main *bmain, ImageSaveOptions *opts, wmOperator *op, ImageFormatData *imf)
Definition: image_ops.c:1832
static int tile_fill_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:4110
static bool image_cycle_render_slot_poll(bContext *C)
Definition: image_ops.c:3429
static int image_view_pan_modal(bContext *C, wmOperator *op, const wmEvent *event)
Definition: image_ops.c:421
static void image_new_cancel(bContext *UNUSED(C), wmOperator *op)
Definition: image_ops.c:2653
void IMAGE_OT_add_render_slot(wmOperatorType *ot)
Definition: image_ops.c:3526
void IMAGE_OT_tile_remove(wmOperatorType *ot)
Definition: image_ops.c:4078
static int render_border_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:3742
struct ViewPanData ViewPanData
static void image_open_init(bContext *C, wmOperator *op)
Definition: image_ops.c:1232
static void tile_fill_init(PointerRNA *ptr, Image *ima, ImageTile *tile)
Definition: image_ops.c:3872
static int image_view_pan_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:389
static int image_save_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:2123
static int image_scale_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
Definition: image_ops.c:2956
static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event)
Definition: image_ops.c:3661
bool space_image_main_region_poll(bContext *C)
Definition: image_ops.c:311
static int view_center_cursor_exec(bContext *C, wmOperator *UNUSED(op))
Definition: image_ops.c:885
static int image_view_pan_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: image_ops.c:403
static int clear_render_border_exec(bContext *C, wmOperator *UNUSED(op))
Definition: image_ops.c:3815
static int tile_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
Definition: image_ops.c:3970
void IMAGE_OT_flip(wmOperatorType *ot)
Definition: image_ops.c:2802
static bool image_save_all_modified_poll(bContext *C)
Definition: image_ops.c:2416
static bool image_open_draw_check_prop(PointerRNA *UNUSED(ptr), PropertyRNA *prop, void *UNUSED(user_data))
Definition: image_ops.c:1473
void IMAGE_OT_sample_line(wmOperatorType *ot)
Definition: image_ops.c:3365
void IMAGE_OT_replace(wmOperatorType *ot)
Definition: image_ops.c:1659
static void sima_zoom_set_from_bounds(SpaceImage *sima, ARegion *region, const rctf *bounds)
Definition: image_ops.c:159
static int image_read_viewlayers_exec(bContext *C, wmOperator *UNUSED(op))
Definition: image_ops.c:3705
static int image_new_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:2522
static bool change_frame_poll(bContext *C)
Definition: image_ops.c:3582
struct ImageOpenData ImageOpenData
static bool image_save_poll(bContext *C)
Definition: image_ops.c:2108
static void image_view_pan_cancel(bContext *C, wmOperator *op)
Definition: image_ops.c:447
static void sima_zoom_set(SpaceImage *sima, ARegion *region, float zoom, const float location[2], const bool zoom_to_pos)
Definition: image_ops.c:107
static int image_unpack_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:3096
static int image_view_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: image_ops.c:577
static int image_replace_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:1601
void IMAGE_OT_view_center_cursor(wmOperatorType *ot)
Definition: image_ops.c:897
bool ED_image_save_all_modified(const bContext *C, ReportList *reports)
Definition: image_ops.c:2385
void IMAGE_OT_view_zoom_ratio(wmOperatorType *ot)
Definition: image_ops.c:1127
static int image_save_all_modified_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:2422
static int image_pack_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:3055
void IMAGE_OT_new(wmOperatorType *ot)
Definition: image_ops.c:2658
static int image_view_zoom_modal(bContext *C, wmOperator *op, const wmEvent *event)
Definition: image_ops.c:657
static void change_frame_apply(bContext *C, wmOperator *op)
Definition: image_ops.c:3592
static int view_cursor_center_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:842
static void image_new_free(wmOperator *op)
Definition: image_ops.c:2514
void IMAGE_OT_clear_render_border(wmOperatorType *ot)
Definition: image_ops.c:3824
static bool space_image_main_area_not_uv_brush_poll(bContext *C)
Definition: image_ops.c:323
static int tile_add_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:3931
static bool image_pack_test(bContext *C, wmOperator *op)
Definition: image_ops.c:3038
void IMAGE_OT_curves_point_set(wmOperatorType *ot)
Definition: image_ops.c:3391
static void tile_add_draw(bContext *C, wmOperator *op)
Definition: image_ops.c:3994
static ImageUser * image_user_from_context(const bContext *C)
Definition: image_ops.c:199
static int image_flip_exec(bContext *C, wmOperator *op)
Definition: image_ops.c:2712
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:610
static int image_remove_render_slot_exec(bContext *C, wmOperator *UNUSED(op))
Definition: image_ops.c:3547
IconTextureDrawCall border
#define GS(x)
Definition: iris.c:241
#define powf(x, y)
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_dupallocN)(const void *vmemh)
Definition: mallocn.c:42
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
static unsigned a[3]
Definition: RandGen.cpp:92
static void area(int d1, int d2, int e1, int e2, float weights[2])
Render * RE_GetSceneRender(const Scene *scene)
Definition: pipeline.c:591
bool RE_ReadRenderResult(Scene *scene, Scene *scenode)
Definition: pipeline.c:2611
return ret
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
Definition: rna_access.c:146
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
Definition: rna_access.c:6550
void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
Definition: rna_access.c:122
const char * RNA_property_identifier(const PropertyRNA *prop)
Definition: rna_access.c:1145
void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA ptr_value, ReportList *reports)
Definition: rna_access.c:3673
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
Definition: rna_access.c:6272
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:6655
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
Definition: rna_access.c:6319
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:3641
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:866
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
Definition: rna_access.c:6378
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:2317
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
Definition: rna_access.c:6514
int RNA_int_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6308
void RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop, char *value)
Definition: rna_access.c:3310
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
Definition: rna_access.c:2358
float RNA_float_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6355
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
Definition: rna_access.c:6366
void RNA_property_int_set_array(PointerRNA *ptr, PropertyRNA *prop, const int *values)
Definition: rna_access.c:2783
void RNA_property_int_get_array(PointerRNA *ptr, PropertyRNA *prop, int *values)
Definition: rna_access.c:2690
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:6685
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6261
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
Definition: rna_access.c:6390
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6402
char * RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen)
Definition: rna_access.c:6527
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:3825
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3481
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:3851
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:3611
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:3675
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:3911
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1512
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:3585
void RNA_def_property_subtype(PropertyRNA *prop, PropertySubType subtype)
Definition: rna_define.c:1563
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:3771
void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array)
Definition: rna_define.c:2064
const EnumPropertyItem rna_enum_image_generated_type_items[]
Definition: rna_image.c:43
const EnumPropertyItem rna_enum_unpack_method_items[]
#define min(a, b)
Definition: sort.c:51
short regiontype
struct ListBase bg_images
float co[2][2]
Definition: DNA_ID.h:273
char name[66]
Definition: DNA_ID.h:283
struct ImBuf * mipmap[IMB_MIPMAP_LEVELS]
int channels
int userflags
struct ColorSpace * rect_colorspace
ImbFormatOptions foptions
int colormanage_flag
unsigned char planes
char name[IMB_FILENAME_SIZE]
unsigned int * rect
float * rect_float
ColorManagedDisplaySettings display_settings
ColorManagedViewSettings view_settings
Stereo3dFormat stereo3d_format
char filepath[FILE_MAX]
Definition: ED_image.h:141
ListBase udim_tiles
Definition: ED_image.h:146
PropertyPointerRNA pprop
Definition: image_ops.c:2499
ImageUser * iuser
Definition: image_ops.c:1228
ImageFormatData im_format
Definition: image_ops.c:1229
PropertyPointerRNA pprop
Definition: image_ops.c:1227
ImageFormatData im_format
Definition: image_ops.c:1693
ImageUser * iuser
Definition: image_ops.c:1691
Image * image
Definition: image_ops.c:1692
struct ImageFormatData im_format
struct Scene * scene
char filepath[1024]
struct Scene * scene
void * first
Definition: DNA_listBase.h:47
Definition: BKE_main.h:116
ListBase wm
Definition: BKE_main.h:175
struct MainLock * lock
Definition: BKE_main.h:194
char name[1024]
Definition: BKE_main.h:118
ListBase images
Definition: BKE_main.h:154
void * data
Definition: RNA_types.h:52
struct ID * owner_id
Definition: RNA_types.h:50
struct PropertyRNA * prop
Definition: RNA_types.h:57
PointerRNA ptr
Definition: RNA_types.h:56
struct ImageFormatData im_format
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:377
float y
Definition: clip_ops.c:375
float xof
Definition: clip_ops.c:376
float x
Definition: clip_ops.c:375
float yof
Definition: clip_ops.c:376
bool own_cursor
Definition: clip_ops.c:378
SpaceImage * sima
Definition: image_ops.c:500
float location[2]
Definition: clip_ops.c:551
double timer_lastdraw
Definition: clip_ops.c:553
float origy
Definition: image_ops.c:489
ARegion * region
Definition: image_ops.c:501
int launch_event
Definition: clip_ops.c:550
float origx
Definition: image_ops.c:489
wmTimer * timer
Definition: clip_ops.c:552
float zoom
Definition: clip_ops.c:549
bool own_cursor
Definition: clip_ops.c:554
Definition: IMB_anim.h:87
int ymin
Definition: DNA_vec_types.h:80
int y
Definition: WM_types.h:581
short val
Definition: WM_types.h:579
int mval[2]
Definition: WM_types.h:583
int prevy
Definition: WM_types.h:614
int x
Definition: WM_types.h:581
short type
Definition: WM_types.h:577
void * customdata
Definition: WM_types.h:631
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:752
const char * name
Definition: WM_types.h:721
int(* modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:768
const char * idname
Definition: WM_types.h:723
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:776
void(* cancel)(struct bContext *, struct wmOperator *)
Definition: WM_types.h:760
struct StructRNA * srna
Definition: WM_types.h:802
const char * description
Definition: WM_types.h:726
void(* ui)(struct bContext *, struct wmOperator *)
Definition: WM_types.h:787
bool(* check)(struct bContext *, struct wmOperator *)
Definition: WM_types.h:744
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:736
struct ReportList * reports
IDProperty * properties
struct uiLayout * layout
struct wmOperatorType * type
struct PointerRNA * ptr
struct wmWindow * win
Definition: WM_types.h:693
double PIL_check_seconds_timer(void)
Definition: time.c:80
float max
#define G(x, y, z)
uint len
void WM_cursor_modal_set(wmWindow *win, int val)
Definition: wm_cursors.c:207
void WM_cursor_modal_restore(wmWindow *win)
Definition: wm_cursors.c:216
void WM_cursor_wait(bool val)
Definition: wm_cursors.c:226
@ WM_CURSOR_NSEW_SCROLL
Definition: wm_cursors.h:67
@ WM_CURSOR_EDIT
Definition: wm_cursors.h:38
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(bContext *C, const char *opstring, short context, PointerRNA *properties)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
@ MOUSEPAN
@ RIGHTMOUSE
@ TIMER
@ MOUSEZOOM
@ MOUSEMOVE
@ LEFTMOUSE
@ NDOF_MOTION
@ EVT_ESCKEY
PointerRNA * ptr
Definition: wm_files.c:3157
wmOperatorType * ot
Definition: wm_files.c:3156
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_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)
void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type, short action, short flag, short display, short sort)
bool WM_operator_filesel_ensure_ext_imtype(wmOperator *op, const struct ImageFormatData *im_format)
int WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width)
void WM_event_remove_timer(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *timer)
Definition: wm_window.c:1669
wmTimer * WM_event_add_timer(wmWindowManager *wm, wmWindow *win, int event_type, double timestep)
Definition: wm_window.c:1632