diff options
author | Ton Roosendaal <ton@blender.org> | 2006-07-09 17:00:41 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2006-07-09 17:00:41 +0400 |
commit | 1ce6c22f2700b2473f5ad8e0c79ff5802fb65a62 (patch) | |
tree | fa4c18e789a0cc7746c5eb03c73c78c82ca9bd98 /source | |
parent | cf313f867d3e457ac9da21c001202650d4a8e2ce (diff) |
Bugfix #4649
Three issues:
- When saving a file, without extension added, and no filename provided,
the saving code received the directory name only. That's a potential
danger of getting directories deleted.
Added in the saveover() function a check for this, and return an error
when you try to save over a directory.
- Screendump did not add file extensions yet, when indicated todo so.
- Screendump code was duplicating all image type cases, whilst we have a
nice BKE_write_ibuf() call for that now. (Bug was that this code did not
check for BMP, saving the file in default format.)
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/src/screendump.c | 34 | ||||
-rw-r--r-- | source/blender/src/toolbox.c | 15 |
2 files changed, 23 insertions, 26 deletions
diff --git a/source/blender/src/screendump.c b/source/blender/src/screendump.c index 2b40d8e7171..4c1cda52da3 100644 --- a/source/blender/src/screendump.c +++ b/source/blender/src/screendump.c @@ -46,6 +46,7 @@ #include "BKE_utildefines.h" #include "BKE_global.h" +#include "BKE_image.h" #include "BKE_material.h" #include "BKE_sca.h" @@ -64,8 +65,6 @@ static unsigned int *dumprect=0; static int dumpsx, dumpsy; -void write_screendump(char *name); - void write_screendump(char *name) { ImBuf *ibuf; @@ -75,42 +74,27 @@ void write_screendump(char *name) strcpy(G.ima, name); BLI_convertstringcode(name, G.sce, G.scene->r.cfra); + /* BKE_add_image_extension() checks for if extension was already set */ + if(G.scene->r.scemode & R_EXTENSION) + if(strlen(name)<FILE_MAXDIR+FILE_MAXFILE-5) + BKE_add_image_extension(name, G.scene->r.imtype); + if(saveover(name)) { waitcursor(1); ibuf= IMB_allocImBuf(dumpsx, dumpsy, 24, 0, 0); ibuf->rect= dumprect; - if(G.scene->r.imtype== R_IRIS) ibuf->ftype= IMAGIC; - else if(G.scene->r.imtype==R_IRIZ) ibuf->ftype= IMAGIC; - else if(G.scene->r.imtype==R_TARGA) ibuf->ftype= TGA; - else if(G.scene->r.imtype==R_RAWTGA) ibuf->ftype= RAWTGA; - else if(G.scene->r.imtype==R_PNG) ibuf->ftype= PNG; - else if((G.have_libtiff) && - (G.scene->r.imtype==R_TIFF)) ibuf->ftype= TIF; -#ifdef WITH_OPENEXR - else if(G.scene->r.imtype==R_OPENEXR) { - ibuf->ftype= OPENEXR; - if(G.scene->r.subimtype & R_OPENEXR_HALF) - ibuf->ftype |= OPENEXR_HALF; - ibuf->ftype |= (G.scene->r.quality & OPENEXR_COMPRESS); - } -#endif - else if(G.scene->r.imtype==R_HAMX) ibuf->ftype= AN_hamx; - else if(ELEM5(G.scene->r.imtype, R_MOVIE, R_AVICODEC, R_AVIRAW, R_AVIJPEG, R_JPEG90)) { - ibuf->ftype= JPG|G.scene->r.quality; - } - else ibuf->ftype= TGA; - if(G.scene->r.planes == 8) IMB_cspace(ibuf, rgb_to_bw); - IMB_saveiff(ibuf, name, IB_rect); + BKE_write_ibuf(ibuf, name, G.scene->r.imtype, G.scene->r.subimtype, G.scene->r.quality); + IMB_freeImBuf(ibuf); waitcursor(0); } MEM_freeN(dumprect); - dumprect= 0; + dumprect= NULL; } } diff --git a/source/blender/src/toolbox.c b/source/blender/src/toolbox.c index 1313dfc4a45..218252704e4 100644 --- a/source/blender/src/toolbox.c +++ b/source/blender/src/toolbox.c @@ -232,7 +232,20 @@ void error(char *fmt, ...) int saveover(char *file) { - return (!BLI_exists(file) || confirm("Save over", file)); + int len= strlen(file); + + if(len==0) + return 0; + + if(BLI_exists(file)==0) + return 1; + + if( file[len-1]=='/' || file[len-1]=='\\' ) { + error("Cannot overwrite a directory"); + return 0; + } + + return confirm("Save over", file); } /* ****************** EXTRA STUFF **************** */ |