2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-11-30 18:39:49 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-11-30 18:39:49 +00:00
|
|
|
*
|
|
|
|
|
* Contributor(s): Brecht Van Lommel
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-27 20:20:01 +00:00
|
|
|
/** \file blender/makesrna/intern/rna_image.c
|
|
|
|
|
* \ingroup RNA
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2008-11-30 18:39:49 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
#include "RNA_define.h"
|
2010-03-07 20:27:40 +00:00
|
|
|
#include "RNA_enum_types.h"
|
2008-11-30 18:39:49 +00:00
|
|
|
|
|
|
|
|
#include "rna_internal.h"
|
|
|
|
|
|
|
|
|
|
#include "DNA_image_types.h"
|
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
|
2009-06-16 00:52:21 +00:00
|
|
|
#include "BKE_context.h"
|
2010-04-06 16:53:48 +00:00
|
|
|
#include "BKE_depsgraph.h"
|
2008-11-30 18:39:49 +00:00
|
|
|
#include "BKE_image.h"
|
|
|
|
|
|
2009-06-23 00:45:41 +00:00
|
|
|
#include "WM_types.h"
|
2011-12-30 14:17:11 +00:00
|
|
|
#include "WM_api.h"
|
2009-06-23 00:45:41 +00:00
|
|
|
|
2012-08-29 08:17:38 +00:00
|
|
|
EnumPropertyItem image_generated_type_items[] = {
|
|
|
|
|
{IMA_GENTYPE_BLANK, "BLANK", 0, "Blank", "Generate a blank image"},
|
|
|
|
|
{IMA_GENTYPE_GRID, "UV_GRID", 0, "UV Grid", "Generated grid to test UV mappings"},
|
|
|
|
|
{IMA_GENTYPE_GRID_COLOR, "COLOR_GRID", 0, "Color Grid", "Generated improved UV grid to test UV mappings"},
|
|
|
|
|
{0, NULL, 0, NULL, NULL}
|
|
|
|
|
};
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
static EnumPropertyItem image_source_items[] = {
|
2011-04-28 12:43:28 +00:00
|
|
|
{IMA_SRC_FILE, "FILE", 0, "Single Image", "Single image file"},
|
|
|
|
|
{IMA_SRC_SEQUENCE, "SEQUENCE", 0, "Image Sequence", "Multiple image files, as a sequence"},
|
2012-03-02 21:14:37 +00:00
|
|
|
{IMA_SRC_MOVIE, "MOVIE", 0, "Movie", "Movie file"},
|
2009-09-16 19:27:08 +00:00
|
|
|
{IMA_SRC_GENERATED, "GENERATED", 0, "Generated", "Generated image"},
|
|
|
|
|
{IMA_SRC_VIEWER, "VIEWER", 0, "Viewer", "Compositing node viewer"},
|
2012-05-12 11:01:29 +00:00
|
|
|
{0, NULL, 0, NULL, NULL}
|
|
|
|
|
};
|
2009-09-16 19:27:08 +00:00
|
|
|
|
2008-11-30 18:39:49 +00:00
|
|
|
#ifdef RNA_RUNTIME
|
|
|
|
|
|
2012-05-26 14:53:33 +00:00
|
|
|
#include "IMB_imbuf.h"
|
2009-06-30 19:10:14 +00:00
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
|
|
2011-05-31 02:14:25 +00:00
|
|
|
static void rna_Image_animated_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
|
2009-06-16 00:52:21 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
Image *ima = (Image *)ptr->data;
|
|
|
|
|
int nr;
|
2009-06-16 00:52:21 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (ima->flag & IMA_TWINANIM) {
|
2012-05-12 11:01:29 +00:00
|
|
|
nr = ima->xrep * ima->yrep;
|
2012-03-05 23:30:41 +00:00
|
|
|
if (ima->twsta >= nr) ima->twsta = 1;
|
2012-05-12 11:01:29 +00:00
|
|
|
if (ima->twend >= nr) ima->twend = nr - 1;
|
|
|
|
|
if (ima->twsta > ima->twend) ima->twsta = 1;
|
2009-06-16 00:52:21 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-30 19:10:14 +00:00
|
|
|
static int rna_Image_dirty_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
Image *ima = (Image *)ptr->data;
|
2009-06-30 19:10:14 +00:00
|
|
|
ImBuf *ibuf;
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (ibuf = ima->ibufs.first; ibuf; ibuf = ibuf->next)
|
|
|
|
|
if (ibuf->userflags & IB_BITMAPDIRTY)
|
2009-06-30 19:10:14 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-31 02:14:25 +00:00
|
|
|
static void rna_Image_source_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
|
2009-09-16 19:27:08 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
Image *ima = ptr->id.data;
|
2009-09-16 19:27:08 +00:00
|
|
|
BKE_image_signal(ima, NULL, IMA_SIGNAL_SRC_CHANGE);
|
2010-12-05 18:59:23 +00:00
|
|
|
DAG_id_tag_update(&ima->id, 0);
|
2009-09-16 19:27:08 +00:00
|
|
|
}
|
|
|
|
|
|
2011-05-31 02:14:25 +00:00
|
|
|
static void rna_Image_fields_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
|
2009-09-16 19:27:08 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
Image *ima = ptr->id.data;
|
2009-09-16 19:27:08 +00:00
|
|
|
ImBuf *ibuf;
|
2009-09-30 18:18:32 +00:00
|
|
|
void *lock;
|
2009-09-16 19:27:08 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
|
2009-09-16 19:27:08 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (ibuf) {
|
|
|
|
|
short nr = 0;
|
2009-09-16 19:27:08 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!(ima->flag & IMA_FIELDS) && (ibuf->flags & IB_fields)) nr = 1;
|
|
|
|
|
if ((ima->flag & IMA_FIELDS) && !(ibuf->flags & IB_fields)) nr = 1;
|
2009-09-16 19:27:08 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (nr)
|
2009-09-16 19:27:08 +00:00
|
|
|
BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE);
|
|
|
|
|
}
|
2009-09-30 18:18:32 +00:00
|
|
|
|
|
|
|
|
BKE_image_release_ibuf(ima, lock);
|
2009-09-16 19:27:08 +00:00
|
|
|
}
|
|
|
|
|
|
2012-01-11 13:18:24 +00:00
|
|
|
static void rna_Image_free_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
|
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
Image *ima = ptr->id.data;
|
2012-01-11 13:18:24 +00:00
|
|
|
BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE);
|
2012-05-12 11:01:29 +00:00
|
|
|
WM_main_add_notifier(NC_IMAGE | NA_EDITED, &ima->id);
|
2012-01-11 13:18:24 +00:00
|
|
|
DAG_id_tag_update(&ima->id, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-05-31 02:14:25 +00:00
|
|
|
static void rna_Image_reload_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
|
2009-09-16 19:27:08 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
Image *ima = ptr->id.data;
|
2009-09-16 19:27:08 +00:00
|
|
|
BKE_image_signal(ima, NULL, IMA_SIGNAL_RELOAD);
|
2012-05-12 11:01:29 +00:00
|
|
|
WM_main_add_notifier(NC_IMAGE | NA_EDITED, &ima->id);
|
2010-12-05 18:59:23 +00:00
|
|
|
DAG_id_tag_update(&ima->id, 0);
|
2009-09-16 19:27:08 +00:00
|
|
|
}
|
|
|
|
|
|
2011-05-31 02:14:25 +00:00
|
|
|
static void rna_Image_generated_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
|
2009-09-16 19:27:08 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
Image *ima = ptr->id.data;
|
2009-09-16 19:27:08 +00:00
|
|
|
BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE);
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-31 02:14:25 +00:00
|
|
|
static void rna_ImageUser_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
|
2009-09-16 19:27:08 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
ImageUser *iuser = ptr->data;
|
2009-09-16 19:27:08 +00:00
|
|
|
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_image_user_frame_calc(iuser, scene->r.cfra, 0);
|
2009-09-16 19:27:08 +00:00
|
|
|
}
|
|
|
|
|
|
2010-09-20 09:52:29 +00:00
|
|
|
|
2012-09-22 14:07:55 +00:00
|
|
|
static char *rna_ImageUser_path(PointerRNA *ptr)
|
2010-09-20 09:52:29 +00:00
|
|
|
{
|
|
|
|
|
if (ptr->id.data) {
|
2012-10-26 04:14:10 +00:00
|
|
|
/* ImageUser *iuser = ptr->data; */
|
2010-09-20 09:52:29 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (GS(((ID *)ptr->id.data)->name)) {
|
2012-05-12 11:01:29 +00:00
|
|
|
case ID_TE:
|
|
|
|
|
return BLI_strdup("image_user");
|
2010-09-20 09:52:29 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return BLI_strdup("");
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
static EnumPropertyItem *rna_Image_source_itemf(bContext *UNUSED(C), PointerRNA *ptr,
|
|
|
|
|
PropertyRNA *UNUSED(prop), int *free)
|
2009-09-16 19:27:08 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
Image *ima = (Image *)ptr->data;
|
2012-03-05 23:30:41 +00:00
|
|
|
EnumPropertyItem *item = NULL;
|
|
|
|
|
int totitem = 0;
|
2009-09-16 19:27:08 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (ima->source == IMA_SRC_VIEWER) {
|
2009-09-16 19:27:08 +00:00
|
|
|
RNA_enum_items_add_value(&item, &totitem, image_source_items, IMA_SRC_VIEWER);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
RNA_enum_items_add_value(&item, &totitem, image_source_items, IMA_SRC_FILE);
|
|
|
|
|
RNA_enum_items_add_value(&item, &totitem, image_source_items, IMA_SRC_SEQUENCE);
|
|
|
|
|
RNA_enum_items_add_value(&item, &totitem, image_source_items, IMA_SRC_MOVIE);
|
|
|
|
|
RNA_enum_items_add_value(&item, &totitem, image_source_items, IMA_SRC_GENERATED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RNA_enum_item_end(&item, &totitem);
|
2012-03-05 23:30:41 +00:00
|
|
|
*free = 1;
|
2009-09-16 19:27:08 +00:00
|
|
|
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-07 20:27:40 +00:00
|
|
|
static int rna_Image_file_format_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
Image *image = (Image *)ptr->data;
|
2012-03-05 23:30:41 +00:00
|
|
|
ImBuf *ibuf = BKE_image_get_ibuf(image, NULL);
|
2010-03-07 20:27:40 +00:00
|
|
|
return BKE_ftype_to_imtype(ibuf ? ibuf->ftype : 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Image_file_format_set(PointerRNA *ptr, int value)
|
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
Image *image = (Image *)ptr->data;
|
2012-03-05 23:30:41 +00:00
|
|
|
if (BKE_imtype_is_movie(value) == 0) { /* should be able to throw an error here */
|
2010-10-28 19:40:05 +00:00
|
|
|
ImBuf *ibuf;
|
2012-03-05 23:30:41 +00:00
|
|
|
int ftype = BKE_imtype_to_ftype(value);
|
2010-10-28 19:40:05 +00:00
|
|
|
|
2012-04-22 11:54:53 +00:00
|
|
|
#if 0
|
2012-05-12 11:01:29 +00:00
|
|
|
ibuf = BKE_image_get_ibuf(image, NULL);
|
2012-03-24 06:24:53 +00:00
|
|
|
if (ibuf)
|
2012-05-12 11:01:29 +00:00
|
|
|
ibuf->ftype = ftype;
|
2012-04-22 11:54:53 +00:00
|
|
|
#endif
|
2010-10-28 19:40:05 +00:00
|
|
|
|
|
|
|
|
/* to be safe change all buffer file types */
|
2012-03-05 23:30:41 +00:00
|
|
|
for (ibuf = image->ibufs.first; ibuf; ibuf = ibuf->next) {
|
|
|
|
|
ibuf->ftype = ftype;
|
2010-10-28 19:40:05 +00:00
|
|
|
}
|
2010-03-07 20:27:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-03 17:44:20 +00:00
|
|
|
static int rna_Image_has_data_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
Image *im = (Image *)ptr->data;
|
2009-07-03 17:44:20 +00:00
|
|
|
|
|
|
|
|
if (im->ibufs.first)
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
static void rna_Image_size_get(PointerRNA *ptr, int *values)
|
2010-01-06 10:46:49 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
Image *im = (Image *)ptr->data;
|
2010-01-06 10:46:49 +00:00
|
|
|
ImBuf *ibuf;
|
|
|
|
|
void *lock;
|
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
ibuf = BKE_image_acquire_ibuf(im, NULL, &lock);
|
2010-01-06 10:46:49 +00:00
|
|
|
if (ibuf) {
|
2012-03-05 23:30:41 +00:00
|
|
|
values[0] = ibuf->x;
|
|
|
|
|
values[1] = ibuf->y;
|
2010-01-06 10:46:49 +00:00
|
|
|
}
|
2010-03-22 09:30:00 +00:00
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
values[0] = 0;
|
|
|
|
|
values[1] = 0;
|
2010-01-06 10:46:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BKE_image_release_ibuf(im, lock);
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-13 14:27:12 +00:00
|
|
|
static void rna_Image_resolution_get(PointerRNA *ptr, float *values)
|
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
Image *im = (Image *)ptr->data;
|
2011-05-13 14:27:12 +00:00
|
|
|
ImBuf *ibuf;
|
|
|
|
|
void *lock;
|
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
ibuf = BKE_image_acquire_ibuf(im, NULL, &lock);
|
2011-05-13 14:27:12 +00:00
|
|
|
if (ibuf) {
|
2012-03-05 23:30:41 +00:00
|
|
|
values[0] = ibuf->ppm[0];
|
|
|
|
|
values[1] = ibuf->ppm[1];
|
2011-05-13 14:27:12 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
values[0] = 0;
|
|
|
|
|
values[1] = 0;
|
2011-05-13 14:27:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BKE_image_release_ibuf(im, lock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Image_resolution_set(PointerRNA *ptr, const float *values)
|
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
Image *im = (Image *)ptr->data;
|
2011-05-13 14:27:12 +00:00
|
|
|
ImBuf *ibuf;
|
|
|
|
|
void *lock;
|
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
ibuf = BKE_image_acquire_ibuf(im, NULL, &lock);
|
2011-05-13 14:27:12 +00:00
|
|
|
if (ibuf) {
|
2012-03-05 23:30:41 +00:00
|
|
|
ibuf->ppm[0] = values[0];
|
|
|
|
|
ibuf->ppm[1] = values[1];
|
2011-05-13 14:27:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BKE_image_release_ibuf(im, lock);
|
|
|
|
|
}
|
2010-01-06 10:46:49 +00:00
|
|
|
|
2009-07-03 17:44:20 +00:00
|
|
|
static int rna_Image_depth_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
Image *im = (Image *)ptr->data;
|
2009-09-30 18:18:32 +00:00
|
|
|
ImBuf *ibuf;
|
|
|
|
|
void *lock;
|
2011-11-21 20:47:19 +00:00
|
|
|
int planes;
|
2009-09-30 18:18:32 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
ibuf = BKE_image_acquire_ibuf(im, NULL, &lock);
|
2009-07-03 17:44:20 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!ibuf)
|
|
|
|
|
planes = 0;
|
|
|
|
|
else if (ibuf->rect_float)
|
|
|
|
|
planes = ibuf->planes * 4;
|
2009-09-30 18:18:32 +00:00
|
|
|
else
|
2012-03-05 23:30:41 +00:00
|
|
|
planes = ibuf->planes;
|
2009-07-03 17:44:20 +00:00
|
|
|
|
2009-09-30 18:18:32 +00:00
|
|
|
BKE_image_release_ibuf(im, lock);
|
2009-07-03 17:44:20 +00:00
|
|
|
|
2011-11-21 20:47:19 +00:00
|
|
|
return planes;
|
2009-07-03 17:44:20 +00:00
|
|
|
}
|
|
|
|
|
|
2012-05-26 14:53:33 +00:00
|
|
|
static int rna_Image_frame_duration_get(PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
Image *im = (Image *)ptr->data;
|
|
|
|
|
|
|
|
|
|
if (im->anim)
|
|
|
|
|
return IMB_anim_get_duration(im->anim, IMB_TC_RECORD_RUN);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-03 16:17:39 +00:00
|
|
|
static int rna_Image_pixels_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
|
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
Image *ima = ptr->id.data;
|
2011-04-03 16:17:39 +00:00
|
|
|
ImBuf *ibuf;
|
|
|
|
|
void *lock;
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
|
2011-04-03 16:17:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (ibuf)
|
2012-05-12 11:01:29 +00:00
|
|
|
length[0] = ibuf->x * ibuf->y * ibuf->channels;
|
2011-04-04 17:10:48 +00:00
|
|
|
else
|
2012-03-05 23:30:41 +00:00
|
|
|
length[0] = 0;
|
2011-04-03 16:17:39 +00:00
|
|
|
|
|
|
|
|
BKE_image_release_ibuf(ima, lock);
|
|
|
|
|
|
2011-04-04 17:10:48 +00:00
|
|
|
return length[0];
|
2011-04-03 16:17:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Image_pixels_get(PointerRNA *ptr, float *values)
|
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
Image *ima = ptr->id.data;
|
2011-04-03 16:17:39 +00:00
|
|
|
ImBuf *ibuf;
|
|
|
|
|
void *lock;
|
|
|
|
|
int i, size;
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
|
2011-04-03 16:17:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (ibuf) {
|
2012-05-12 11:01:29 +00:00
|
|
|
size = ibuf->x * ibuf->y * ibuf->channels;
|
2011-04-03 16:17:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (ibuf->rect_float) {
|
2012-05-12 11:01:29 +00:00
|
|
|
memcpy(values, ibuf->rect_float, sizeof(float) * size);
|
2011-04-03 16:17:39 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
for (i = 0; i < size; i++)
|
2012-05-12 11:01:29 +00:00
|
|
|
values[i] = ((unsigned char *)ibuf->rect)[i] * (1.0f / 255.0f);
|
2011-04-03 16:17:39 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BKE_image_release_ibuf(ima, lock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Image_pixels_set(PointerRNA *ptr, const float *values)
|
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
Image *ima = ptr->id.data;
|
2011-04-03 16:17:39 +00:00
|
|
|
ImBuf *ibuf;
|
|
|
|
|
void *lock;
|
|
|
|
|
int i, size;
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
|
2011-04-03 16:17:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (ibuf) {
|
2012-05-12 11:01:29 +00:00
|
|
|
size = ibuf->x * ibuf->y * ibuf->channels;
|
2011-04-03 16:17:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (ibuf->rect_float) {
|
2012-05-12 11:01:29 +00:00
|
|
|
memcpy(ibuf->rect_float, values, sizeof(float) * size);
|
2011-04-03 16:17:39 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
for (i = 0; i < size; i++)
|
2012-05-12 11:01:29 +00:00
|
|
|
((unsigned char *)ibuf->rect)[i] = FTOCHAR(values[i]);
|
2011-04-03 16:17:39 +00:00
|
|
|
}
|
2011-04-06 12:54:47 +00:00
|
|
|
|
2012-10-23 09:59:04 +00:00
|
|
|
ibuf->userflags |= IB_BITMAPDIRTY | IB_DISPLAY_BUFFER_INVALID;
|
2011-04-03 16:17:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BKE_image_release_ibuf(ima, lock);
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-30 18:39:49 +00:00
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
static void rna_def_imageuser(BlenderRNA *brna)
|
|
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "ImageUser", NULL);
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Image User",
|
|
|
|
|
"Parameters defining how an Image datablock is used by another datablock");
|
2010-09-20 09:52:29 +00:00
|
|
|
RNA_def_struct_path_func(srna, "rna_ImageUser_path");
|
2008-11-30 18:39:49 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "use_auto_refresh", PROP_BOOLEAN, PROP_NONE);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_ANIM_ALWAYS);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Auto Refresh", "Always refresh image on frame changes");
|
2009-09-16 19:27:08 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_ImageUser_update");
|
2008-11-30 18:39:49 +00:00
|
|
|
|
|
|
|
|
/* animation */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "use_cyclic", PROP_BOOLEAN, PROP_NONE);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "cycl", 0);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Cyclic", "Cycle the images in the movie");
|
2009-09-16 19:27:08 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_ImageUser_update");
|
2008-11-30 18:39:49 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_NONE);
|
2010-08-21 04:51:00 +00:00
|
|
|
RNA_def_property_int_sdna(prop, NULL, "frames");
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_range(prop, 0, MAXFRAMEF);
|
2011-10-20 07:56:04 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Frames", "Number of images of a movie to use");
|
2009-09-16 19:27:08 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_ImageUser_update");
|
2008-11-30 18:39:49 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "frame_offset", PROP_INT, PROP_NONE);
|
2010-08-21 04:51:00 +00:00
|
|
|
RNA_def_property_int_sdna(prop, NULL, "offset");
|
2011-10-20 07:56:04 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Offset", "Offset the number of the frame to use in the animation");
|
2009-09-16 19:27:08 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_ImageUser_update");
|
2008-11-30 18:39:49 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_int_sdna(prop, NULL, "sfra");
|
2010-09-15 03:45:33 +00:00
|
|
|
RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Start Frame",
|
|
|
|
|
"Global starting frame of the movie/sequence, assuming first picture has a #1");
|
2009-09-16 19:27:08 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_ImageUser_update");
|
2008-11-30 18:39:49 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "fields_per_frame", PROP_INT, PROP_NONE);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_int_sdna(prop, NULL, "fie_ima");
|
2010-11-21 03:45:35 +00:00
|
|
|
RNA_def_property_range(prop, 1, 200);
|
2011-10-20 07:56:04 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Fields per Frame", "Number of fields per rendered frame (2 fields is 1 image)");
|
2009-09-16 19:27:08 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_ImageUser_update");
|
2008-11-30 18:39:49 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "multilayer_layer", PROP_INT, PROP_UNSIGNED);
|
2008-12-18 23:34:19 +00:00
|
|
|
RNA_def_property_int_sdna(prop, NULL, "layer");
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* image_multi_cb */
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Layer", "Layer in multilayer image");
|
2008-11-30 18:39:49 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "multilayer_pass", PROP_INT, PROP_UNSIGNED);
|
2008-12-18 23:34:19 +00:00
|
|
|
RNA_def_property_int_sdna(prop, NULL, "pass");
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* image_multi_cb */
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Pass", "Pass in multilayer image");
|
2008-11-30 18:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_def_image(BlenderRNA *brna)
|
|
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
|
|
|
|
PropertyRNA *prop;
|
2012-03-05 23:30:41 +00:00
|
|
|
static const EnumPropertyItem prop_type_items[] = {
|
2009-06-16 00:52:21 +00:00
|
|
|
{IMA_TYPE_IMAGE, "IMAGE", 0, "Image", ""},
|
|
|
|
|
{IMA_TYPE_MULTILAYER, "MULTILAYER", 0, "Multilayer", ""},
|
2009-09-16 19:27:08 +00:00
|
|
|
{IMA_TYPE_UV_TEST, "UV_TEST", 0, "UV Test", ""},
|
|
|
|
|
{IMA_TYPE_R_RESULT, "RENDER_RESULT", 0, "Render Result", ""},
|
2009-06-16 00:52:21 +00:00
|
|
|
{IMA_TYPE_COMPOSITE, "COMPOSITING", 0, "Compositing", ""},
|
2012-05-12 11:01:29 +00:00
|
|
|
{0, NULL, 0, NULL, NULL}
|
|
|
|
|
};
|
2012-03-05 23:30:41 +00:00
|
|
|
static const EnumPropertyItem prop_mapping_items[] = {
|
2009-06-16 00:52:21 +00:00
|
|
|
{0, "UV", 0, "UV Coordinates", "Use UV coordinates for mapping the image"},
|
|
|
|
|
{IMA_REFLECT, "REFLECTION", 0, "Reflection", "Use reflection mapping for mapping the image"},
|
2012-05-12 11:01:29 +00:00
|
|
|
{0, NULL, 0, NULL, NULL}
|
|
|
|
|
};
|
2012-03-05 23:30:41 +00:00
|
|
|
static const EnumPropertyItem prop_field_order_items[] = {
|
2010-02-10 18:29:58 +00:00
|
|
|
{0, "EVEN", 0, "Upper First", "Upper field first"},
|
|
|
|
|
{IMA_STD_FIELD, "ODD", 0, "Lower First", "Lower field first"},
|
2012-05-12 11:01:29 +00:00
|
|
|
{0, NULL, 0, NULL, NULL}
|
|
|
|
|
};
|
2008-11-30 18:39:49 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "Image", "ID");
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Image", "Image datablock referencing an external or packed image");
|
2009-06-03 23:16:51 +00:00
|
|
|
RNA_def_struct_ui_icon(srna, ICON_IMAGE_DATA);
|
2008-11-30 18:39:49 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_string_sdna(prop, NULL, "name");
|
2010-06-02 17:58:28 +00:00
|
|
|
RNA_def_property_ui_text(prop, "File Name", "Image/Movie file name");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_reload_update");
|
2008-11-30 18:39:49 +00:00
|
|
|
|
2010-03-06 21:47:16 +00:00
|
|
|
/* eek. this is horrible but needed so we can save to a new name without blanking the data :( */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "filepath_raw", PROP_STRING, PROP_FILEPATH);
|
2010-03-06 21:47:16 +00:00
|
|
|
RNA_def_property_string_sdna(prop, NULL, "name");
|
2010-06-02 17:58:28 +00:00
|
|
|
RNA_def_property_ui_text(prop, "File Name", "Image/Movie file name (without data refreshing)");
|
2010-03-06 21:47:16 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "file_format", PROP_ENUM, PROP_NONE);
|
2010-03-07 20:27:40 +00:00
|
|
|
RNA_def_property_enum_items(prop, image_type_items);
|
|
|
|
|
RNA_def_property_enum_funcs(prop, "rna_Image_file_format_get", "rna_Image_file_format_set", NULL);
|
|
|
|
|
RNA_def_property_ui_text(prop, "File Format", "Format used for re-saving this file");
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "source", PROP_ENUM, PROP_NONE);
|
2009-09-16 19:27:08 +00:00
|
|
|
RNA_def_property_enum_items(prop, image_source_items);
|
|
|
|
|
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Image_source_itemf");
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Source", "Where the image comes from");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_source_update");
|
2008-11-30 18:39:49 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_enum_items(prop, prop_type_items);
|
2009-09-16 19:27:08 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Type", "How to generate the image");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
2008-11-30 18:39:49 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_pointer_sdna(prop, NULL, "packedfile");
|
|
|
|
|
RNA_def_property_ui_text(prop, "Packed File", "");
|
2009-09-16 19:58:01 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "field_order", PROP_ENUM, PROP_NONE);
|
2009-09-16 19:58:01 +00:00
|
|
|
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
|
|
|
|
|
RNA_def_property_enum_items(prop, prop_field_order_items);
|
2011-11-26 12:30:01 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Field Order", "Order of video fields (select which lines are displayed first)");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
2009-09-16 19:58:01 +00:00
|
|
|
|
2008-11-30 18:39:49 +00:00
|
|
|
/* booleans */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "use_fields", PROP_BOOLEAN, PROP_NONE);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_FIELDS);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Fields", "Use fields of the image");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_fields_update");
|
2008-11-30 18:39:49 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "use_premultiply", PROP_BOOLEAN, PROP_NONE);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_DO_PREMUL);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Premultiply", "Convert RGB from key alpha to premultiplied alpha");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_free_update");
|
2011-12-30 14:17:11 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "use_color_unpremultiply", PROP_BOOLEAN, PROP_NONE);
|
2011-12-30 14:17:11 +00:00
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_CM_PREDIVIDE);
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Color Unpremultiply",
|
|
|
|
|
"For premultiplied alpha images, do color space conversion on colors without alpha, "
|
|
|
|
|
"to avoid fringing for images with light backgrounds");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_free_update");
|
2008-11-30 18:39:49 +00:00
|
|
|
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
prop = RNA_def_property(srna, "view_as_render", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_VIEW_AS_RENDER);
|
|
|
|
|
RNA_def_property_ui_text(prop, "View as Render", "Apply render part of display transformation when displaying this image on the screen");
|
|
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "is_dirty", PROP_BOOLEAN, PROP_NONE);
|
2009-06-30 19:10:14 +00:00
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Image_dirty_get", NULL);
|
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Dirty", "Image has changed and is not saved");
|
2009-06-30 19:10:14 +00:00
|
|
|
|
2008-11-30 18:39:49 +00:00
|
|
|
/* generated image (image_generated_change_cb) */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "generated_type", PROP_ENUM, PROP_NONE);
|
2008-12-03 20:17:12 +00:00
|
|
|
RNA_def_property_enum_sdna(prop, NULL, "gen_type");
|
2012-08-29 08:17:38 +00:00
|
|
|
RNA_def_property_enum_items(prop, image_generated_type_items);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Generated Type", "Generated image type");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");
|
2008-11-30 18:39:49 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "generated_width", PROP_INT, PROP_NONE);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_int_sdna(prop, NULL, "gen_x");
|
2009-04-12 17:28:41 +00:00
|
|
|
RNA_def_property_range(prop, 1, 16384);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Generated Width", "Generated image width");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");
|
2008-11-30 18:39:49 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "generated_height", PROP_INT, PROP_NONE);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_int_sdna(prop, NULL, "gen_y");
|
2009-04-12 17:28:41 +00:00
|
|
|
RNA_def_property_range(prop, 1, 16384);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Generated Height", "Generated image height");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");
|
2008-11-30 18:39:49 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "use_generated_float", PROP_BOOLEAN, PROP_NONE);
|
2011-07-21 00:41:00 +00:00
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "gen_flag", IMA_GEN_FLOAT);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Float Buffer", "Generate floating point buffer");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");
|
2011-07-21 00:41:00 +00:00
|
|
|
|
2008-11-30 18:39:49 +00:00
|
|
|
/* realtime properties */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE);
|
2008-12-03 20:17:12 +00:00
|
|
|
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_enum_items(prop, prop_mapping_items);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Mapping", "Mapping type to use for this image in the game engine");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
2008-11-30 18:39:49 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "display_aspect", PROP_FLOAT, PROP_XYZ);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_float_sdna(prop, NULL, "aspx");
|
|
|
|
|
RNA_def_property_array(prop, 2);
|
|
|
|
|
RNA_def_property_range(prop, 0.1f, 5000.0f);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Display Aspect", "Display Aspect for this image, does not affect rendering");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
2008-11-30 18:39:49 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "use_animation", PROP_BOOLEAN, PROP_NONE);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_TWINANIM);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Animated", "Use as animated texture in the game engine");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_animated_update");
|
2008-11-30 18:39:49 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_NONE);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_int_sdna(prop, NULL, "twsta");
|
|
|
|
|
RNA_def_property_range(prop, 0, 128);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Animation Start", "Start frame of an animated texture");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_animated_update");
|
2008-11-30 18:39:49 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_NONE);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_int_sdna(prop, NULL, "twend");
|
|
|
|
|
RNA_def_property_range(prop, 0, 128);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Animation End", "End frame of an animated texture");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_animated_update");
|
2008-11-30 18:39:49 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "fps", PROP_INT, PROP_NONE);
|
2008-12-26 02:02:06 +00:00
|
|
|
RNA_def_property_int_sdna(prop, NULL, "animspeed");
|
|
|
|
|
RNA_def_property_range(prop, 1, 100);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Animation Speed", "Speed of the animation in frames per second");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
2008-11-30 18:39:49 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "use_tiles", PROP_BOOLEAN, PROP_NONE);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_TILES);
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Tiles",
|
|
|
|
|
"Use of tilemode for faces (default shift-LMB to pick the tile for selected faces)");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
2008-11-30 18:39:49 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "tiles_x", PROP_INT, PROP_NONE);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_int_sdna(prop, NULL, "xrep");
|
|
|
|
|
RNA_def_property_range(prop, 1, 16);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Tiles X", "Degree of repetition in the X direction");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
2008-11-30 18:39:49 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "tiles_y", PROP_INT, PROP_NONE);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_int_sdna(prop, NULL, "yrep");
|
|
|
|
|
RNA_def_property_range(prop, 1, 16);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Tiles Y", "Degree of repetition in the Y direction");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
2008-11-30 18:39:49 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "use_clamp_x", PROP_BOOLEAN, PROP_NONE);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_CLAMP_U);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Clamp X", "Disable texture repeating horizontally");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
2008-11-30 18:39:49 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "use_clamp_y", PROP_BOOLEAN, PROP_NONE);
|
2008-11-30 18:39:49 +00:00
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_CLAMP_V);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Clamp Y", "Disable texture repeating vertically");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
2010-06-03 16:26:04 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "bindcode", PROP_INT, PROP_UNSIGNED);
|
2010-06-03 16:26:04 +00:00
|
|
|
RNA_def_property_int_sdna(prop, NULL, "bindcode");
|
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Bindcode", "OpenGL bindcode");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
2009-07-03 17:44:20 +00:00
|
|
|
|
2012-03-28 09:10:19 +00:00
|
|
|
prop = RNA_def_property(srna, "render_slot", PROP_INT, PROP_UNSIGNED);
|
|
|
|
|
RNA_def_property_range(prop, 0, IMA_MAX_RENDER_SLOT - 1);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Render Slot", "The current render slot displayed, only for viewer type images");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
2012-03-28 09:10:19 +00:00
|
|
|
|
2009-07-03 17:44:20 +00:00
|
|
|
/*
|
2012-04-22 11:54:53 +00:00
|
|
|
* Image.has_data and Image.depth are temporary,
|
|
|
|
|
* Update import_obj.py when they are replaced (Arystan)
|
|
|
|
|
*/
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "has_data", PROP_BOOLEAN, PROP_NONE);
|
2009-07-03 17:44:20 +00:00
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Image_has_data_get", NULL);
|
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Has data", "True if this image has data");
|
2009-07-03 17:44:20 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED);
|
2009-07-03 17:44:20 +00:00
|
|
|
RNA_def_property_int_funcs(prop, "rna_Image_depth_get", NULL, NULL);
|
2010-02-10 18:29:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Depth", "Image bit depth");
|
2009-07-03 17:44:20 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2009-07-23 12:55:26 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
prop = RNA_def_int_vector(srna, "size", 2, NULL, 0, 0, "Size",
|
|
|
|
|
"Width and height in pixels, zero when image data cant be loaded", 0, 0);
|
|
|
|
|
RNA_def_property_int_funcs(prop, "rna_Image_size_get", NULL, NULL);
|
2010-01-06 10:46:49 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
prop = RNA_def_float_vector(srna, "resolution", 2, NULL, 0, 0, "Resolution", "X/Y pixels per meter", 0, 0);
|
|
|
|
|
RNA_def_property_float_funcs(prop, "rna_Image_resolution_get", "rna_Image_resolution_set", NULL);
|
2011-05-13 14:27:12 +00:00
|
|
|
|
2012-05-26 14:53:33 +00:00
|
|
|
prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_UNSIGNED);
|
|
|
|
|
RNA_def_property_int_funcs(prop, "rna_Image_frame_duration_get", NULL, NULL);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Duration", "Duration (in frames) of the image (1 when not a video/sequence)");
|
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "pixels", PROP_FLOAT, PROP_NONE);
|
2011-04-03 16:17:39 +00:00
|
|
|
RNA_def_property_flag(prop, PROP_DYNAMIC);
|
2011-04-04 17:10:48 +00:00
|
|
|
RNA_def_property_multi_array(prop, 1, NULL);
|
2011-04-03 16:17:39 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Pixels", "Image pixels in floating point values");
|
|
|
|
|
RNA_def_property_dynamic_array_funcs(prop, "rna_Image_pixels_get_length");
|
|
|
|
|
RNA_def_property_float_funcs(prop, "rna_Image_pixels_get", "rna_Image_pixels_set", NULL);
|
|
|
|
|
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
prop = RNA_def_property(srna, "colorspace_settings", PROP_POINTER, PROP_NONE);
|
|
|
|
|
RNA_def_property_pointer_sdna(prop, NULL, "colorspace_settings");
|
|
|
|
|
RNA_def_property_struct_type(prop, "ColorManagedColorspaceSettings");
|
2012-09-18 07:14:16 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Color Space Settings", "Input color space settings");
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
|
2009-07-23 12:55:26 +00:00
|
|
|
RNA_api_image(srna);
|
2008-11-30 18:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RNA_def_image(BlenderRNA *brna)
|
|
|
|
|
{
|
|
|
|
|
rna_def_image(brna);
|
|
|
|
|
rna_def_imageuser(brna);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|