Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorGaia Clary <gaia.clary@machinimatrix.org>2012-06-22 19:40:49 +0400
committerGaia Clary <gaia.clary@machinimatrix.org>2012-06-22 19:40:49 +0400
commit257283e030792157d24c2cd7846a92de9572b846 (patch)
tree7e4d026e28b9171e2cb937dbeffcbae1c1e4776a /source
parent5455cadb3d16685f682516475c0d66e071f386f2 (diff)
added new function BKE_imbuf_to_image_format
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_image.h1
-rw-r--r--source/blender/blenkernel/intern/image.c100
2 files changed, 101 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index baa530c0599..e2263a5edb7 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -70,6 +70,7 @@ char BKE_imtype_valid_depths(const char imtype);
char BKE_imtype_from_arg(const char *arg);
void BKE_imformat_defaults(struct ImageFormatData *im_format);
+void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const struct ImBuf *imbuf);
struct anim *openanim(const char *name, int flags, int streamindex);
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index eaf4c898b86..8676a5fb271 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -1208,6 +1208,106 @@ void BKE_imformat_defaults(ImageFormatData *im_format)
im_format->compress = 90;
}
+void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *imbuf)
+{
+ BKE_imformat_defaults(im_format);
+
+ // file type
+
+ if (imbuf->ftype == IMAGIC)
+ im_format->imtype = R_IMF_IMTYPE_IRIS;
+
+#ifdef WITH_HDR
+ else if (imbuf->ftype == RADHDR)
+ im_format->imtype = R_IMF_IMTYPE_RADHDR;
+#endif
+
+ else if (imbuf->ftype == PNG)
+ im_format->imtype = R_IMF_IMTYPE_PNG;
+
+#ifdef WITH_DDS
+ else if (imbuf->ftype == DDS)
+ im_format->imtype = R_IMF_IMTYPE_DDS;
+#endif
+
+ else if (imbuf->ftype == BMP)
+ im_format->imtype = R_IMF_IMTYPE_BMP;
+
+#ifdef WITH_TIFF
+ else if (imbuf->ftype & TIF) {
+ im_format->imtype = R_IMF_IMTYPE_TIFF;
+ if (imbuf->ftype & TIF_16BIT)
+ im_format->depth = R_IMF_CHAN_DEPTH_16;
+ }
+#endif
+
+#ifdef WITH_OPENEXR
+ else if (imbuf->ftype & OPENEXR) {
+ im_format->imtype = R_IMF_IMTYPE_OPENEXR;
+ if (imbuf->ftype & OPENEXR_HALF)
+ im_format->depth = R_IMF_CHAN_DEPTH_16;
+ if (imbuf->ftype & OPENEXR_COMPRESS)
+ im_format->exr_codec = R_IMF_EXR_CODEC_ZIP; // Can't determine compression
+ if (imbuf->zbuf_float)
+ im_format->flag |= R_IMF_FLAG_ZBUF;
+ }
+#endif
+
+#ifdef WITH_CINEON
+ else if (imbuf->ftype == CINEON)
+ im_format->imtype = R_IMF_IMTYPE_CINEON;
+ else if (imbuf->ftype == DPX)
+ im_format->imtype = R_IMF_IMTYPE_DPX;
+#endif
+
+ else if (imbuf->ftype == TGA) {
+ im_format->imtype = R_IMF_IMTYPE_TARGA;
+ }
+ else if (imbuf->ftype == RAWTGA) {
+ im_format->imtype = R_IMF_IMTYPE_RAWTGA;
+ }
+
+#ifdef WITH_OPENJPEG
+ else if (imbuf->ftype & JP2) {
+ im_format->imtype = R_IMF_IMTYPE_JP2;
+ im_format->quality = imbuf->ftype & ~JPG_MSK;
+
+ if (imbuf->ftype & JP2_16BIT)
+ im_format->depth = R_IMF_CHAN_DEPTH_16;
+ else if (imbuf->ftype & JP2_12BIT)
+ im_format->depth = R_IMF_CHAN_DEPTH_12;
+
+ if(imbuf->ftype & JP2_YCC)
+ im_format->jp2_flag |= R_IMF_JP2_FLAG_YCC;
+
+ if(imbuf->ftype & JP2_CINE) {
+ im_format->jp2_flag |= R_IMF_JP2_FLAG_CINE_PRESET;
+ if (imbuf->ftype & JP2_CINE_48FPS)
+ im_format->jp2_flag |= R_IMF_JP2_FLAG_CINE_48;
+ }
+ }
+#endif
+
+ else {
+ im_format->imtype = R_IMF_IMTYPE_JPEG90;
+ im_format->quality = imbuf->ftype & ~JPG_MSK;
+ }
+
+ // planes
+ switch (imbuf->channels) {
+ case 0:
+ case 4: im_format->planes = R_IMF_PLANES_RGBA;
+ break;
+ case 3: im_format->planes = R_IMF_PLANES_RGB;
+ break;
+ case 1: im_format->planes = R_IMF_PLANES_BW;
+ break;
+ default:im_format->planes = R_IMF_PLANES_RGB;
+ break;
+ }
+
+}
+
/* could allow access externally - 512 is for long names, 64 is for id names */
typedef struct StampData {
char file[512];