diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2015-05-19 12:20:54 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2015-05-19 12:20:54 +0300 |
commit | 8357040667f3008d9d0f1e33f0b0dc54ff4a3ef8 (patch) | |
tree | bf3743b1cf42a7fa257fb2cac3a835bc7da17825 /source/blender/imbuf/intern | |
parent | 8ef679b6fddfa4f9d6a417b578e8ce77ca320c61 (diff) | |
parent | e8561e966d3d6ced9569e9a91aa123975e9ee95a (diff) |
Merge branch 'master' into gooseberry
Conflicts:
source/blender/windowmanager/intern/wm_playanim.c
Diffstat (limited to 'source/blender/imbuf/intern')
-rw-r--r-- | source/blender/imbuf/intern/IMB_filetype.h | 6 | ||||
-rw-r--r-- | source/blender/imbuf/intern/colormanagement.c | 4 | ||||
-rw-r--r-- | source/blender/imbuf/intern/filetype.c | 12 | ||||
-rw-r--r-- | source/blender/imbuf/intern/png.c | 15 | ||||
-rw-r--r-- | source/blender/imbuf/intern/readimage.c | 6 | ||||
-rw-r--r-- | source/blender/imbuf/intern/util.c | 4 | ||||
-rw-r--r-- | source/blender/imbuf/intern/writeimage.c | 4 |
7 files changed, 26 insertions, 25 deletions
diff --git a/source/blender/imbuf/intern/IMB_filetype.h b/source/blender/imbuf/intern/IMB_filetype.h index 0e6438fb729..332878b6067 100644 --- a/source/blender/imbuf/intern/IMB_filetype.h +++ b/source/blender/imbuf/intern/IMB_filetype.h @@ -40,7 +40,7 @@ typedef struct ImFileType { int (*is_a)(unsigned char *buf); int (*is_a_filepath)(const char *name); - int (*ftype)(struct ImFileType *type, struct ImBuf *ibuf); + int (*ftype)(const struct ImFileType *type, struct ImBuf *ibuf); struct ImBuf *(*load)(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]); struct ImBuf *(*load_filepath)(const char *name, int flags, char colorspace[IM_MAX_SPACE]); int (*save)(struct ImBuf *ibuf, const char *name, int flags); @@ -51,8 +51,8 @@ typedef struct ImFileType { int default_save_role; } ImFileType; -extern ImFileType IMB_FILE_TYPES[]; -extern ImFileType *IMB_FILE_TYPES_LAST; +extern const ImFileType IMB_FILE_TYPES[]; +extern const ImFileType *IMB_FILE_TYPES_LAST; void imb_filetypes_init(void); void imb_filetypes_exit(void); diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c index d6fdcad0819..a2f89ec4cbe 100644 --- a/source/blender/imbuf/intern/colormanagement.c +++ b/source/blender/imbuf/intern/colormanagement.c @@ -1948,7 +1948,7 @@ ImBuf *IMB_colormanagement_imbuf_for_write(ImBuf *ibuf, bool save_as_render, boo if (do_colormanagement) { bool make_byte = false; - ImFileType *type; + const ImFileType *type; /* for proper check whether byte buffer is required by a format or not * should be pretty safe since this image buffer is supposed to be used for @@ -2457,7 +2457,7 @@ const char *IMB_colormanagement_colorspace_get_indexed_name(int index) void IMB_colormanagment_colorspace_from_ibuf_ftype(ColorManagedColorspaceSettings *colorspace_settings, ImBuf *ibuf) { - ImFileType *type; + const ImFileType *type; for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) { if (type->save && type->ftype(type, ibuf)) { diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c index c6e358dd3d2..e58cda07ecf 100644 --- a/source/blender/imbuf/intern/filetype.c +++ b/source/blender/imbuf/intern/filetype.c @@ -51,17 +51,17 @@ #include "quicktime_import.h" #endif -static int imb_ftype_default(ImFileType *type, ImBuf *ibuf) +static int imb_ftype_default(const ImFileType *type, ImBuf *ibuf) { return (ibuf->ftype & type->filetype); } -static int imb_ftype_iris(ImFileType *type, ImBuf *ibuf) +static int imb_ftype_iris(const ImFileType *type, ImBuf *ibuf) { (void)type; return (ibuf->ftype == IMAGIC); } -ImFileType IMB_FILE_TYPES[] = { +const ImFileType IMB_FILE_TYPES[] = { {NULL, NULL, imb_is_a_jpeg, NULL, imb_ftype_default, imb_load_jpeg, NULL, imb_savejpeg, NULL, 0, JPG, COLOR_ROLE_DEFAULT_BYTE}, {NULL, NULL, imb_is_a_png, NULL, imb_ftype_default, imb_loadpng, NULL, imb_savepng, NULL, 0, PNG, COLOR_ROLE_DEFAULT_BYTE}, {NULL, NULL, imb_is_a_bmp, NULL, imb_ftype_default, imb_bmp_decode, NULL, imb_savebmp, NULL, 0, BMP, COLOR_ROLE_DEFAULT_BYTE}, @@ -92,11 +92,11 @@ ImFileType IMB_FILE_TYPES[] = { {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0} }; -ImFileType *IMB_FILE_TYPES_LAST = &IMB_FILE_TYPES[sizeof(IMB_FILE_TYPES) / sizeof(ImFileType) - 1]; +const ImFileType *IMB_FILE_TYPES_LAST = &IMB_FILE_TYPES[sizeof(IMB_FILE_TYPES) / sizeof(ImFileType) - 1]; void imb_filetypes_init(void) { - ImFileType *type; + const ImFileType *type; for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) if (type->init) @@ -109,7 +109,7 @@ void imb_filetypes_init(void) void imb_filetypes_exit(void) { - ImFileType *type; + const ImFileType *type; for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) if (type->exit) diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c index f3ff6659e1c..1b6b413838d 100644 --- a/source/blender/imbuf/intern/png.c +++ b/source/blender/imbuf/intern/png.c @@ -138,6 +138,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) int channels_in_float = ibuf->channels ? ibuf->channels : 4; float (*chanel_colormanage_cb)(float); + size_t num_bytes; /* use the jpeg quality setting for compression */ int compression; @@ -184,11 +185,11 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) } /* copy image data */ - + num_bytes = ((size_t)ibuf->x) * ibuf->y * bytesperpixel; if (is_16bit) - pixels16 = MEM_mallocN(ibuf->x * ibuf->y * bytesperpixel * sizeof(unsigned short), "png 16bit pixels"); + pixels16 = MEM_mallocN(num_bytes * sizeof(unsigned short), "png 16bit pixels"); else - pixels = MEM_mallocN(ibuf->x * ibuf->y * bytesperpixel * sizeof(unsigned char), "png 8bit pixels"); + pixels = MEM_mallocN(num_bytes * sizeof(unsigned char), "png 8bit pixels"); if (pixels == NULL && pixels16 == NULL) { png_destroy_write_struct(&png_ptr, &info_ptr); @@ -454,13 +455,13 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) if (is_16bit) { for (i = 0; i < ibuf->y; i++) { row_pointers[ibuf->y - 1 - i] = (png_bytep) - ((unsigned short *)pixels16 + (i * ibuf->x) * bytesperpixel); + ((unsigned short *)pixels16 + (((size_t)i) * ibuf->x) * bytesperpixel); } } else { for (i = 0; i < ibuf->y; i++) { row_pointers[ibuf->y - 1 - i] = (png_bytep) - ((unsigned char *)pixels + (i * ibuf->x) * bytesperpixel * sizeof(unsigned char)); + ((unsigned char *)pixels + (((size_t)i) * ibuf->x) * bytesperpixel * sizeof(unsigned char)); } } @@ -682,7 +683,7 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags, char colorspace[I else { imb_addrectImBuf(ibuf); - pixels = MEM_mallocN(ibuf->x * ibuf->y * bytesperpixel * sizeof(unsigned char), "pixels"); + pixels = MEM_mallocN(((size_t)ibuf->x) * ibuf->y * bytesperpixel * sizeof(unsigned char), "pixels"); if (pixels == NULL) { printf("Cannot allocate pixels array\n"); longjmp(png_jmpbuf(png_ptr), 1); @@ -698,7 +699,7 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags, char colorspace[I /* set the individual row-pointers to point at the correct offsets */ for (i = 0; i < ibuf->y; i++) { row_pointers[ibuf->y - 1 - i] = (png_bytep) - ((unsigned char *)pixels + (i * ibuf->x) * bytesperpixel * sizeof(unsigned char)); + ((unsigned char *)pixels + (((size_t)i) * ibuf->x) * bytesperpixel * sizeof(unsigned char)); } png_read_image(png_ptr, row_pointers); diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c index bb09c57d1e5..3cf123fbc28 100644 --- a/source/blender/imbuf/intern/readimage.c +++ b/source/blender/imbuf/intern/readimage.c @@ -103,7 +103,7 @@ static void imb_handle_alpha(ImBuf *ibuf, int flags, char colorspace[IM_MAX_SPAC ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE], const char *descr) { ImBuf *ibuf; - ImFileType *type; + const ImFileType *type; char effective_colorspace[IM_MAX_SPACE] = ""; if (mem == NULL) { @@ -133,7 +133,7 @@ ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags, char co static ImBuf *IMB_ibImageFromFile(const char *filepath, int flags, char colorspace[IM_MAX_SPACE], const char *descr) { ImBuf *ibuf; - ImFileType *type; + const ImFileType *type; char effective_colorspace[IM_MAX_SPACE] = ""; if (colorspace) @@ -257,7 +257,7 @@ ImBuf *IMB_testiffname(const char *filepath, int flags) static void imb_loadtilefile(ImBuf *ibuf, int file, int tx, int ty, unsigned int *rect) { - ImFileType *type; + const ImFileType *type; unsigned char *mem; size_t size; diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index 3fee6688014..77962d43470 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -186,7 +186,7 @@ int IMB_ispic_type(const char *name) #define HEADER_SIZE 64 unsigned char buf[HEADER_SIZE]; - ImFileType *type; + const ImFileType *type; BLI_stat_t st; int fp; @@ -442,7 +442,7 @@ bool IMB_isanim(const char *filename) bool IMB_isfloat(ImBuf *ibuf) { - ImFileType *type; + const ImFileType *type; for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) { if (type->ftype(type, ibuf)) { diff --git a/source/blender/imbuf/intern/writeimage.c b/source/blender/imbuf/intern/writeimage.c index 5e9ccf4437e..2f688803804 100644 --- a/source/blender/imbuf/intern/writeimage.c +++ b/source/blender/imbuf/intern/writeimage.c @@ -41,14 +41,14 @@ #include "IMB_colormanagement.h" #include "IMB_colormanagement_intern.h" -static ImBuf *prepare_write_imbuf(ImFileType *type, ImBuf *ibuf) +static ImBuf *prepare_write_imbuf(const ImFileType *type, ImBuf *ibuf) { return IMB_prepare_write_ImBuf((type->flag & IM_FTYPE_FLOAT), ibuf); } short IMB_saveiff(struct ImBuf *ibuf, const char *name, int flags) { - ImFileType *type; + const ImFileType *type; if (ibuf == NULL) return (false); ibuf->flags = flags; |