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
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2006-01-11 13:41:04 +0300
committerTon Roosendaal <ton@blender.org>2006-01-11 13:41:04 +0300
commit305fdec0eb3cfb166d2a5fd56382af5372b657e3 (patch)
tree55370f1526cda36af74bd9655241c43e2894ec17 /source/blender/imbuf
parent1332091dc27f02e89b7e0c87c1fabe01148b7322 (diff)
Orange: tested all EXR demo images from openexr.com, found two issues;
- images with a so-called "data window" (have negative start coordinate) did not read correctly - negative colors were not clamped yet in imbuf Now there's still some compliancy issues with zbuffers... you can save it either as unsigned int or as float, whilst blender renders zbuffer in signed int. :)
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r--source/blender/imbuf/intern/divers.c11
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.cpp19
2 files changed, 19 insertions, 11 deletions
diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c
index 07ba4ee5f73..cca92741275 100644
--- a/source/blender/imbuf/intern/divers.c
+++ b/source/blender/imbuf/intern/divers.c
@@ -166,6 +166,8 @@ void IMB_gamwarp(struct ImBuf *ibuf, double gamma)
}
}
+#define FTOCHAR(val) val<=0.0f?0: (val>=1.0f?255: (char)(255.0f*val))
+
void IMB_rect_from_float(struct ImBuf *ibuf)
{
/* quick method to convert floatbuf to byte */
@@ -181,12 +183,13 @@ void IMB_rect_from_float(struct ImBuf *ibuf)
for (i = ibuf->x * ibuf->y; i > 0; i--)
{
- to[0] = tof[0] > 1.0 ? 255 : (unsigned char)(tof[0] * 255.0f);
- to[1] = tof[1] > 1.0 ? 255 : (unsigned char)(tof[1] * 255.0f);
- to[2] = tof[2] > 1.0 ? 255 : (unsigned char)(tof[2] * 255.0f);
- to[3] = tof[3] > 1.0 ? 255 : (unsigned char)(tof[3] * 255.0f);
+ to[0] = FTOCHAR(tof[0]);
+ to[1] = FTOCHAR(tof[1]);
+ to[2] = FTOCHAR(tof[2]);
+ to[3] = FTOCHAR(tof[3]);
to += 4;
tof += 4;
}
}
+
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index 327c1ef02c5..1fefe48c227 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -375,10 +375,10 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, int size, int flags)
int width = dw.max.x - dw.min.x + 1;
int height = dw.max.y - dw.min.y + 1;
-// printf("OpenEXR-load: image data window %d %d %d %d\n",
-// dw.min.x, dw.min.y, dw.max.x, dw.max.y);
+ //printf("OpenEXR-load: image data window %d %d %d %d\n",
+ // dw.min.x, dw.min.y, dw.max.x, dw.max.y);
-// exr_print_filecontents(file);
+ //exr_print_filecontents(file);
ibuf = IMB_allocImBuf(width, height, 32, 0, 0);
@@ -389,12 +389,16 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, int size, int flags)
if (!(flags & IB_test))
{
FrameBuffer frameBuffer;
+ float *first;
+ int xstride = sizeof(float) * 4;
+ int ystride = - xstride*width;
imb_addrectfloatImBuf(ibuf);
- float *first= ibuf->rect_float + 4*(height-1)*width;
- int xstride = sizeof(float) * 4;
- int ystride = - xstride*width;
+ /* inverse correct first pixel for datawindow coordinates (- dw.min.y because of y flip) */
+ first= ibuf->rect_float - 4*(dw.min.x - dw.min.y*width);
+ /* but, since we read y-flipped (negative y stride) we move to last scanline */
+ first+= 4*(height-1)*width;
frameBuffer.insert ("R", Slice (FLOAT, (char *) first, xstride, ystride));
frameBuffer.insert ("G", Slice (FLOAT, (char *) (first+1), xstride, ystride));
@@ -406,7 +410,8 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, int size, int flags)
int *firstz;
addzbufImBuf(ibuf);
- firstz= ibuf->zbuf + (height-1)*width;
+ firstz= ibuf->zbuf - (dw.min.x - dw.min.y*width);
+ firstz+= (height-1)*width;
frameBuffer.insert ("Z", Slice (UINT, (char *)firstz , sizeof(int), -width*sizeof(int)));
}