~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to source/blender/blenkernel/intern/image.c

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2007-05-17 11:47:59 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070517114759-yp4ybrnhp2u7pk66
Tags: 2.44-1
* New upstream release.
* Drop debian/patches/01_64bits_stupidity, not needed anymore: as of this
  version blender is 64 bits safe again. Adjust README.Debian accordingly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*  image.c        
2
2
 * 
3
 
 * $Id: image.c,v 1.59 2007/02/10 16:59:20 blendix Exp $
 
3
 * $Id: image.c,v 1.62 2007/05/03 15:10:43 bebraw Exp $
4
4
 *
5
5
 * ***** BEGIN GPL LICENSE BLOCK *****
6
6
 *
318
318
        const char *libname;
319
319
        char str[FILE_MAX], strtest[FILE_MAX];
320
320
        
 
321
        /* escape when name is directory */
 
322
        len= strlen(name);
 
323
        if(len) {
 
324
                if(name[len-1]=='/' || name[len-1]=='\\')
 
325
                        return NULL;
 
326
        }
 
327
        
321
328
        BLI_strncpy(str, name, sizeof(str));
322
329
        BLI_convertstringcode(str, G.sce, G.scene->r.cfra);
323
330
        
 
331
        /* exists? */
324
332
        file= open(str, O_BINARY|O_RDONLY);
325
 
        if(file== -1) return 0;
 
333
        if(file== -1) return NULL;
326
334
        close(file);
327
335
        
328
336
        /* first search an identical image */
362
370
        return ima;
363
371
}
364
372
 
365
 
static ImBuf *add_ibuf_size(int width, int height, char *name, short uvtestgrid)
 
373
static ImBuf *add_ibuf_size(int width, int height, char *name, short uvtestgrid, float color[4])
366
374
{
367
375
        ImBuf *ibuf;
368
376
        float h=0.0, hoffs=0.0, hue=0.0, s=0.9, v=0.9, r, g, b;
397
405
                        }
398
406
                }
399
407
                
400
 
                /* 2nd pass, coloured + */
 
408
                /* 2nd pass, colored + */
401
409
                rect= (unsigned char*)ibuf->rect;
402
410
                
403
411
                for(y=0; y<ibuf->y; y++) {
427
435
        } else {        /* blank image */
428
436
                for(y=0; y<ibuf->y; y++) {
429
437
                        for(x=0; x<ibuf->x; x++, rect+=4) {
430
 
                                rect[0]= rect[1]= rect[2]= 0;
431
 
                                rect[3]= 255;
 
438
                                rect[0]= (char)(color[0] * 255.0);
 
439
                                rect[1]= (char)(color[1] * 255.0);
 
440
                                rect[2]= (char)(color[2] * 255.0);
 
441
                                rect[3]= (char)(color[3] * 255.0);
432
442
                        }
433
443
                }
434
444
        }
436
446
}
437
447
 
438
448
/* adds new image block, creates ImBuf and initializes color */
439
 
Image *BKE_add_image_size(int width, int height, char *name, short uvtestgrid)
 
449
Image *BKE_add_image_size(int width, int height, char *name, short uvtestgrid, float color[4])
440
450
{
441
451
        Image *ima;
442
452
        
451
461
                ima->gen_y= height;
452
462
                ima->gen_type= uvtestgrid;
453
463
                
454
 
                ibuf= add_ibuf_size(width, height, name, uvtestgrid);
 
464
                ibuf= add_ibuf_size(width, height, name, uvtestgrid, color);
455
465
                image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
456
466
                
457
467
                ima->ok= IMA_OK_LOADED;
1362
1372
ImBuf *BKE_image_get_ibuf(Image *ima, ImageUser *iuser)
1363
1373
{
1364
1374
        ImBuf *ibuf= NULL;
 
1375
        float color[] = {0, 0, 0, 1};
1365
1376
 
1366
1377
        /* quick reject tests */
1367
1378
        if(ima==NULL) 
1439
1450
                                /* UV testgrid or black or solid etc */
1440
1451
                                if(ima->gen_x==0) ima->gen_x= 256;
1441
1452
                                if(ima->gen_y==0) ima->gen_y= 256;
1442
 
                                ibuf= add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, ima->gen_type);
 
1453
                                ibuf= add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, ima->gen_type, color);
1443
1454
                                image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
1444
1455
                                ima->ok= IMA_OK_LOADED;
1445
1456
                        }