[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32171] trunk/blender/source/blender: images bigger then 32k no longer crash blender, use unsigned int for image size rather then short.

Campbell Barton ideasman42 at gmail.com
Tue Sep 28 12:03:56 CEST 2010


Revision: 32171
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32171
Author:   campbellbarton
Date:     2010-09-28 12:03:56 +0200 (Tue, 28 Sep 2010)

Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_image.h
    trunk/blender/source/blender/blenkernel/intern/constraint.c
    trunk/blender/source/blender/blenkernel/intern/image.c
    trunk/blender/source/blender/editors/transform/transform_snap.c
    trunk/blender/source/blender/imbuf/IMB_imbuf.h
    trunk/blender/source/blender/imbuf/IMB_imbuf_types.h
    trunk/blender/source/blender/imbuf/intern/allocimbuf.c
    trunk/blender/source/blender/imbuf/intern/jpeg.c
    trunk/blender/source/blender/imbuf/intern/scaling.c

Modified: trunk/blender/source/blender/blenkernel/BKE_image.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_image.h	2010-09-28 09:27:35 UTC (rev 32170)
+++ trunk/blender/source/blender/blenkernel/BKE_image.h	2010-09-28 10:03:56 UTC (rev 32171)
@@ -115,7 +115,7 @@
 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);
 

Modified: trunk/blender/source/blender/blenkernel/intern/constraint.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/constraint.c	2010-09-28 09:27:35 UTC (rev 32170)
+++ trunk/blender/source/blender/blenkernel/intern/constraint.c	2010-09-28 10:03:56 UTC (rev 32171)
@@ -4358,8 +4358,7 @@
 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 */

Modified: trunk/blender/source/blender/blenkernel/intern/image.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/image.c	2010-09-28 09:27:35 UTC (rev 32170)
+++ trunk/blender/source/blender/blenkernel/intern/image.c	2010-09-28 10:03:56 UTC (rev 32171)
@@ -382,7 +382,7 @@
 	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 @@
 }
 
 /* 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);

Modified: trunk/blender/source/blender/editors/transform/transform_snap.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_snap.c	2010-09-28 09:27:35 UTC (rev 32170)
+++ trunk/blender/source/blender/editors/transform/transform_snap.c	2010-09-28 10:03:56 UTC (rev 32171)
@@ -141,16 +141,15 @@
 			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);
 			}

Modified: trunk/blender/source/blender/imbuf/IMB_imbuf.h
===================================================================
--- trunk/blender/source/blender/imbuf/IMB_imbuf.h	2010-09-28 09:27:35 UTC (rev 32170)
+++ trunk/blender/source/blender/imbuf/IMB_imbuf.h	2010-09-28 10:03:56 UTC (rev 32171)
@@ -117,7 +117,7 @@
  *
  * @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 @@
  *
  * @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);
 
 /**
  *

Modified: trunk/blender/source/blender/imbuf/IMB_imbuf_types.h
===================================================================
--- trunk/blender/source/blender/imbuf/IMB_imbuf_types.h	2010-09-28 09:27:35 UTC (rev 32170)
+++ trunk/blender/source/blender/imbuf/IMB_imbuf_types.h	2010-09-28 10:03:56 UTC (rev 32171)
@@ -71,7 +71,7 @@
 	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) */
 

Modified: trunk/blender/source/blender/imbuf/intern/allocimbuf.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/allocimbuf.c	2010-09-28 09:27:35 UTC (rev 32170)
+++ trunk/blender/source/blender/imbuf/intern/allocimbuf.c	2010-09-28 10:03:56 UTC (rev 32171)
@@ -324,7 +324,7 @@
 	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;
 

Modified: trunk/blender/source/blender/imbuf/intern/jpeg.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/jpeg.c	2010-09-28 09:27:35 UTC (rev 32170)
+++ trunk/blender/source/blender/imbuf/intern/jpeg.c	2010-09-28 10:03:56 UTC (rev 32171)
@@ -298,9 +298,11 @@
 		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 @@
 		}
 		
 		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);
 }
 

Modified: trunk/blender/source/blender/imbuf/intern/scaling.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/scaling.c	2010-09-28 09:27:35 UTC (rev 32170)
+++ trunk/blender/source/blender/imbuf/intern/scaling.c	2010-09-28 10:03:56 UTC (rev 32171)
@@ -1439,7 +1439,7 @@
 	}
 }
 
-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 @@
 	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;





More information about the Bf-blender-cvs mailing list