bugfix [#22859] Multi-user images cant be made into single user in texure panel.
authorCampbell Barton <ideasman42@gmail.com>
Fri, 30 Jul 2010 06:09:23 +0000 (06:09 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 30 Jul 2010 06:09:23 +0000 (06:09 +0000)
turns out this isnt exactly a bug since support was never written for this but may as well support it.
now rna/py can do image.copy() too.

source/blender/blenkernel/BKE_image.h
source/blender/blenkernel/intern/deform.c
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/node.c
source/blender/makesdna/DNA_image_types.h

index d7eb5fe824675143afea05e40c3ad494176632bd..c842efaa3b2440f143f0e47de2477e5d7bf617d9 100644 (file)
@@ -159,7 +159,7 @@ void BKE_image_memorypack(struct Image *ima);
 void BKE_image_print_memlist(void);
 
 /* empty image block, of similar type and filename */
-struct Image *BKE_image_copy(struct Image *ima);
+struct Image *copy_image(struct Image *ima);
 
 /* merge source into dest, and free source */
 void BKE_image_merge(struct Image *dest, struct Image *source);
index ccb6ebe1f1eb22c9b1e954be0bab731092edb149..5f262c526c3f199ebd4146e6a7baf99ce0366076 100644 (file)
@@ -471,6 +471,7 @@ void flip_side_name (char *name, const char *from_name, int strip_number)
 #undef IS_SEPARATOR
 
        sprintf (name, "%s%s%s%s", prefix, replace, suffix, number);
+       printf("'%s' --> '%s'\n", from_name, name);
 }
 
 float defvert_find_weight(const struct MDeformVert *dvert, int group_num)
index ffd0b378f078bf06e69725c4403923856050788a..77607ae25b6ad55fadad433368c6674cf54d2d26 100644 (file)
@@ -287,17 +287,25 @@ static void image_assign_ibuf(Image *ima, ImBuf *ibuf, int index, int frame)
 }
 
 /* empty image block, of similar type and filename */
-Image *BKE_image_copy(Image *ima)
+Image *copy_image(Image *ima)
 {
-       Image *new= image_alloc(ima->id.name+2, ima->source, ima->type);
+       Image *nima= image_alloc(ima->id.name+2, ima->source, ima->type);
 
-       BLI_strncpy(new->name, ima->name, sizeof(ima->name));
-       
-       new->gen_x= ima->gen_x;
-       new->gen_y= ima->gen_y;
-       new->gen_type= ima->gen_type;
+       BLI_strncpy(nima->name, ima->name, sizeof(ima->name));
+
+       nima->flag= ima->flag;
+       nima->tpageflag= ima->tpageflag;
        
-       return new;
+       nima->gen_x= ima->gen_x;
+       nima->gen_y= ima->gen_y;
+       nima->gen_type= ima->gen_type;
+
+       nima->animspeed= ima->animspeed;
+
+       nima->aspx= ima->aspx;
+       nima->aspy= ima->aspy;
+
+       return nima;
 }
 
 void BKE_image_merge(Image *dest, Image *source)
index acfaef9eb88a41d0b3215431c19dc670ee806568..716a0b7d41b3aff78007ad36e974420233ff79ce 100644 (file)
@@ -262,7 +262,8 @@ int id_copy(ID *id, ID **newid, int test)
                        if(!test) *newid= (ID*)copy_texture((Tex*)id);
                        return 1;
                case ID_IM:
-                       return 0; /* not implemented */
+                       if(!test) *newid= (ID*)copy_image((Image*)id);
+                       return 1;
                case ID_WV:
                        return 0; /* deprecated */
                case ID_LT:
index add011d0950445cd912bba2fd36a107765500abd..ff1887b0883193b9a604fb88c9ea00974568d242 100644 (file)
@@ -2565,7 +2565,7 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree)
                if(ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
                        if(node->id) {
                                if(node->flag & NODE_DO_OUTPUT)
-                                       node->new_node->id= (ID *)BKE_image_copy((Image *)node->id);
+                                       node->new_node->id= (ID *)copy_image((Image *)node->id);
                                else
                                        node->new_node->id= NULL;
                        }
index 1695ceb73a5faf64334bd09d4ba211bf4203bef7..d1aa3c00ac430a37d58940932730e96ac2d68a13 100644 (file)
@@ -105,7 +105,7 @@ typedef struct Image {
 
 /* **************** IMAGE ********************* */
 
-/* flag */
+/* Image.flag */
 #define IMA_FIELDS             1
 #define IMA_STD_FIELD  2
 #define IMA_DO_PREMUL  4
@@ -115,7 +115,7 @@ typedef struct Image {
 #define IMA_DEPRECATED 64
 #define IMA_OLD_PREMUL 128
 
-/* tpageflag */
+/* Image.tpageflag */
 #define IMA_TILES                      1
 #define IMA_TWINANIM           2
 #define IMA_COLCYCLE           4       /* Depreciated */