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 | |
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.
-rw-r--r-- | source/blender/blenkernel/BKE_image.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 4 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 7 | ||||
-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 |
9 files changed, 24 insertions, 22 deletions
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index e246b51af09..0a07e6d482c 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -115,7 +115,7 @@ void BKE_image_release_ibuf(struct Image *ima, void *lock); struct Image *BKE_add_image_file(const char *name, int frame); /* adds image, adds ibuf, generates color or pattern */ -struct Image *BKE_add_image_size(int width, int height, char *name, int depth, int floatbuf, short uvtestgrid, float color[4]); +struct Image *BKE_add_image_size(unsigned int width, unsigned int height, char *name, int depth, int floatbuf, short uvtestgrid, float color[4]); /* adds image from imbuf, owns imbuf */ struct Image *BKE_add_image_imbuf(struct ImBuf *ibuf); diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 59e81293c9f..fe69f13bbda 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -4358,8 +4358,7 @@ void get_constraint_target_matrix (struct Scene *scene, bConstraint *con, int n, void solve_constraints (ListBase *conlist, bConstraintOb *cob, float ctime) { bConstraint *con; - float solution[4][4], delta[4][4]; - float oldmat[4][4], imat[4][4]; + float oldmat[4][4]; float enf; /* check that there is a valid constraint object to evaluate */ diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index a199c1cf738..cb2261932ce 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -382,7 +382,7 @@ Image *BKE_add_image_file(const char *name, int frame) return ima; } -static ImBuf *add_ibuf_size(int width, int height, char *name, int depth, int floatbuf, short uvtestgrid, float color[4]) +static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, char *name, int depth, int floatbuf, short uvtestgrid, float color[4]) { ImBuf *ibuf; unsigned char *rect= NULL; @@ -415,7 +415,7 @@ static ImBuf *add_ibuf_size(int width, int height, char *name, int depth, int fl } /* adds new image block, creates ImBuf and initializes color */ -Image *BKE_add_image_size(int width, int height, char *name, int depth, int floatbuf, short uvtestgrid, float color[4]) +Image *BKE_add_image_size(unsigned int width, unsigned int height, char *name, int depth, int floatbuf, short uvtestgrid, float color[4]) { /* on save, type is changed to FILE in editsima.c */ Image *ima= image_alloc(name, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST); diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 778698d3060..93331dd0ee3 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -141,15 +141,14 @@ void drawSnapping(const struct bContext *C, TransInfo *t) TransSnapPoint *p; View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); - float tmat[4][4], imat[4][4]; + float imat[4][4]; float size; glDisable(GL_DEPTH_TEST); size = 0.5f * UI_GetThemeValuef(TH_VERTEX_SIZE); - - copy_m4_m4(tmat, rv3d->viewmat); - invert_m4_m4(imat, tmat); + + invert_m4_m4(imat, rv3d->viewmat); for (p = t->tsnap.points.first; p; p = p->next) { drawcircball(GL_LINE_LOOP, p->co, size * get_drawsize(t->ar, p->co), imat); 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; |