[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55229] trunk/blender/source/blender/imbuf /intern: patch [#34604] Add DPI read write for BMP and OpenEXR format
Campbell Barton
ideasman42 at gmail.com
Wed Mar 13 08:16:54 CET 2013
Revision: 55229
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55229
Author: campbellbarton
Date: 2013-03-13 07:16:53 +0000 (Wed, 13 Mar 2013)
Log Message:
-----------
patch [#34604] Add DPI read write for BMP and OpenEXR format
Modified Paths:
--------------
trunk/blender/source/blender/imbuf/intern/bmp.c
trunk/blender/source/blender/imbuf/intern/openexr/openexr_api.cpp
Modified: trunk/blender/source/blender/imbuf/intern/bmp.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/bmp.c 2013-03-13 06:44:43 UTC (rev 55228)
+++ trunk/blender/source/blender/imbuf/intern/bmp.c 2013-03-13 07:16:53 UTC (rev 55229)
@@ -126,6 +126,7 @@
int x, y, depth, skip, i;
unsigned char *bmp, *rect;
unsigned short col;
+ double xppm, yppm;
(void)size; /* unused */
@@ -145,6 +146,8 @@
x = LITTLE_LONG(bmi.biWidth);
y = LITTLE_LONG(bmi.biHeight);
depth = LITTLE_SHORT(bmi.biBitCount);
+ xppm = LITTLE_LONG(bmi.biXPelsPerMeter);
+ yppm = LITTLE_LONG(bmi.biYPelsPerMeter);
#if 0
printf("skip: %d, x: %d y: %d, depth: %d (%x)\n", skip, x, y,
@@ -200,6 +203,8 @@
}
if (ibuf) {
+ ibuf->ppm[0] = xppm;
+ ibuf->ppm[1] = yppm;
ibuf->ftype = BMP;
}
@@ -251,10 +256,10 @@
putShortLSB(24, ofile);
putIntLSB(0, ofile);
putIntLSB(bytesize + BMP_FILEHEADER_SIZE + sizeof(infoheader), ofile);
+ putIntLSB((int)(ibuf->ppm[0] + 0.5), ofile);
+ putIntLSB((int)(ibuf->ppm[1] + 0.5), ofile);
putIntLSB(0, ofile);
putIntLSB(0, ofile);
- putIntLSB(0, ofile);
- putIntLSB(0, ofile);
/* Need to write out padded image data in bgr format */
for (y = 0; y < ibuf->y; y++) {
Modified: trunk/blender/source/blender/imbuf/intern/openexr/openexr_api.cpp
===================================================================
--- trunk/blender/source/blender/imbuf/intern/openexr/openexr_api.cpp 2013-03-13 06:44:43 UTC (rev 55228)
+++ trunk/blender/source/blender/imbuf/intern/openexr/openexr_api.cpp 2013-03-13 07:16:53 UTC (rev 55229)
@@ -85,6 +85,7 @@
#include <ImfCompression.h>
#include <ImfCompressionAttribute.h>
#include <ImfStringAttribute.h>
+#include <ImfStandardAttributes.h>
using namespace Imf;
using namespace Imath;
@@ -302,6 +303,9 @@
for (info = ibuf->metadata; info; info = info->next)
header->insert(info->key, StringAttribute(info->value));
+
+ if (ibuf->ppm[0] > 0.0f)
+ addXDensity(*header, ibuf->ppm[0] / 39.3700787f); /* 1 meter = 39.3700787 inches */
}
static int imb_save_openexr_half(struct ImBuf *ibuf, const char *name, int flags)
@@ -1144,6 +1148,12 @@
const int is_alpha = exr_has_alpha(file);
ibuf = IMB_allocImBuf(width, height, is_alpha ? 32 : 24, 0);
+
+ if (hasXDensity(file->header())) {
+ ibuf->ppm[0] = xDensity(file->header()) * 39.3700787f;
+ ibuf->ppm[1] = ibuf->ppm[0] * file->header().pixelAspectRatio();
+ }
+
ibuf->ftype = OPENEXR;
if (!(flags & IB_test)) {
More information about the Bf-blender-cvs
mailing list