~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to source/blender/makesrna/intern/rna_image.c

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * $Id: rna_image.c 30519 2010-07-20 02:18:10Z jwilkins $
3
 
 *
 
1
/*
4
2
 * ***** BEGIN GPL LICENSE BLOCK *****
5
3
 *
6
4
 * This program is free software; you can redistribute it and/or
22
20
 * ***** END GPL LICENSE BLOCK *****
23
21
 */
24
22
 
 
23
/** \file blender/makesrna/intern/rna_image.c
 
24
 *  \ingroup RNA
 
25
 */
 
26
 
 
27
 
25
28
#include <stdlib.h>
26
29
 
27
30
#include "RNA_define.h"
37
40
#include "BKE_image.h"
38
41
 
39
42
#include "WM_types.h"
 
43
#include "WM_api.h"
40
44
 
41
 
static EnumPropertyItem image_source_items[]= {
42
 
        {IMA_SRC_FILE, "FILE", 0, "File", "Single image file"},
43
 
        {IMA_SRC_SEQUENCE, "SEQUENCE", 0, "Sequence", "Multiple image files, as a sequence"},
 
45
static EnumPropertyItem image_source_items[] = {
 
46
        {IMA_SRC_FILE, "FILE", 0, "Single Image", "Single image file"},
 
47
        {IMA_SRC_SEQUENCE, "SEQUENCE", 0, "Image Sequence", "Multiple image files, as a sequence"},
44
48
        {IMA_SRC_MOVIE, "MOVIE", 0, "Movie", "Movie file"},
45
49
        {IMA_SRC_GENERATED, "GENERATED", 0, "Generated", "Generated image"},
46
50
        {IMA_SRC_VIEWER, "VIEWER", 0, "Viewer", "Compositing node viewer"},
50
54
 
51
55
#include "IMB_imbuf_types.h"
52
56
 
53
 
static void rna_Image_animated_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 
57
static void rna_Image_animated_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
54
58
{
55
 
        Image *ima= (Image*)ptr->data;
 
59
        Image *ima = (Image*)ptr->data;
56
60
        int  nr;
57
61
 
58
 
        if(ima->flag & IMA_TWINANIM) {
59
 
                nr= ima->xrep*ima->yrep;
60
 
                if(ima->twsta>=nr) ima->twsta= 1;
61
 
                if(ima->twend>=nr) ima->twend= nr-1;
62
 
                if(ima->twsta>ima->twend) ima->twsta= 1;
 
62
        if (ima->flag & IMA_TWINANIM) {
 
63
                nr = ima->xrep*ima->yrep;
 
64
                if (ima->twsta >= nr) ima->twsta = 1;
 
65
                if (ima->twend >= nr) ima->twend = nr-1;
 
66
                if (ima->twsta>ima->twend) ima->twsta = 1;
63
67
        }
64
68
}
65
69
 
66
70
static int rna_Image_dirty_get(PointerRNA *ptr)
67
71
{
68
 
        Image *ima= (Image*)ptr->data;
 
72
        Image *ima = (Image*)ptr->data;
69
73
        ImBuf *ibuf;
70
74
 
71
 
        for(ibuf=ima->ibufs.first; ibuf; ibuf=ibuf->next)
72
 
                if(ibuf->userflags & IB_BITMAPDIRTY)
 
75
        for (ibuf = ima->ibufs.first; ibuf; ibuf = ibuf->next)
 
76
                if (ibuf->userflags & IB_BITMAPDIRTY)
73
77
                        return 1;
74
78
        
75
79
        return 0;
76
80
}
77
81
 
78
 
static void rna_Image_source_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 
82
static void rna_Image_source_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
79
83
{
80
 
        Image *ima= ptr->id.data;
 
84
        Image *ima = ptr->id.data;
81
85
        BKE_image_signal(ima, NULL, IMA_SIGNAL_SRC_CHANGE);
82
 
        DAG_id_flush_update(&ima->id, 0);
 
86
        DAG_id_tag_update(&ima->id, 0);
83
87
}
84
88
 
85
 
static void rna_Image_fields_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 
89
static void rna_Image_fields_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
86
90
{
87
 
        Image *ima= ptr->id.data;
 
91
        Image *ima = ptr->id.data;
88
92
        ImBuf *ibuf;
89
93
        void *lock;
90
94
 
91
 
        ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock);
92
 
 
93
 
        if(ibuf) {
94
 
                short nr= 0;
95
 
 
96
 
                if(!(ima->flag & IMA_FIELDS) && (ibuf->flags & IB_fields)) nr= 1;
97
 
                if((ima->flag & IMA_FIELDS) && !(ibuf->flags & IB_fields)) nr= 1;
98
 
 
99
 
                if(nr)
 
95
        ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
 
96
 
 
97
        if (ibuf) {
 
98
                short nr = 0;
 
99
 
 
100
                if (!(ima->flag & IMA_FIELDS) && (ibuf->flags & IB_fields)) nr = 1;
 
101
                if ((ima->flag & IMA_FIELDS) && !(ibuf->flags & IB_fields)) nr = 1;
 
102
 
 
103
                if (nr)
100
104
                        BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE);
101
105
        }
102
106
 
103
107
        BKE_image_release_ibuf(ima, lock);
104
108
}
105
109
 
106
 
static void rna_Image_reload_update(Main *bmain, Scene *scene, PointerRNA *ptr)
107
 
{
108
 
        Image *ima= ptr->id.data;
 
110
static void rna_Image_free_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
 
111
{
 
112
        Image *ima = ptr->id.data;
 
113
        BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE);
 
114
        WM_main_add_notifier(NC_IMAGE|NA_EDITED, &ima->id);
 
115
        DAG_id_tag_update(&ima->id, 0);
 
116
}
 
117
 
 
118
 
 
119
static void rna_Image_reload_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
 
120
{
 
121
        Image *ima = ptr->id.data;
109
122
        BKE_image_signal(ima, NULL, IMA_SIGNAL_RELOAD);
110
 
        DAG_id_flush_update(&ima->id, 0);
 
123
        WM_main_add_notifier(NC_IMAGE|NA_EDITED, &ima->id);
 
124
        DAG_id_tag_update(&ima->id, 0);
111
125
}
112
126
 
113
 
static void rna_Image_generated_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 
127
static void rna_Image_generated_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
114
128
{
115
 
        Image *ima= ptr->id.data;
 
129
        Image *ima = ptr->id.data;
116
130
        BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE);
117
131
}
118
132
 
119
 
static void rna_ImageUser_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 
133
static void rna_ImageUser_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
120
134
{
121
 
        ImageUser *iuser= ptr->data;
 
135
        ImageUser *iuser = ptr->data;
122
136
 
123
137
        BKE_image_user_calc_frame(iuser, scene->r.cfra, 0);
124
138
}
125
139
 
126
 
static EnumPropertyItem *rna_Image_source_itemf(bContext *C, PointerRNA *ptr, int *free)
127
 
{
128
 
        Image *ima= (Image*)ptr->data;
129
 
        EnumPropertyItem *item= NULL;
130
 
        int totitem= 0;
131
 
        
132
 
        if(ima->source == IMA_SRC_VIEWER) {
 
140
 
 
141
char *rna_ImageUser_path(PointerRNA *ptr)
 
142
{
 
143
        if (ptr->id.data) {
 
144
                /* ImageUser *iuser= ptr->data; */
 
145
                
 
146
                switch (GS(((ID *)ptr->id.data)->name)) {
 
147
                case ID_TE:
 
148
                        return BLI_strdup("image_user");
 
149
                }
 
150
        }
 
151
        
 
152
        return BLI_strdup("");
 
153
}
 
154
 
 
155
static EnumPropertyItem *rna_Image_source_itemf(bContext *UNUSED(C), PointerRNA *ptr,
 
156
                                                PropertyRNA *UNUSED(prop), int *free)
 
157
{
 
158
        Image *ima = (Image*)ptr->data;
 
159
        EnumPropertyItem *item = NULL;
 
160
        int totitem = 0;
 
161
        
 
162
        if (ima->source == IMA_SRC_VIEWER) {
133
163
                RNA_enum_items_add_value(&item, &totitem, image_source_items, IMA_SRC_VIEWER);
134
164
        }
135
165
        else {
140
170
        }
141
171
 
142
172
        RNA_enum_item_end(&item, &totitem);
143
 
        *free= 1;
 
173
        *free = 1;
144
174
 
145
175
        return item;
146
176
}
147
177
 
148
178
static int rna_Image_file_format_get(PointerRNA *ptr)
149
179
{
150
 
        Image *image= (Image*)ptr->data;
151
 
        ImBuf *ibuf= BKE_image_get_ibuf(image, NULL);
 
180
        Image *image = (Image*)ptr->data;
 
181
        ImBuf *ibuf = BKE_image_get_ibuf(image, NULL);
152
182
        return BKE_ftype_to_imtype(ibuf ? ibuf->ftype : 0);
153
183
}
154
184
 
155
185
static void rna_Image_file_format_set(PointerRNA *ptr, int value)
156
186
{
157
 
        Image *image= (Image*)ptr->data;
158
 
        if(BKE_imtype_is_movie(value) == 0) { /* should be able to throw an error here */
159
 
                ImBuf *ibuf= BKE_image_get_ibuf(image, NULL);
160
 
                if(ibuf)
161
 
                        ibuf->ftype= BKE_imtype_to_ftype(value);
 
187
        Image *image = (Image*)ptr->data;
 
188
        if (BKE_imtype_is_movie(value) == 0) { /* should be able to throw an error here */
 
189
                ImBuf *ibuf;
 
190
                int ftype = BKE_imtype_to_ftype(value);
 
191
 
 
192
#if 0
 
193
                ibuf= BKE_image_get_ibuf(image, NULL);
 
194
                if (ibuf)
 
195
                        ibuf->ftype= ftype;
 
196
#endif
 
197
 
 
198
                /* to be safe change all buffer file types */
 
199
                for (ibuf = image->ibufs.first; ibuf; ibuf = ibuf->next) {
 
200
                        ibuf->ftype = ftype;
 
201
                }
162
202
        }
163
203
}
164
204
 
165
205
static int rna_Image_has_data_get(PointerRNA *ptr)
166
206
{
167
 
        Image *im= (Image*)ptr->data;
 
207
        Image *im = (Image*)ptr->data;
168
208
 
169
209
        if (im->ibufs.first)
170
210
                return 1;
174
214
 
175
215
static void rna_Image_size_get(PointerRNA *ptr,int *values)
176
216
{
177
 
        Image *im= (Image*)ptr->data;
178
 
        ImBuf *ibuf;
179
 
        void *lock;
180
 
 
181
 
        ibuf = BKE_image_acquire_ibuf(im, NULL , &lock);
182
 
        if (ibuf) {
183
 
                values[0]= ibuf->x;
184
 
                values[1]= ibuf->y;
185
 
        }
186
 
        else {
187
 
                values[0]= 0;
188
 
                values[1]= 0;
189
 
        }
190
 
 
191
 
        BKE_image_release_ibuf(im, lock);
192
 
}
193
 
 
 
217
        Image *im = (Image*)ptr->data;
 
218
        ImBuf *ibuf;
 
219
        void *lock;
 
220
 
 
221
        ibuf = BKE_image_acquire_ibuf(im, NULL , &lock);
 
222
        if (ibuf) {
 
223
                values[0] = ibuf->x;
 
224
                values[1] = ibuf->y;
 
225
        }
 
226
        else {
 
227
                values[0] = 0;
 
228
                values[1] = 0;
 
229
        }
 
230
 
 
231
        BKE_image_release_ibuf(im, lock);
 
232
}
 
233
 
 
234
static void rna_Image_resolution_get(PointerRNA *ptr, float *values)
 
235
{
 
236
        Image *im = (Image*)ptr->data;
 
237
        ImBuf *ibuf;
 
238
        void *lock;
 
239
 
 
240
        ibuf = BKE_image_acquire_ibuf(im, NULL , &lock);
 
241
        if (ibuf) {
 
242
                values[0] = ibuf->ppm[0];
 
243
                values[1] = ibuf->ppm[1];
 
244
        }
 
245
        else {
 
246
                values[0] = 0;
 
247
                values[1] = 0;
 
248
        }
 
249
 
 
250
        BKE_image_release_ibuf(im, lock);
 
251
}
 
252
 
 
253
static void rna_Image_resolution_set(PointerRNA *ptr, const float *values)
 
254
{
 
255
        Image *im = (Image*)ptr->data;
 
256
        ImBuf *ibuf;
 
257
        void *lock;
 
258
 
 
259
        ibuf = BKE_image_acquire_ibuf(im, NULL , &lock);
 
260
        if (ibuf) {
 
261
                ibuf->ppm[0] = values[0];
 
262
                ibuf->ppm[1] = values[1];
 
263
        }
 
264
 
 
265
        BKE_image_release_ibuf(im, lock);
 
266
}
194
267
 
195
268
static int rna_Image_depth_get(PointerRNA *ptr)
196
269
{
197
 
        Image *im= (Image*)ptr->data;
 
270
        Image *im = (Image*)ptr->data;
198
271
        ImBuf *ibuf;
199
272
        void *lock;
200
 
        int depth;
 
273
        int planes;
201
274
        
202
 
        ibuf= BKE_image_acquire_ibuf(im, NULL, &lock);
 
275
        ibuf = BKE_image_acquire_ibuf(im, NULL, &lock);
203
276
 
204
 
        if(!ibuf)
205
 
                depth= 0;
206
 
        else if(ibuf->rect_float)
207
 
                depth= 128;
 
277
        if (!ibuf)
 
278
                planes = 0;
 
279
        else if (ibuf->rect_float)
 
280
                planes = ibuf->planes * 4;
208
281
        else
209
 
                depth= ibuf->depth;
 
282
                planes = ibuf->planes;
210
283
 
211
284
        BKE_image_release_ibuf(im, lock);
212
285
 
213
 
        return depth;
 
286
        return planes;
 
287
}
 
288
 
 
289
static int rna_Image_pixels_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
 
290
{
 
291
        Image *ima = ptr->id.data;
 
292
        ImBuf *ibuf;
 
293
        void *lock;
 
294
 
 
295
        ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
 
296
 
 
297
        if (ibuf)
 
298
                length[0] = ibuf->x*ibuf->y*ibuf->channels;
 
299
        else
 
300
                length[0] = 0;
 
301
 
 
302
        BKE_image_release_ibuf(ima, lock);
 
303
 
 
304
        return length[0];
 
305
}
 
306
 
 
307
static void rna_Image_pixels_get(PointerRNA *ptr, float *values)
 
308
{
 
309
        Image *ima = ptr->id.data;
 
310
        ImBuf *ibuf;
 
311
        void *lock;
 
312
        int i, size;
 
313
 
 
314
        ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
 
315
 
 
316
        if (ibuf) {
 
317
                size = ibuf->x*ibuf->y*ibuf->channels;
 
318
 
 
319
                if (ibuf->rect_float) {
 
320
                        memcpy(values, ibuf->rect_float, sizeof(float)*size);
 
321
                }
 
322
                else {
 
323
                        for (i = 0; i < size; i++)
 
324
                                values[i] = ((unsigned char*)ibuf->rect)[i]*(1.0f/255.0f);
 
325
                }
 
326
        }
 
327
 
 
328
        BKE_image_release_ibuf(ima, lock);
 
329
}
 
330
 
 
331
static void rna_Image_pixels_set(PointerRNA *ptr, const float *values)
 
332
{
 
333
        Image *ima = ptr->id.data;
 
334
        ImBuf *ibuf;
 
335
        void *lock;
 
336
        int i, size;
 
337
 
 
338
        ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
 
339
 
 
340
        if (ibuf) {
 
341
                size = ibuf->x*ibuf->y*ibuf->channels;
 
342
 
 
343
                if (ibuf->rect_float) {
 
344
                        memcpy(ibuf->rect_float, values, sizeof(float)*size);
 
345
                }
 
346
                else {
 
347
                        for (i = 0; i < size; i++)
 
348
                                ((unsigned char*)ibuf->rect)[i] = FTOCHAR(values[i]);
 
349
                }
 
350
 
 
351
                ibuf->userflags |= IB_BITMAPDIRTY;
 
352
        }
 
353
 
 
354
        BKE_image_release_ibuf(ima, lock);
214
355
}
215
356
 
216
357
#else
220
361
        StructRNA *srna;
221
362
        PropertyRNA *prop;
222
363
 
223
 
        srna= RNA_def_struct(brna, "ImageUser", NULL);
224
 
        RNA_def_struct_ui_text(srna, "Image User", "Parameters defining how an Image datablock is used by another datablock");
 
364
        srna = RNA_def_struct(brna, "ImageUser", NULL);
 
365
        RNA_def_struct_ui_text(srna, "Image User",
 
366
                               "Parameters defining how an Image datablock is used by another datablock");
 
367
        RNA_def_struct_path_func(srna, "rna_ImageUser_path");
225
368
 
226
 
        prop= RNA_def_property(srna, "auto_refresh", PROP_BOOLEAN, PROP_NONE);
 
369
        prop = RNA_def_property(srna, "use_auto_refresh", PROP_BOOLEAN, PROP_NONE);
227
370
        RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_ANIM_ALWAYS);
228
371
        RNA_def_property_ui_text(prop, "Auto Refresh", "Always refresh image on frame changes");
229
372
        RNA_def_property_update(prop, 0, "rna_ImageUser_update");
230
373
 
231
374
        /* animation */
232
 
        prop= RNA_def_property(srna, "cyclic", PROP_BOOLEAN, PROP_NONE);
 
375
        prop = RNA_def_property(srna, "use_cyclic", PROP_BOOLEAN, PROP_NONE);
233
376
        RNA_def_property_boolean_sdna(prop, NULL, "cycl", 0);
234
377
        RNA_def_property_ui_text(prop, "Cyclic", "Cycle the images in the movie");
235
378
        RNA_def_property_update(prop, 0, "rna_ImageUser_update");
236
379
 
237
 
        prop= RNA_def_property(srna, "frames", PROP_INT, PROP_NONE);
 
380
        prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_NONE);
 
381
        RNA_def_property_int_sdna(prop, NULL, "frames");
238
382
        RNA_def_property_range(prop, 0, MAXFRAMEF);
239
 
        RNA_def_property_ui_text(prop, "Frames", "Sets the number of images of a movie to use");
240
 
        RNA_def_property_update(prop, 0, "rna_ImageUser_update");
241
 
 
242
 
        prop= RNA_def_property(srna, "offset", PROP_INT, PROP_NONE);
243
 
        RNA_def_property_range(prop, -MAXFRAMEF, MAXFRAMEF);
244
 
        RNA_def_property_ui_text(prop, "Offset", "Offsets the number of the frame to use in the animation");
245
 
        RNA_def_property_update(prop, 0, "rna_ImageUser_update");
246
 
 
247
 
        prop= RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
 
383
        RNA_def_property_ui_text(prop, "Frames", "Number of images of a movie to use");
 
384
        RNA_def_property_update(prop, 0, "rna_ImageUser_update");
 
385
 
 
386
        prop = RNA_def_property(srna, "frame_offset", PROP_INT, PROP_NONE);
 
387
        RNA_def_property_int_sdna(prop, NULL, "offset");
 
388
        RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
 
389
        RNA_def_property_ui_text(prop, "Offset", "Offset the number of the frame to use in the animation");
 
390
        RNA_def_property_update(prop, 0, "rna_ImageUser_update");
 
391
 
 
392
        prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
248
393
        RNA_def_property_int_sdna(prop, NULL, "sfra");
249
 
        RNA_def_property_range(prop, 1.0f, MAXFRAMEF);
250
 
        RNA_def_property_ui_text(prop, "Start Frame", "Sets the global starting frame of the movie");
 
394
        RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
 
395
        RNA_def_property_ui_text(prop, "Start Frame",
 
396
                                 "Global starting frame of the movie/sequence, assuming first picture has a #1");
251
397
        RNA_def_property_update(prop, 0, "rna_ImageUser_update");
252
398
 
253
 
        prop= RNA_def_property(srna, "fields_per_frame", PROP_INT, PROP_NONE);
 
399
        prop = RNA_def_property(srna, "fields_per_frame", PROP_INT, PROP_NONE);
254
400
        RNA_def_property_int_sdna(prop, NULL, "fie_ima");
255
 
        RNA_def_property_range(prop, -MAXFRAMEF, MAXFRAMEF);
256
 
        RNA_def_property_ui_text(prop, "Fields per Frame", "The number of fields per rendered frame (2 fields is 1 image)");
 
401
        RNA_def_property_range(prop, 1, 200);
 
402
        RNA_def_property_ui_text(prop, "Fields per Frame", "Number of fields per rendered frame (2 fields is 1 image)");
257
403
        RNA_def_property_update(prop, 0, "rna_ImageUser_update");
258
404
 
259
 
        prop= RNA_def_property(srna, "multilayer_layer", PROP_INT, PROP_UNSIGNED);
 
405
        prop = RNA_def_property(srna, "multilayer_layer", PROP_INT, PROP_UNSIGNED);
260
406
        RNA_def_property_int_sdna(prop, NULL, "layer");
261
407
        RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* image_multi_cb */
262
408
        RNA_def_property_ui_text(prop, "Layer", "Layer in multilayer image");
263
409
 
264
 
        prop= RNA_def_property(srna, "multilayer_pass", PROP_INT, PROP_UNSIGNED);
 
410
        prop = RNA_def_property(srna, "multilayer_pass", PROP_INT, PROP_UNSIGNED);
265
411
        RNA_def_property_int_sdna(prop, NULL, "pass");
266
412
        RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* image_multi_cb */
267
413
        RNA_def_property_ui_text(prop, "Pass", "Pass in multilayer image");
271
417
{
272
418
        StructRNA *srna;
273
419
        PropertyRNA *prop;
274
 
        static const EnumPropertyItem prop_type_items[]= {
 
420
        static const EnumPropertyItem prop_type_items[] = {
275
421
                {IMA_TYPE_IMAGE, "IMAGE", 0, "Image", ""},
276
422
                {IMA_TYPE_MULTILAYER, "MULTILAYER", 0, "Multilayer", ""},
277
423
                {IMA_TYPE_UV_TEST, "UV_TEST", 0, "UV Test", ""},
278
424
                {IMA_TYPE_R_RESULT, "RENDER_RESULT", 0, "Render Result", ""},
279
425
                {IMA_TYPE_COMPOSITE, "COMPOSITING", 0, "Compositing", ""},
280
426
                {0, NULL, 0, NULL, NULL}};
281
 
        static const EnumPropertyItem prop_generated_type_items[]= {
 
427
        static const EnumPropertyItem prop_generated_type_items[] = {
282
428
                {0, "BLANK", 0, "Blank", "Generate a blank image"},
283
429
                {1, "UV_GRID", 0, "UV Grid", "Generated grid to test UV mappings"},
284
430
                {2, "COLOR_GRID", 0, "Color Grid", "Generated improved UV grid to test UV mappings"},
285
431
                {0, NULL, 0, NULL, NULL}};
286
 
        static const EnumPropertyItem prop_mapping_items[]= {
 
432
        static const EnumPropertyItem prop_mapping_items[] = {
287
433
                {0, "UV", 0, "UV Coordinates", "Use UV coordinates for mapping the image"},
288
434
                {IMA_REFLECT, "REFLECTION", 0, "Reflection", "Use reflection mapping for mapping the image"},
289
435
                {0, NULL, 0, NULL, NULL}};
290
 
        static const EnumPropertyItem prop_field_order_items[]= {
 
436
        static const EnumPropertyItem prop_field_order_items[] = {
291
437
                {0, "EVEN", 0, "Upper First", "Upper field first"},
292
438
                {IMA_STD_FIELD, "ODD", 0, "Lower First", "Lower field first"},
293
439
                {0, NULL, 0, NULL, NULL}};
294
440
 
295
 
        srna= RNA_def_struct(brna, "Image", "ID");
 
441
        srna = RNA_def_struct(brna, "Image", "ID");
296
442
        RNA_def_struct_ui_text(srna, "Image", "Image datablock referencing an external or packed image");
297
443
        RNA_def_struct_ui_icon(srna, ICON_IMAGE_DATA);
298
444
 
299
 
        prop= RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
 
445
        prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
300
446
        RNA_def_property_string_sdna(prop, NULL, "name");
301
447
        RNA_def_property_ui_text(prop, "File Name", "Image/Movie file name");
302
448
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_reload_update");
303
449
 
304
450
        /* eek. this is horrible but needed so we can save to a new name without blanking the data :( */
305
 
        prop= RNA_def_property(srna, "filepath_raw", PROP_STRING, PROP_FILEPATH);
 
451
        prop = RNA_def_property(srna, "filepath_raw", PROP_STRING, PROP_FILEPATH);
306
452
        RNA_def_property_string_sdna(prop, NULL, "name");
307
453
        RNA_def_property_ui_text(prop, "File Name", "Image/Movie file name (without data refreshing)");
308
454
 
309
 
        prop= RNA_def_property(srna, "file_format", PROP_ENUM, PROP_NONE);
 
455
        prop = RNA_def_property(srna, "file_format", PROP_ENUM, PROP_NONE);
310
456
        RNA_def_property_enum_items(prop, image_type_items);
311
457
        RNA_def_property_enum_funcs(prop, "rna_Image_file_format_get", "rna_Image_file_format_set", NULL);
312
458
        RNA_def_property_ui_text(prop, "File Format", "Format used for re-saving this file");
313
459
 
314
 
        prop= RNA_def_property(srna, "source", PROP_ENUM, PROP_NONE);
 
460
        prop = RNA_def_property(srna, "source", PROP_ENUM, PROP_NONE);
315
461
        RNA_def_property_enum_items(prop, image_source_items);
316
462
        RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Image_source_itemf");
317
463
        RNA_def_property_ui_text(prop, "Source", "Where the image comes from");
318
464
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_source_update");
319
465
 
320
 
        prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
 
466
        prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
321
467
        RNA_def_property_enum_items(prop, prop_type_items);
322
468
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
323
469
        RNA_def_property_ui_text(prop, "Type", "How to generate the image");
324
470
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
325
471
 
326
 
        prop= RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
 
472
        prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
327
473
        RNA_def_property_pointer_sdna(prop, NULL, "packedfile");
328
474
        RNA_def_property_ui_text(prop, "Packed File", "");
329
475
        
330
 
        prop= RNA_def_property(srna, "field_order", PROP_ENUM, PROP_NONE);
 
476
        prop = RNA_def_property(srna, "field_order", PROP_ENUM, PROP_NONE);
331
477
        RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
332
478
        RNA_def_property_enum_items(prop, prop_field_order_items);
333
 
        RNA_def_property_ui_text(prop, "Field Order", "Order of video fields. Select which lines are displayed first");
 
479
        RNA_def_property_ui_text(prop, "Field Order", "Order of video fields (select which lines are displayed first)");
334
480
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
335
481
        
336
482
        /* booleans */
337
 
        prop= RNA_def_property(srna, "fields", PROP_BOOLEAN, PROP_NONE);
 
483
        prop = RNA_def_property(srna, "use_fields", PROP_BOOLEAN, PROP_NONE);
338
484
        RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_FIELDS);
339
485
        RNA_def_property_ui_text(prop, "Fields", "Use fields of the image");
340
486
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_fields_update");
341
487
 
342
 
        prop= RNA_def_property(srna, "premultiply", PROP_BOOLEAN, PROP_NONE);
 
488
        prop = RNA_def_property(srna, "use_premultiply", PROP_BOOLEAN, PROP_NONE);
343
489
        RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_DO_PREMUL);
344
490
        RNA_def_property_ui_text(prop, "Premultiply", "Convert RGB from key alpha to premultiplied alpha");
345
 
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_reload_update");
 
491
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_free_update");
 
492
        
 
493
        prop = RNA_def_property(srna, "use_color_unpremultiply", PROP_BOOLEAN, PROP_NONE);
 
494
        RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_CM_PREDIVIDE);
 
495
        RNA_def_property_ui_text(prop, "Color Unpremultiply",
 
496
                                 "For premultiplied alpha images, do color space conversion on colors without alpha, "
 
497
                                 "to avoid fringing for images with light backgrounds");
 
498
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_free_update");
346
499
 
347
 
        prop= RNA_def_property(srna, "dirty", PROP_BOOLEAN, PROP_NONE);
 
500
        prop = RNA_def_property(srna, "is_dirty", PROP_BOOLEAN, PROP_NONE);
348
501
        RNA_def_property_boolean_funcs(prop, "rna_Image_dirty_get", NULL);
349
502
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
350
503
        RNA_def_property_ui_text(prop, "Dirty", "Image has changed and is not saved");
351
504
 
352
505
        /* generated image (image_generated_change_cb) */
353
 
        prop= RNA_def_property(srna, "generated_type", PROP_ENUM, PROP_NONE);
 
506
        prop = RNA_def_property(srna, "generated_type", PROP_ENUM, PROP_NONE);
354
507
        RNA_def_property_enum_sdna(prop, NULL, "gen_type");
355
508
        RNA_def_property_enum_items(prop, prop_generated_type_items);
356
509
        RNA_def_property_ui_text(prop, "Generated Type", "Generated image type");
357
510
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_generated_update");
358
511
 
359
 
        prop= RNA_def_property(srna, "generated_width", PROP_INT, PROP_NONE);
 
512
        prop = RNA_def_property(srna, "generated_width", PROP_INT, PROP_NONE);
360
513
        RNA_def_property_int_sdna(prop, NULL, "gen_x");
361
514
        RNA_def_property_range(prop, 1, 16384);
362
515
        RNA_def_property_ui_text(prop, "Generated Width", "Generated image width");
363
516
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_generated_update");
364
517
 
365
 
        prop= RNA_def_property(srna, "generated_height", PROP_INT, PROP_NONE);
 
518
        prop = RNA_def_property(srna, "generated_height", PROP_INT, PROP_NONE);
366
519
        RNA_def_property_int_sdna(prop, NULL, "gen_y");
367
520
        RNA_def_property_range(prop, 1, 16384);
368
521
        RNA_def_property_ui_text(prop, "Generated Height", "Generated image height");
369
522
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_generated_update");
370
523
 
 
524
        prop = RNA_def_property(srna, "use_generated_float", PROP_BOOLEAN, PROP_NONE);
 
525
        RNA_def_property_boolean_sdna(prop, NULL, "gen_flag", IMA_GEN_FLOAT);
 
526
        RNA_def_property_ui_text(prop, "Float Buffer", "Generate floating point buffer");
 
527
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_generated_update");
 
528
 
371
529
        /* realtime properties */
372
 
        prop= RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE);
 
530
        prop = RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE);
373
531
        RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
374
532
        RNA_def_property_enum_items(prop, prop_mapping_items);
375
533
        RNA_def_property_ui_text(prop, "Mapping", "Mapping type to use for this image in the game engine");
376
534
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
377
535
 
378
 
        prop= RNA_def_property(srna, "display_aspect", PROP_FLOAT, PROP_XYZ);
 
536
        prop = RNA_def_property(srna, "display_aspect", PROP_FLOAT, PROP_XYZ);
379
537
        RNA_def_property_float_sdna(prop, NULL, "aspx");
380
538
        RNA_def_property_array(prop, 2);
381
539
        RNA_def_property_range(prop, 0.1f, 5000.0f);
382
540
        RNA_def_property_ui_text(prop, "Display Aspect", "Display Aspect for this image, does not affect rendering");
383
541
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
384
542
 
385
 
        prop= RNA_def_property(srna, "animated", PROP_BOOLEAN, PROP_NONE);
 
543
        prop = RNA_def_property(srna, "use_animation", PROP_BOOLEAN, PROP_NONE);
386
544
        RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_TWINANIM);
387
545
        RNA_def_property_ui_text(prop, "Animated", "Use as animated texture in the game engine");
388
546
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_animated_update");
389
547
 
390
 
        prop= RNA_def_property(srna, "animation_start", PROP_INT, PROP_NONE);
 
548
        prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_NONE);
391
549
        RNA_def_property_int_sdna(prop, NULL, "twsta");
392
550
        RNA_def_property_range(prop, 0, 128);
393
551
        RNA_def_property_ui_text(prop, "Animation Start", "Start frame of an animated texture");
394
552
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_animated_update");
395
553
 
396
 
        prop= RNA_def_property(srna, "animation_end", PROP_INT, PROP_NONE);
 
554
        prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_NONE);
397
555
        RNA_def_property_int_sdna(prop, NULL, "twend");
398
556
        RNA_def_property_range(prop, 0, 128);
399
557
        RNA_def_property_ui_text(prop, "Animation End", "End frame of an animated texture");
400
558
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_animated_update");
401
559
 
402
 
        prop= RNA_def_property(srna, "animation_speed", PROP_INT, PROP_NONE);
 
560
        prop = RNA_def_property(srna, "fps", PROP_INT, PROP_NONE);
403
561
        RNA_def_property_int_sdna(prop, NULL, "animspeed");
404
562
        RNA_def_property_range(prop, 1, 100);
405
563
        RNA_def_property_ui_text(prop, "Animation Speed", "Speed of the animation in frames per second");
406
564
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
407
565
 
408
 
        prop= RNA_def_property(srna, "tiles", PROP_BOOLEAN, PROP_NONE);
 
566
        prop = RNA_def_property(srna, "use_tiles", PROP_BOOLEAN, PROP_NONE);
409
567
        RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_TILES);
410
 
        RNA_def_property_ui_text(prop, "Tiles", "Use of tilemode for faces (default shift-LMB to pick the tile for selected faces)");
 
568
        RNA_def_property_ui_text(prop, "Tiles",
 
569
                                 "Use of tilemode for faces (default shift-LMB to pick the tile for selected faces)");
411
570
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
412
571
 
413
 
        prop= RNA_def_property(srna, "tiles_x", PROP_INT, PROP_NONE);
 
572
        prop = RNA_def_property(srna, "tiles_x", PROP_INT, PROP_NONE);
414
573
        RNA_def_property_int_sdna(prop, NULL, "xrep");
415
574
        RNA_def_property_range(prop, 1, 16);
416
575
        RNA_def_property_ui_text(prop, "Tiles X", "Degree of repetition in the X direction");
417
576
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
418
577
 
419
 
        prop= RNA_def_property(srna, "tiles_y", PROP_INT, PROP_NONE);
 
578
        prop = RNA_def_property(srna, "tiles_y", PROP_INT, PROP_NONE);
420
579
        RNA_def_property_int_sdna(prop, NULL, "yrep");
421
580
        RNA_def_property_range(prop, 1, 16);
422
581
        RNA_def_property_ui_text(prop, "Tiles Y", "Degree of repetition in the Y direction");
423
582
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
424
583
 
425
 
        prop= RNA_def_property(srna, "clamp_x", PROP_BOOLEAN, PROP_NONE);
 
584
        prop = RNA_def_property(srna, "use_clamp_x", PROP_BOOLEAN, PROP_NONE);
426
585
        RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_CLAMP_U);
427
586
        RNA_def_property_ui_text(prop, "Clamp X", "Disable texture repeating horizontally");
428
587
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
429
588
 
430
 
        prop= RNA_def_property(srna, "clamp_y", PROP_BOOLEAN, PROP_NONE);
 
589
        prop = RNA_def_property(srna, "use_clamp_y", PROP_BOOLEAN, PROP_NONE);
431
590
        RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_CLAMP_V);
432
591
        RNA_def_property_ui_text(prop, "Clamp Y", "Disable texture repeating vertically");
433
592
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
434
593
 
435
 
        prop= RNA_def_property(srna, "bindcode", PROP_INT, PROP_UNSIGNED);
 
594
        prop = RNA_def_property(srna, "bindcode", PROP_INT, PROP_UNSIGNED);
436
595
        RNA_def_property_int_sdna(prop, NULL, "bindcode");
437
596
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
438
597
        RNA_def_property_ui_text(prop, "Bindcode", "OpenGL bindcode");
439
598
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
440
599
 
 
600
        prop = RNA_def_property(srna, "render_slot", PROP_INT, PROP_UNSIGNED);
 
601
        RNA_def_property_range(prop, 0, IMA_MAX_RENDER_SLOT - 1);
 
602
        RNA_def_property_ui_text(prop, "Render Slot", "The current render slot displayed, only for viewer type images");
 
603
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);
 
604
 
441
605
        /*
442
 
           Image.has_data and Image.depth are temporary,
443
 
           Update import_obj.py when they are replaced (Arystan)
444
 
        */
445
 
        prop= RNA_def_property(srna, "has_data", PROP_BOOLEAN, PROP_NONE);
 
606
         * Image.has_data and Image.depth are temporary,
 
607
         * Update import_obj.py when they are replaced (Arystan)
 
608
         */
 
609
        prop = RNA_def_property(srna, "has_data", PROP_BOOLEAN, PROP_NONE);
446
610
        RNA_def_property_boolean_funcs(prop, "rna_Image_has_data_get", NULL);
447
611
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
448
612
        RNA_def_property_ui_text(prop, "Has data", "True if this image has data");
449
613
 
450
 
        prop= RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED);
 
614
        prop = RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED);
451
615
        RNA_def_property_int_funcs(prop, "rna_Image_depth_get", NULL, NULL);
452
616
        RNA_def_property_ui_text(prop, "Depth", "Image bit depth");
453
617
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
454
618
 
455
 
        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);
 
619
        prop = RNA_def_int_vector(srna, "size" , 2 , NULL , 0, 0, "Size" ,
 
620
                                  "Width and height in pixels, zero when image data cant be loaded" , 0 , 0);
456
621
        RNA_def_property_int_funcs(prop, "rna_Image_size_get" , NULL, NULL);
457
622
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
458
623
 
 
624
        prop = RNA_def_float_vector(srna, "resolution" , 2 , NULL , 0, 0, "Resolution" , "X/Y pixels per meter" , 0 , 0);
 
625
        RNA_def_property_float_funcs(prop, "rna_Image_resolution_get" , "rna_Image_resolution_set", NULL);
 
626
 
 
627
        prop = RNA_def_property(srna, "pixels", PROP_FLOAT, PROP_NONE);
 
628
        RNA_def_property_flag(prop, PROP_DYNAMIC);
 
629
        RNA_def_property_multi_array(prop, 1, NULL);
 
630
        RNA_def_property_ui_text(prop, "Pixels", "Image pixels in floating point values");
 
631
        RNA_def_property_dynamic_array_funcs(prop, "rna_Image_pixels_get_length");
 
632
        RNA_def_property_float_funcs(prop, "rna_Image_pixels_get", "rna_Image_pixels_set", NULL);
 
633
 
459
634
        RNA_api_image(srna);
460
635
}
461
636
 
466
641
}
467
642
 
468
643
#endif
469