diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-09-28 14:03:56 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-09-28 14:03:56 +0400 |
commit | 8df244f20dc4a2d92bbe496f123f2d6578167949 (patch) | |
tree | 93b4f34ee3cd5f98e30a3ebe324fdd59669e9ca1 /source/blender/imbuf | |
parent | 8d50b283cbc663f08b0c4b0e43ed8fdee4a93549 (diff) |
images bigger then 32k no longer crash blender, use unsigned int for image size rather then short.
also check if jpeg fails to allocate an imbuf.
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r-- | source/blender/imbuf/IMB_imbuf.h | 6 | ||||
-rw-r--r-- | source/blender/imbuf/IMB_imbuf_types.h | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/allocimbuf.c | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/jpeg.c | 16 | ||||
-rw-r--r-- | source/blender/imbuf/intern/scaling.c | 4 |
5 files changed, 17 insertions, 13 deletions
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index c39c5d31f80..d8c7be06aa1 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -117,7 +117,7 @@ void IMB_freeImBuf(struct ImBuf *ibuf); * * @attention Defined in allocimbuf.c */ -struct ImBuf *IMB_allocImBuf(short x, short y, +struct ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char d, unsigned int flags, unsigned char bitmap); @@ -272,13 +272,13 @@ struct ImBuf *IMB_onehalf(struct ImBuf *ibuf1); * * @attention Defined in scaling.c */ -struct ImBuf *IMB_scaleImBuf(struct ImBuf *ibuf, short newx, short newy); +struct ImBuf *IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy); /** * * @attention Defined in scaling.c */ -struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, short newx, short newy); +struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy); /** * diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h index 203a7268581..5fbdcf95f13 100644 --- a/source/blender/imbuf/IMB_imbuf_types.h +++ b/source/blender/imbuf/IMB_imbuf_types.h @@ -71,7 +71,7 @@ typedef struct ImBuf { struct ImBuf *next, *prev; /**< allow lists of ImBufs, for caches or flipbooks */ /* dimensions */ - short x, y; /* width and Height of our image buffer */ + unsigned int x, y; /* width and Height of our image buffer */ unsigned char depth; /* Active amount of bits/bitplanes */ int channels; /* amount of channels in rect_float (0 = 4 channel default) */ diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index 02fc98f2d63..e67c319e61a 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -324,7 +324,7 @@ short imb_addtilesImBuf(ImBuf *ibuf) return (ibuf->tiles != NULL); } -ImBuf *IMB_allocImBuf(short x, short y, uchar d, unsigned int flags, uchar bitmap) /* XXX bitmap argument is deprecated */ +ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar d, unsigned int flags, uchar bitmap) /* XXX bitmap argument is deprecated */ { ImBuf *ibuf; diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c index 855c0bf3433..0a070646fd5 100644 --- a/source/blender/imbuf/intern/jpeg.c +++ b/source/blender/imbuf/intern/jpeg.c @@ -298,9 +298,11 @@ static ImBuf * ibJpegImageFromCinfo(struct jpeg_decompress_struct * cinfo, int f if (flags & IB_test) { jpeg_abort_decompress(cinfo); ibuf = IMB_allocImBuf(x, y, 8 * depth, 0, 0); - } else { - ibuf = IMB_allocImBuf(x, y, 8 * depth, IB_rect, 0); - + } + else if ((ibuf = IMB_allocImBuf(x, y, 8 * depth, IB_rect, 0)) == NULL) { + jpeg_abort_decompress(cinfo); + } + else { row_stride = cinfo->output_width * depth; row_pointer = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo, JPOOL_IMAGE, row_stride, 1); @@ -421,10 +423,12 @@ next_stamp_marker: } jpeg_destroy((j_common_ptr) cinfo); - ibuf->ftype = ibuf_ftype; - ibuf->profile = IB_PROFILE_SRGB; + if(ibuf) { + ibuf->ftype = ibuf_ftype; + ibuf->profile = IB_PROFILE_SRGB; + } } - + return(ibuf); } diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c index 0b8dea01ada..4fccf5dae41 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.c @@ -1439,7 +1439,7 @@ static void scalefast_Z_ImBuf(ImBuf *ibuf, short newx, short newy) } } -struct ImBuf *IMB_scaleImBuf(struct ImBuf * ibuf, short newx, short newy) +struct ImBuf *IMB_scaleImBuf(struct ImBuf * ibuf, unsigned int newx, unsigned int newy) { if (ibuf==NULL) return (0); if (ibuf->rect==NULL && ibuf->rect_float==NULL) return (ibuf); @@ -1468,7 +1468,7 @@ struct imbufRGBA { float r, g, b, a; }; -struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, short newx, short newy) +struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy) { unsigned int *rect,*_newrect,*newrect; struct imbufRGBA *rectf, *_newrectf, *newrectf; |