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.)
This commit is contained in:
@@ -46,6 +46,7 @@
|
|||||||
|
|
||||||
#include "BKE_utildefines.h"
|
#include "BKE_utildefines.h"
|
||||||
#include "BKE_global.h"
|
#include "BKE_global.h"
|
||||||
|
#include "BKE_image.h"
|
||||||
#include "BKE_material.h"
|
#include "BKE_material.h"
|
||||||
#include "BKE_sca.h"
|
#include "BKE_sca.h"
|
||||||
|
|
||||||
@@ -64,8 +65,6 @@
|
|||||||
static unsigned int *dumprect=0;
|
static unsigned int *dumprect=0;
|
||||||
static int dumpsx, dumpsy;
|
static int dumpsx, dumpsy;
|
||||||
|
|
||||||
void write_screendump(char *name);
|
|
||||||
|
|
||||||
void write_screendump(char *name)
|
void write_screendump(char *name)
|
||||||
{
|
{
|
||||||
ImBuf *ibuf;
|
ImBuf *ibuf;
|
||||||
@@ -75,42 +74,27 @@ void write_screendump(char *name)
|
|||||||
strcpy(G.ima, name);
|
strcpy(G.ima, name);
|
||||||
BLI_convertstringcode(name, G.sce, G.scene->r.cfra);
|
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)) {
|
if(saveover(name)) {
|
||||||
waitcursor(1);
|
waitcursor(1);
|
||||||
|
|
||||||
ibuf= IMB_allocImBuf(dumpsx, dumpsy, 24, 0, 0);
|
ibuf= IMB_allocImBuf(dumpsx, dumpsy, 24, 0, 0);
|
||||||
ibuf->rect= dumprect;
|
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);
|
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);
|
IMB_freeImBuf(ibuf);
|
||||||
|
|
||||||
waitcursor(0);
|
waitcursor(0);
|
||||||
}
|
}
|
||||||
MEM_freeN(dumprect);
|
MEM_freeN(dumprect);
|
||||||
dumprect= 0;
|
dumprect= NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -232,7 +232,20 @@ void error(char *fmt, ...)
|
|||||||
|
|
||||||
int saveover(char *file)
|
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 **************** */
|
/* ****************** EXTRA STUFF **************** */
|
||||||
|
|||||||
Reference in New Issue
Block a user