[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14315] trunk/blender/source/blender/src/ editnode.c:
Brecht Van Lommel
brechtvanlommel at pandora.be
Wed Apr 2 14:03:32 CEST 2008
Revision: 14315
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14315
Author: blendix
Date: 2008-04-02 14:03:31 +0200 (Wed, 02 Apr 2008)
Log Message:
-----------
Small last-minute peach feature: loading an image into the image node
now automatically detects if a sequence of images is selected, and sets
the frames and image type to sequence.
Modified Paths:
--------------
trunk/blender/source/blender/src/editnode.c
Modified: trunk/blender/source/blender/src/editnode.c
===================================================================
--- trunk/blender/source/blender/src/editnode.c 2008-04-02 04:31:41 UTC (rev 14314)
+++ trunk/blender/source/blender/src/editnode.c 2008-04-02 12:03:31 UTC (rev 14315)
@@ -67,6 +67,7 @@
#include "BIF_resources.h"
#include "BIF_renderwin.h"
#include "BIF_space.h"
+#include "BIF_scrarea.h"
#include "BIF_screen.h"
#include "BIF_toolbox.h"
@@ -76,8 +77,9 @@
#include "BSE_headerbuttons.h"
#include "BSE_node.h"
+#include "BLI_arithb.h"
#include "BLI_blenlib.h"
-#include "BLI_arithb.h"
+#include "BLI_storage_types.h"
#include "BDR_editobject.h"
@@ -188,11 +190,82 @@
}
}
+static int image_detect_file_sequence(int *start_p, int *frames_p, char *str)
+{
+ SpaceFile *sfile;
+ char name[FILE_MAX], head[FILE_MAX], tail[FILE_MAX], filename[FILE_MAX];
+ int a, frame, totframe, found, minframe;
+ unsigned short numlen;
+
+ sfile= scrarea_find_space_of_type(curarea, SPACE_FILE);
+ if(sfile==0)
+ return 0;
+
+ /* find first frame */
+ found= 0;
+ minframe= 0;
+
+ for(a=0; a<sfile->totfile; a++) {
+ if(sfile->filelist[a].flags & ACTIVE) {
+ BLI_strncpy(name, sfile->filelist[a].relname, sizeof(name));
+ frame= BLI_stringdec(name, head, tail, &numlen);
+
+ if(!found || frame < minframe) {
+ BLI_strncpy(filename, name, sizeof(name));
+ minframe= frame;
+ found= 1;
+ }
+ }
+ }
+
+ /* not one frame found */
+ if(!found)
+ return 0;
+
+ /* counter number of following frames */
+ found= 1;
+ totframe= 0;
+
+ for(frame=minframe; found; frame++) {
+ found= 0;
+ BLI_strncpy(name, filename, sizeof(name));
+ BLI_stringenc(name, head, tail, numlen, frame);
+
+ for(a=0; a<sfile->totfile; a++) {
+ if(sfile->filelist[a].flags & ACTIVE) {
+ if(strcmp(sfile->filelist[a].relname, name) == 0) {
+ found= 1;
+ totframe++;
+ break;
+ }
+ }
+ }
+ }
+
+ if(totframe > 1) {
+ BLI_strncpy(str, sfile->dir, sizeof(name));
+ strcat(str, filename);
+
+ *start_p= minframe;
+ *frames_p= totframe;
+ return 1;
+ }
+
+ return 0;
+}
+
static void load_node_image(char *str) /* called from fileselect */
{
SpaceNode *snode= curarea->spacedata.first;
bNode *node= nodeGetActive(snode->edittree);
Image *ima= NULL;
+ ImageUser *iuser= node->storage;
+ char filename[FILE_MAX];
+ int start=0, frames=0, sequence;
+
+ sequence= image_detect_file_sequence(&start, &frames, filename);
+ if(sequence)
+ str= filename;
ima= BKE_add_image_file(str);
if(ima) {
@@ -203,6 +276,12 @@
id_us_plus(node->id);
BLI_strncpy(node->name, node->id->name+2, 21);
+
+ if(sequence) {
+ ima->source= IMA_SRC_SEQUENCE;
+ iuser->frames= frames;
+ iuser->offset= start-1;
+ }
BKE_image_signal(ima, node->storage, IMA_SIGNAL_RELOAD);
More information about the Bf-blender-cvs
mailing list