[Bf-blender-cvs] [01e15e5] multiview: Core changes to be able to get a ready-to-render ImBuf

Dalai Felinto noreply at git.blender.org
Fri Aug 8 15:14:07 CEST 2014


Commit: 01e15e5037f8c91d4a9e9e19ae8bb97001e8791d
Author: Dalai Felinto
Date:   Fri Aug 8 15:13:14 2014 +0200
Branches: multiview
https://developer.blender.org/rB01e15e5037f8c91d4a9e9e19ae8bb97001e8791d

Core changes to be able to get a ready-to-render ImBuf

Note: this could be done in master even

===================================================================

M	source/blender/blenkernel/BKE_image.h
M	source/blender/blenkernel/intern/image.c
M	source/blender/imbuf/IMB_imbuf.h
M	source/blender/imbuf/intern/util.c
M	source/blender/imbuf/intern/writeimage.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index e2a06f0..e48ccdc 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -60,6 +60,7 @@ void    BKE_imbuf_stamp_info(struct Scene *scene, struct Object *camera, struct
 void    BKE_stamp_buf(struct Scene *scene, struct Object *camera, unsigned char *rect, float *rectf, int width, int height, int channels);
 bool    BKE_imbuf_alpha_test(struct ImBuf *ibuf);
 int     BKE_imbuf_write_stamp(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf);
+void    BKE_imbuf_prepare_write(struct ImBuf *ibuf, struct ImageFormatData *imf);
 int     BKE_imbuf_write(struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf);
 int     BKE_imbuf_write_as(struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf, const bool is_copy);
 void    BKE_makepicstring(char *string, const char *base, const char *relbase, int frame,
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 6d03318..f01eeed 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -1888,14 +1888,12 @@ bool BKE_imbuf_alpha_test(ImBuf *ibuf)
 
 /* note: imf->planes is ignored here, its assumed the image channels
  * are already set */
-int BKE_imbuf_write(ImBuf *ibuf, const char *name, ImageFormatData *imf)
+void BKE_imbuf_prepare_write(ImBuf *ibuf, ImageFormatData *imf)
 {
 	char imtype = imf->imtype;
 	char compress = imf->compress;
 	char quality = imf->quality;
 
-	int ok;
-
 	if (imtype == R_IMF_IMTYPE_IRIS) {
 		ibuf->ftype = IMAGIC;
 	}
@@ -2016,6 +2014,13 @@ int BKE_imbuf_write(ImBuf *ibuf, const char *name, ImageFormatData *imf)
 		if (quality < 10) quality = 90;
 		ibuf->ftype = JPG | quality;
 	}
+}
+
+int BKE_imbuf_write(ImBuf *ibuf, const char *name, ImageFormatData *imf)
+{
+	int ok;
+
+	BKE_imbuf_prepare_write(ibuf, imf);
 
 	BLI_make_existing_file(name);
 
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index 9601055..4eaac4c 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -371,6 +371,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);
+struct ImBuf *IMB_prepare_write_ImBuf(const bool isfloat, struct ImBuf *ibuf);
 
 /**
  *
@@ -393,6 +394,12 @@ int imb_get_anim_type(const char *name);
 
 /**
  *
+ * \attention Defined in util.c
+ */
+bool IMB_isfloat(struct ImBuf *ibuf);
+
+/**
+ *
  * \attention Defined in divers.c
  */
 void IMB_de_interlace(struct ImBuf *ibuf);
diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c
index 32100aa..9835fa1 100644
--- a/source/blender/imbuf/intern/util.c
+++ b/source/blender/imbuf/intern/util.c
@@ -439,3 +439,15 @@ bool IMB_isanim(const char *filename)
 	
 	return (type && type != ANIM_SEQUENCE);
 }
+
+bool IMB_isfloat(ImBuf *ibuf)
+{
+	ImFileType *type;
+
+	for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) {
+		if (type->ftype(type, ibuf)) {
+			return (type->flag & IM_FTYPE_FLOAT);
+		}
+	}
+	return false;
+}
diff --git a/source/blender/imbuf/intern/writeimage.c b/source/blender/imbuf/intern/writeimage.c
index d4a9bf7..59c2469 100644
--- a/source/blender/imbuf/intern/writeimage.c
+++ b/source/blender/imbuf/intern/writeimage.c
@@ -45,19 +45,7 @@
 
 static ImBuf *prepare_write_imbuf(ImFileType *type, ImBuf *ibuf)
 {
-	ImBuf *write_ibuf = ibuf;
-
-	if (type->flag & IM_FTYPE_FLOAT) {
-		/* pass */
-	}
-	else {
-		if (ibuf->rect == NULL && ibuf->rect_float) {
-			ibuf->rect_colorspace = colormanage_colorspace_get_roled(COLOR_ROLE_DEFAULT_BYTE);
-			IMB_rect_from_float(ibuf);
-		}
-	}
-
-	return write_ibuf;
+	return IMB_prepare_write_ImBuf((type->flag & IM_FTYPE_FLOAT), ibuf);
 }
 
 short IMB_saveiff(struct ImBuf *ibuf, const char *name, int flags)
@@ -88,3 +76,19 @@ short IMB_saveiff(struct ImBuf *ibuf, const char *name, int flags)
 	return false;
 }
 
+ImBuf *IMB_prepare_write_ImBuf(const bool isfloat, ImBuf *ibuf)
+{
+	ImBuf *write_ibuf = ibuf;
+
+	if (isfloat) {
+		/* pass */
+	}
+	else {
+		if (ibuf->rect == NULL && ibuf->rect_float) {
+			ibuf->rect_colorspace = colormanage_colorspace_get_roled(COLOR_ROLE_DEFAULT_BYTE);
+			IMB_rect_from_float(ibuf);
+		}
+	}
+
+	return write_ibuf;
+}




More information about the Bf-blender-cvs mailing list