[Bf-blender-cvs] [a5f8071bdf7] master: Cleanup: use bool for imbuf save callbacks
Campbell Barton
noreply at git.blender.org
Wed Nov 11 06:14:50 CET 2020
Commit: a5f8071bdf7893ef487c677b460793e8bef55402
Author: Campbell Barton
Date: Wed Nov 11 16:14:05 2020 +1100
Branches: master
https://developer.blender.org/rBa5f8071bdf7893ef487c677b460793e8bef55402
Cleanup: use bool for imbuf save callbacks
===================================================================
M source/blender/blenkernel/intern/image.c
M source/blender/imbuf/IMB_imbuf.h
M source/blender/imbuf/intern/IMB_filetype.h
M source/blender/imbuf/intern/bmp.c
M source/blender/imbuf/intern/cineon/cineon_dpx.c
M source/blender/imbuf/intern/dds/dds_api.cpp
M source/blender/imbuf/intern/dds/dds_api.h
M source/blender/imbuf/intern/iris.c
M source/blender/imbuf/intern/jp2.c
M source/blender/imbuf/intern/jpeg.c
M source/blender/imbuf/intern/openexr/openexr_api.cpp
M source/blender/imbuf/intern/openexr/openexr_api.h
M source/blender/imbuf/intern/png.c
M source/blender/imbuf/intern/radiance_hdr.c
M source/blender/imbuf/intern/targa.c
M source/blender/imbuf/intern/tiff.c
M source/blender/imbuf/intern/writeimage.c
M source/blender/sequencer/intern/proxy.c
===================================================================
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index f87b1b5ff45..9010c846954 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -2953,13 +2953,11 @@ void BKE_imbuf_write_prepare(ImBuf *ibuf, const ImageFormatData *imf)
int BKE_imbuf_write(ImBuf *ibuf, const char *name, const ImageFormatData *imf)
{
- int ok;
-
BKE_imbuf_write_prepare(ibuf, imf);
BLI_make_existing_file(name);
- ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat);
+ const bool ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat);
if (ok == 0) {
perror(name);
}
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index 0f9aa7055e7..bb28c4b1234 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -466,7 +466,7 @@ void IMB_scaleImBuf_threaded(struct ImBuf *ibuf, unsigned int newx, unsigned int
*
* \attention Defined in writeimage.c
*/
-short IMB_saveiff(struct ImBuf *ibuf, const char *filepath, int flags);
+bool IMB_saveiff(struct ImBuf *ibuf, const char *filepath, int flags);
bool IMB_prepare_write_ImBuf(const bool isfloat, struct ImBuf *ibuf);
/**
diff --git a/source/blender/imbuf/intern/IMB_filetype.h b/source/blender/imbuf/intern/IMB_filetype.h
index b7763976853..520e810fe32 100644
--- a/source/blender/imbuf/intern/IMB_filetype.h
+++ b/source/blender/imbuf/intern/IMB_filetype.h
@@ -39,7 +39,7 @@ typedef struct ImFileType {
int flags,
char colorspace[IM_MAX_SPACE]);
struct ImBuf *(*load_filepath)(const char *filepath, int flags, char colorspace[IM_MAX_SPACE]);
- int (*save)(struct ImBuf *ibuf, const char *filepath, int flags);
+ bool (*save)(struct ImBuf *ibuf, const char *filepath, int flags);
void (*load_tile)(struct ImBuf *ibuf,
const unsigned char *mem,
size_t size,
@@ -72,7 +72,7 @@ struct ImBuf *imb_loadpng(const unsigned char *mem,
size_t size,
int flags,
char colorspace[IM_MAX_SPACE]);
-int imb_savepng(struct ImBuf *ibuf, const char *filepath, int flags);
+bool imb_savepng(struct ImBuf *ibuf, const char *filepath, int flags);
/* targa */
int imb_is_a_targa(const unsigned char *buf);
@@ -80,7 +80,7 @@ struct ImBuf *imb_loadtarga(const unsigned char *mem,
size_t size,
int flags,
char colorspace[IM_MAX_SPACE]);
-int imb_savetarga(struct ImBuf *ibuf, const char *filepath, int flags);
+bool imb_savetarga(struct ImBuf *ibuf, const char *filepath, int flags);
/* iris */
int imb_is_a_iris(const unsigned char *mem);
@@ -88,7 +88,7 @@ struct ImBuf *imb_loadiris(const unsigned char *mem,
size_t size,
int flags,
char colorspace[IM_MAX_SPACE]);
-int imb_saveiris(struct ImBuf *ibuf, const char *filepath, int flags);
+bool imb_saveiris(struct ImBuf *ibuf, const char *filepath, int flags);
/* jp2 */
int imb_is_a_jp2(const unsigned char *buf);
@@ -99,11 +99,11 @@ struct ImBuf *imb_load_jp2(const unsigned char *mem,
struct ImBuf *imb_load_jp2_filepath(const char *filepath,
int flags,
char colorspace[IM_MAX_SPACE]);
-int imb_save_jp2(struct ImBuf *ibuf, const char *filepath, int flags);
+bool imb_save_jp2(struct ImBuf *ibuf, const char *filepath, int flags);
/* jpeg */
int imb_is_a_jpeg(const unsigned char *mem);
-int imb_savejpeg(struct ImBuf *ibuf, const char *filepath, int flags);
+bool imb_savejpeg(struct ImBuf *ibuf, const char *filepath, int flags);
struct ImBuf *imb_load_jpeg(const unsigned char *buffer,
size_t size,
int flags,
@@ -115,11 +115,11 @@ struct ImBuf *imb_bmp_decode(const unsigned char *mem,
size_t size,
int flags,
char colorspace[IM_MAX_SPACE]);
-int imb_savebmp(struct ImBuf *ibuf, const char *filepath, int flags);
+bool imb_savebmp(struct ImBuf *ibuf, const char *filepath, int flags);
/* cineon */
int imb_is_a_cineon(const unsigned char *buf);
-int imb_save_cineon(struct ImBuf *buf, const char *filepath, int flags);
+bool imb_save_cineon(struct ImBuf *buf, const char *filepath, int flags);
struct ImBuf *imb_load_cineon(const unsigned char *mem,
size_t size,
int flags,
@@ -127,7 +127,7 @@ struct ImBuf *imb_load_cineon(const unsigned char *mem,
/* dpx */
int imb_is_a_dpx(const unsigned char *buf);
-int imb_save_dpx(struct ImBuf *buf, const char *filepath, int flags);
+bool imb_save_dpx(struct ImBuf *buf, const char *filepath, int flags);
struct ImBuf *imb_load_dpx(const unsigned char *mem,
size_t size,
int flags,
@@ -139,7 +139,7 @@ struct ImBuf *imb_loadhdr(const unsigned char *mem,
size_t size,
int flags,
char colorspace[IM_MAX_SPACE]);
-int imb_savehdr(struct ImBuf *ibuf, const char *filepath, int flags);
+bool imb_savehdr(struct ImBuf *ibuf, const char *filepath, int flags);
/* tiff */
void imb_inittiff(void);
@@ -150,4 +150,4 @@ struct ImBuf *imb_loadtiff(const unsigned char *mem,
char colorspace[IM_MAX_SPACE]);
void imb_loadtiletiff(
struct ImBuf *ibuf, const unsigned char *mem, size_t size, int tx, int ty, unsigned int *rect);
-int imb_savetiff(struct ImBuf *ibuf, const char *filepath, int flags);
+bool imb_savetiff(struct ImBuf *ibuf, const char *filepath, int flags);
diff --git a/source/blender/imbuf/intern/bmp.c b/source/blender/imbuf/intern/bmp.c
index f7fdc7a8e80..6d1726af608 100644
--- a/source/blender/imbuf/intern/bmp.c
+++ b/source/blender/imbuf/intern/bmp.c
@@ -292,7 +292,7 @@ static int putShortLSB(ushort us, FILE *ofile)
}
/* Found write info at http://users.ece.gatech.edu/~slabaugh/personal/c/bitmapUnix.c */
-int imb_savebmp(ImBuf *ibuf, const char *filepath, int UNUSED(flags))
+bool imb_savebmp(ImBuf *ibuf, const char *filepath, int UNUSED(flags))
{
BMPINFOHEADER infoheader;
diff --git a/source/blender/imbuf/intern/cineon/cineon_dpx.c b/source/blender/imbuf/intern/cineon/cineon_dpx.c
index 98082a97e0f..7907d648abe 100644
--- a/source/blender/imbuf/intern/cineon/cineon_dpx.c
+++ b/source/blender/imbuf/intern/cineon/cineon_dpx.c
@@ -183,7 +183,7 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon
return rvalue;
}
-int imb_save_cineon(struct ImBuf *buf, const char *filepath, int flags)
+bool imb_save_cineon(struct ImBuf *buf, const char *filepath, int flags)
{
return imb_save_dpx_cineon(buf, filepath, 1, flags);
}
@@ -204,7 +204,7 @@ ImBuf *imb_load_cineon(const unsigned char *mem,
return NULL;
}
-int imb_save_dpx(struct ImBuf *buf, const char *filepath, int flags)
+bool imb_save_dpx(struct ImBuf *buf, const char *filepath, int flags)
{
return imb_save_dpx_cineon(buf, filepath, 0, flags);
}
diff --git a/source/blender/imbuf/intern/dds/dds_api.cpp b/source/blender/imbuf/intern/dds/dds_api.cpp
index e620c968f1c..d8bcca7e1f5 100644
--- a/source/blender/imbuf/intern/dds/dds_api.cpp
+++ b/source/blender/imbuf/intern/dds/dds_api.cpp
@@ -42,16 +42,16 @@
extern "C" {
-int imb_save_dds(struct ImBuf *ibuf, const char *name, int /*flags*/)
+bool imb_save_dds(struct ImBuf *ibuf, const char *name, int /*flags*/)
{
- return 0; /* todo: finish this function */
+ return false; /* todo: finish this function */
/* check image buffer */
if (ibuf == nullptr) {
- return 0;
+ return false;
}
if (ibuf->rect == nullptr) {
- return 0;
+ return false;
}
/* open file for writing */
@@ -69,7 +69,7 @@ int imb_save_dds(struct ImBuf *ibuf, const char *name, int /*flags*/)
fildes << "DDS ";
fildes.close();
- return 1;
+ return true;
}
int imb_is_a_dds(const unsigned char *mem) /* note: use at most first 32 bytes */
diff --git a/source/blender/imbuf/intern/dds/dds_api.h b/source/blender/imbuf/intern/dds/dds_api.h
index 930205c9efb..ca74cbeaa74 100644
--- a/source/blender/imbuf/intern/dds/dds_api.h
+++ b/source/blender/imbuf/intern/dds/dds_api.h
@@ -27,7 +27,7 @@ extern "C" {
#endif
int imb_is_a_dds(const unsigned char *mem); /* use only first 32 bytes of mem */
-int imb_save_dds(struct ImBuf *ibuf, const char *name, int flags);
+bool imb_save_dds(struct ImBuf *ibuf, const char *name, int flags);
struct ImBuf *imb_load_dds(const unsigned char *mem,
size_t size,
int flags,
diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c
index 214cdf1b63b..6bf2e3ec8d3 100644
--- a/source/blender/imbuf/intern/iris.c
+++ b/source/blender/imbuf/intern/iris.c
@@ -807,7 +807,7 @@ fail:
* Added: zbuf write
*/
-static int output_iris(uint *lptr, int xsize, int ysize, int zsize, const char *name, int *zptr)
+static bool output_iris(uint *lptr, int xsize, int ysize, int zsize, const char *name, int *zptr)
{
FILE *outf;
IMAGE *image;
@@ -969,10 +969,9 @@ static int compressrow(uchar *lbuf, uchar *rlebuf, int z, int cnt)
return optr - (uchar *)rlebuf;
}
-int imb_saveiris(struct ImBuf *ibuf, const char *filepath, int flags)
+bool imb_saveiris(struct ImBuf *ibuf, const char *filepath, int flags)
{
short zsize;
- int ret;
zsize = (ibuf->planes + 7) >> 3;
if (flags & IB_zbuf && ibuf->zbuf != NULL) {
@@ -982,11 +981,11 @@ int imb_saveiris(struct ImBuf *ibuf, const char *filepath, int flags)
IMB_convert_rgba_to_abgr(ibuf);
test_endian_zbuf(ibuf);
- ret = output_iris(ibuf->rect, ibuf->x, ibuf->y, zsize, filepath, ibuf->zbuf);
+ const bool ok = output_iris(ibuf->rect, ibuf->x, ibuf->y, zsize, filepath, ibuf->zbuf);
/* restore! Quite clumsy, 2 times a switch... maybe better a malloc ? */
IMB_convert_rgba_to_abgr(ibuf);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list