2011-02-23 11:52:22 +01:00
|
|
|
/*
|
2008-04-17 00:40:48 +02:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 13:37:38 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-04-17 00:40:48 +02:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 13:37:38 +02:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 14:34:04 +01:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 13:37:38 +02:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
2008-04-17 00:40:48 +02:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 13:37:38 +02:00
|
|
|
* allocimbuf.c
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-02-27 21:23:21 +01:00
|
|
|
/** \file blender/imbuf/intern/rectop.c
|
|
|
|
* \ingroup imbuf
|
|
|
|
*/
|
|
|
|
|
2012-08-13 00:50:21 +02:00
|
|
|
#include <stdlib.h>
|
2011-02-27 21:23:21 +01:00
|
|
|
|
2011-01-07 19:36:47 +01:00
|
|
|
#include "BLI_utildefines.h"
|
2012-08-13 00:50:21 +02:00
|
|
|
#include "BLI_math_color.h"
|
|
|
|
#include "BLI_math_vector.h"
|
2002-10-12 13:37:38 +02:00
|
|
|
|
|
|
|
#include "imbuf.h"
|
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
#include "IMB_imbuf.h"
|
|
|
|
|
|
|
|
#include "IMB_allocimbuf.h"
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 12:05:07 +02:00
|
|
|
#include "IMB_colormanagement.h"
|
2011-01-07 20:18:31 +01:00
|
|
|
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2006-07-31 17:53:03 +02:00
|
|
|
/* blend modes */
|
|
|
|
|
2012-09-10 04:45:29 +02:00
|
|
|
static void blend_color_mix(char cp[3], const char cp1[3], const char cp2[3], const int fac)
|
2006-07-31 17:53:03 +02:00
|
|
|
{
|
|
|
|
/* this and other blending modes previously used >>8 instead of /255. both
|
2012-03-09 19:28:30 +01:00
|
|
|
* are not equivalent (>>8 is /256), and the former results in rounding
|
|
|
|
* errors that can turn colors black fast after repeated blending */
|
2012-09-10 04:45:29 +02:00
|
|
|
const int mfac = 255 - fac;
|
2006-10-27 01:42:04 +02:00
|
|
|
|
2012-05-08 13:48:19 +02:00
|
|
|
cp[0] = (mfac * cp1[0] + fac * cp2[0]) / 255;
|
|
|
|
cp[1] = (mfac * cp1[1] + fac * cp2[1]) / 255;
|
|
|
|
cp[2] = (mfac * cp1[2] + fac * cp2[2]) / 255;
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
|
|
|
|
2012-09-10 04:45:29 +02:00
|
|
|
static void blend_color_add(char cp[3], const char cp1[3], const char cp2[3], const int fac)
|
2006-07-31 17:53:03 +02:00
|
|
|
{
|
|
|
|
int temp;
|
|
|
|
|
2012-05-08 13:48:19 +02:00
|
|
|
temp = cp1[0] + ((fac * cp2[0]) / 255);
|
|
|
|
if (temp > 254) cp[0] = 255; else cp[0] = temp;
|
|
|
|
temp = cp1[1] + ((fac * cp2[1]) / 255);
|
|
|
|
if (temp > 254) cp[1] = 255; else cp[1] = temp;
|
|
|
|
temp = cp1[2] + ((fac * cp2[2]) / 255);
|
|
|
|
if (temp > 254) cp[2] = 255; else cp[2] = temp;
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
|
|
|
|
2012-09-10 04:45:29 +02:00
|
|
|
static void blend_color_sub(char cp[3], const char cp1[3], const char cp2[3], const int fac)
|
2006-07-31 17:53:03 +02:00
|
|
|
{
|
|
|
|
int temp;
|
|
|
|
|
2012-05-08 13:48:19 +02:00
|
|
|
temp = cp1[0] - ((fac * cp2[0]) / 255);
|
|
|
|
if (temp < 0) cp[0] = 0; else cp[0] = temp;
|
|
|
|
temp = cp1[1] - ((fac * cp2[1]) / 255);
|
|
|
|
if (temp < 0) cp[1] = 0; else cp[1] = temp;
|
|
|
|
temp = cp1[2] - ((fac * cp2[2]) / 255);
|
|
|
|
if (temp < 0) cp[2] = 0; else cp[2] = temp;
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
|
|
|
|
2012-09-10 04:45:29 +02:00
|
|
|
static void blend_color_mul(char cp[3], const char cp1[3], const char cp2[3], const int fac)
|
2006-07-31 17:53:03 +02:00
|
|
|
{
|
2012-05-08 13:48:19 +02:00
|
|
|
int mfac = 255 - fac;
|
2006-07-31 17:53:03 +02:00
|
|
|
|
|
|
|
/* first mul, then blend the fac */
|
2012-05-08 13:48:19 +02:00
|
|
|
cp[0] = (mfac * cp1[0] + fac * ((cp1[0] * cp2[0]) / 255)) / 255;
|
|
|
|
cp[1] = (mfac * cp1[1] + fac * ((cp1[1] * cp2[1]) / 255)) / 255;
|
|
|
|
cp[2] = (mfac * cp1[2] + fac * ((cp1[2] * cp2[2]) / 255)) / 255;
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
|
|
|
|
2012-09-10 04:45:29 +02:00
|
|
|
static void blend_color_lighten(char cp[3], const char cp1[3], const char cp2[3], const int fac)
|
2006-07-31 17:53:03 +02:00
|
|
|
{
|
2012-03-18 08:38:51 +01:00
|
|
|
/* See if are lighter, if so mix, else don't do anything.
|
2012-03-09 19:28:30 +01:00
|
|
|
* if the paint col is darker then the original, then ignore */
|
2012-05-08 13:48:19 +02:00
|
|
|
if (cp1[0] + cp1[1] + cp1[2] > cp2[0] + cp2[1] + cp2[2]) {
|
|
|
|
cp[0] = cp1[0];
|
|
|
|
cp[1] = cp1[1];
|
|
|
|
cp[2] = cp1[2];
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
2012-09-10 04:45:29 +02:00
|
|
|
else {
|
2006-07-31 17:53:03 +02:00
|
|
|
blend_color_mix(cp, cp1, cp2, fac);
|
2012-09-10 04:45:29 +02:00
|
|
|
}
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
|
|
|
|
2012-09-10 04:45:29 +02:00
|
|
|
static void blend_color_darken(char cp[3], const char cp1[3], const char cp2[3], const int fac)
|
2006-07-31 17:53:03 +02:00
|
|
|
{
|
2012-03-18 08:38:51 +01:00
|
|
|
/* See if were darker, if so mix, else don't do anything.
|
2012-03-09 19:28:30 +01:00
|
|
|
* if the paint col is brighter then the original, then ignore */
|
2012-05-08 13:48:19 +02:00
|
|
|
if (cp1[0] + cp1[1] + cp1[2] < cp2[0] + cp2[1] + cp2[2]) {
|
|
|
|
cp[0] = cp1[0];
|
|
|
|
cp[1] = cp1[1];
|
|
|
|
cp[2] = cp1[2];
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
2012-09-10 04:45:29 +02:00
|
|
|
else {
|
2006-07-31 17:53:03 +02:00
|
|
|
blend_color_mix(cp, cp1, cp2, fac);
|
2012-09-10 04:45:29 +02:00
|
|
|
}
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int IMB_blend_color(unsigned int src1, unsigned int src2, int fac, IMB_BlendMode mode)
|
|
|
|
{
|
2006-11-07 01:10:37 +01:00
|
|
|
unsigned int dst;
|
|
|
|
int temp;
|
2006-07-31 17:53:03 +02:00
|
|
|
char *cp, *cp1, *cp2;
|
|
|
|
|
2012-05-08 13:48:19 +02:00
|
|
|
if (fac == 0)
|
2006-07-31 17:53:03 +02:00
|
|
|
return src1;
|
|
|
|
|
2012-05-08 13:48:19 +02:00
|
|
|
cp = (char *)&dst;
|
|
|
|
cp1 = (char *)&src1;
|
|
|
|
cp2 = (char *)&src2;
|
2006-07-31 17:53:03 +02:00
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case IMB_BLEND_MIX:
|
|
|
|
blend_color_mix(cp, cp1, cp2, fac); break;
|
|
|
|
case IMB_BLEND_ADD:
|
|
|
|
blend_color_add(cp, cp1, cp2, fac); break;
|
|
|
|
case IMB_BLEND_SUB:
|
|
|
|
blend_color_sub(cp, cp1, cp2, fac); break;
|
|
|
|
case IMB_BLEND_MUL:
|
|
|
|
blend_color_mul(cp, cp1, cp2, fac); break;
|
|
|
|
case IMB_BLEND_LIGHTEN:
|
|
|
|
blend_color_lighten(cp, cp1, cp2, fac); break;
|
|
|
|
case IMB_BLEND_DARKEN:
|
|
|
|
blend_color_darken(cp, cp1, cp2, fac); break;
|
|
|
|
default:
|
2012-05-08 13:48:19 +02:00
|
|
|
cp[0] = cp1[0];
|
|
|
|
cp[1] = cp1[1];
|
|
|
|
cp[2] = cp1[2];
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
|
|
|
|
2006-11-07 01:10:37 +01:00
|
|
|
if (mode == IMB_BLEND_ERASE_ALPHA) {
|
2012-05-08 13:48:19 +02:00
|
|
|
temp = (cp1[3] - fac * cp2[3] / 255);
|
|
|
|
cp[3] = (temp < 0) ? 0 : temp;
|
2006-11-07 01:10:37 +01:00
|
|
|
}
|
|
|
|
else { /* this does ADD_ALPHA also */
|
2012-05-08 13:48:19 +02:00
|
|
|
temp = (cp1[3] + fac * cp2[3] / 255);
|
|
|
|
cp[3] = (temp > 255) ? 255 : temp;
|
2006-11-07 01:10:37 +01:00
|
|
|
}
|
2006-10-27 01:42:04 +02:00
|
|
|
|
2006-07-31 17:53:03 +02:00
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
2012-09-10 04:45:29 +02:00
|
|
|
static void blend_color_mix_float(float cp[3], const float cp1[3], const float cp2[3], const float fac)
|
2006-07-31 17:53:03 +02:00
|
|
|
{
|
2012-05-08 13:48:19 +02:00
|
|
|
float mfac = 1.0f - fac;
|
|
|
|
cp[0] = mfac * cp1[0] + fac * cp2[0];
|
|
|
|
cp[1] = mfac * cp1[1] + fac * cp2[1];
|
|
|
|
cp[2] = mfac * cp1[2] + fac * cp2[2];
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
|
|
|
|
2012-09-10 04:45:29 +02:00
|
|
|
static void blend_color_add_float(float cp[3], const float cp1[3], const float cp2[3], const float fac)
|
2006-07-31 17:53:03 +02:00
|
|
|
{
|
2012-05-08 13:48:19 +02:00
|
|
|
cp[0] = cp1[0] + fac * cp2[0];
|
|
|
|
cp[1] = cp1[1] + fac * cp2[1];
|
|
|
|
cp[2] = cp1[2] + fac * cp2[2];
|
2006-07-31 17:53:03 +02:00
|
|
|
|
2012-05-08 13:48:19 +02:00
|
|
|
if (cp[0] > 1.0f) cp[0] = 1.0f;
|
|
|
|
if (cp[1] > 1.0f) cp[1] = 1.0f;
|
|
|
|
if (cp[2] > 1.0f) cp[2] = 1.0f;
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
|
|
|
|
2012-09-10 04:45:29 +02:00
|
|
|
static void blend_color_sub_float(float cp[3], const float cp1[3], const float cp2[3], const float fac)
|
2006-07-31 17:53:03 +02:00
|
|
|
{
|
2012-05-08 13:48:19 +02:00
|
|
|
cp[0] = cp1[0] - fac * cp2[0];
|
|
|
|
cp[1] = cp1[1] - fac * cp2[1];
|
|
|
|
cp[2] = cp1[2] - fac * cp2[2];
|
2006-07-31 17:53:03 +02:00
|
|
|
|
2012-05-08 13:48:19 +02:00
|
|
|
if (cp[0] < 0.0f) cp[0] = 0.0f;
|
|
|
|
if (cp[1] < 0.0f) cp[1] = 0.0f;
|
|
|
|
if (cp[2] < 0.0f) cp[2] = 0.0f;
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
|
|
|
|
2012-09-10 04:45:29 +02:00
|
|
|
static void blend_color_mul_float(float cp[3], const float cp1[3], const float cp2[3], const float fac)
|
2006-07-31 17:53:03 +02:00
|
|
|
{
|
2012-05-08 13:48:19 +02:00
|
|
|
float mfac = 1.0f - fac;
|
2006-07-31 17:53:03 +02:00
|
|
|
|
2012-05-08 13:48:19 +02:00
|
|
|
cp[0] = mfac * cp1[0] + fac * (cp1[0] * cp2[0]);
|
|
|
|
cp[1] = mfac * cp1[1] + fac * (cp1[1] * cp2[1]);
|
|
|
|
cp[2] = mfac * cp1[2] + fac * (cp1[2] * cp2[2]);
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
|
|
|
|
2012-09-10 04:45:29 +02:00
|
|
|
static void blend_color_lighten_float(float cp[3], const float cp1[3], const float cp2[3], const float fac)
|
2006-07-31 17:53:03 +02:00
|
|
|
{
|
2012-03-18 08:38:51 +01:00
|
|
|
/* See if are lighter, if so mix, else don't do anything.
|
2012-03-09 19:28:30 +01:00
|
|
|
* if the pafloat col is darker then the original, then ignore */
|
2012-05-08 13:48:19 +02:00
|
|
|
if (cp1[0] + cp1[1] + cp1[2] > cp2[0] + cp2[1] + cp2[2]) {
|
|
|
|
cp[0] = cp1[0];
|
|
|
|
cp[1] = cp1[1];
|
|
|
|
cp[2] = cp1[2];
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
blend_color_mix_float(cp, cp1, cp2, fac);
|
|
|
|
}
|
|
|
|
|
2012-09-10 04:45:29 +02:00
|
|
|
static void blend_color_darken_float(float cp[3], const float cp1[3], const float cp2[3], const float fac)
|
2006-07-31 17:53:03 +02:00
|
|
|
{
|
2012-03-18 08:38:51 +01:00
|
|
|
/* See if were darker, if so mix, else don't do anything.
|
2012-03-09 19:28:30 +01:00
|
|
|
* if the pafloat col is brighter then the original, then ignore */
|
2012-05-08 13:48:19 +02:00
|
|
|
if (cp1[0] + cp1[1] + cp1[2] < cp2[0] + cp2[1] + cp2[2]) {
|
|
|
|
cp[0] = cp1[0];
|
|
|
|
cp[1] = cp1[1];
|
|
|
|
cp[2] = cp1[2];
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
blend_color_mix_float(cp, cp1, cp2, fac);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IMB_blend_color_float(float *dst, float *src1, float *src2, float fac, IMB_BlendMode mode)
|
|
|
|
{
|
2012-05-08 13:48:19 +02:00
|
|
|
if (fac == 0) {
|
|
|
|
dst[0] = src1[0];
|
|
|
|
dst[1] = src1[1];
|
|
|
|
dst[2] = src1[2];
|
|
|
|
dst[3] = src1[3];
|
2006-07-31 17:53:03 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case IMB_BLEND_MIX:
|
|
|
|
blend_color_mix_float(dst, src1, src2, fac); break;
|
|
|
|
case IMB_BLEND_ADD:
|
|
|
|
blend_color_add_float(dst, src1, src2, fac); break;
|
|
|
|
case IMB_BLEND_SUB:
|
|
|
|
blend_color_sub_float(dst, src1, src2, fac); break;
|
|
|
|
case IMB_BLEND_MUL:
|
|
|
|
blend_color_mul_float(dst, src1, src2, fac); break;
|
|
|
|
case IMB_BLEND_LIGHTEN:
|
|
|
|
blend_color_lighten_float(dst, src1, src2, fac); break;
|
|
|
|
case IMB_BLEND_DARKEN:
|
|
|
|
blend_color_darken_float(dst, src1, src2, fac); break;
|
|
|
|
default:
|
2012-05-08 13:48:19 +02:00
|
|
|
dst[0] = src1[0];
|
|
|
|
dst[1] = src1[1];
|
|
|
|
dst[2] = src1[2];
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
2006-10-27 01:42:04 +02:00
|
|
|
|
2006-11-07 01:10:37 +01:00
|
|
|
if (mode == IMB_BLEND_ERASE_ALPHA) {
|
2012-05-08 13:48:19 +02:00
|
|
|
dst[3] = (src1[3] - fac * src2[3]);
|
2006-11-07 01:10:37 +01:00
|
|
|
if (dst[3] < 0.0f) dst[3] = 0.0f;
|
|
|
|
}
|
|
|
|
else { /* this does ADD_ALPHA also */
|
2012-05-08 13:48:19 +02:00
|
|
|
dst[3] = (src1[3] + fac * src2[3]);
|
2006-11-07 01:10:37 +01:00
|
|
|
if (dst[3] > 1.0f) dst[3] = 1.0f;
|
|
|
|
}
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* clipping */
|
|
|
|
|
|
|
|
void IMB_rectclip(struct ImBuf *dbuf, struct ImBuf *sbuf, int *destx,
|
2012-05-08 13:48:19 +02:00
|
|
|
int *desty, int *srcx, int *srcy, int *width, int *height)
|
2006-07-31 17:53:03 +02:00
|
|
|
{
|
|
|
|
int tmp;
|
|
|
|
|
|
|
|
if (dbuf == NULL) return;
|
|
|
|
|
|
|
|
if (*destx < 0) {
|
2006-08-27 15:29:00 +02:00
|
|
|
*srcx -= *destx;
|
|
|
|
*width += *destx;
|
2006-07-31 17:53:03 +02:00
|
|
|
*destx = 0;
|
|
|
|
}
|
|
|
|
if (*srcx < 0) {
|
2006-08-27 15:29:00 +02:00
|
|
|
*destx -= *srcx;
|
2009-12-08 09:44:18 +01:00
|
|
|
*width += *srcx;
|
2006-07-31 17:53:03 +02:00
|
|
|
*srcx = 0;
|
|
|
|
}
|
|
|
|
if (*desty < 0) {
|
2006-08-27 15:29:00 +02:00
|
|
|
*srcy -= *desty;
|
|
|
|
*height += *desty;
|
2006-07-31 17:53:03 +02:00
|
|
|
*desty = 0;
|
|
|
|
}
|
|
|
|
if (*srcy < 0) {
|
2006-08-27 15:29:00 +02:00
|
|
|
*desty -= *srcy;
|
2009-12-08 09:44:18 +01:00
|
|
|
*height += *srcy;
|
2006-07-31 17:53:03 +02:00
|
|
|
*srcy = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = dbuf->x - *destx;
|
|
|
|
if (*width > tmp) *width = tmp;
|
|
|
|
tmp = dbuf->y - *desty;
|
|
|
|
if (*height > tmp) *height = tmp;
|
|
|
|
|
|
|
|
if (sbuf) {
|
|
|
|
tmp = sbuf->x - *srcx;
|
|
|
|
if (*width > tmp) *width = tmp;
|
|
|
|
tmp = sbuf->y - *srcy;
|
|
|
|
if (*height > tmp) *height = tmp;
|
|
|
|
}
|
2006-08-27 15:29:00 +02:00
|
|
|
|
|
|
|
if ((*height <= 0) || (*width <= 0)) {
|
|
|
|
*width = 0;
|
|
|
|
*height = 0;
|
|
|
|
}
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* copy and blend */
|
|
|
|
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 01:40:35 +01:00
|
|
|
void IMB_rectcpy(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx,
|
2012-05-08 13:48:19 +02:00
|
|
|
int desty, int srcx, int srcy, int width, int height)
|
2002-10-12 13:37:38 +02:00
|
|
|
{
|
2006-07-31 17:53:03 +02:00
|
|
|
IMB_rectblend(dbuf, sbuf, destx, desty, srcx, srcy, width, height,
|
2012-05-08 13:48:19 +02:00
|
|
|
IMB_BLEND_COPY);
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void IMB_rectblend(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx,
|
2012-05-08 13:48:19 +02:00
|
|
|
int desty, int srcx, int srcy, int width, int height, IMB_BlendMode mode)
|
2006-07-31 17:53:03 +02:00
|
|
|
{
|
|
|
|
unsigned int *drect = NULL, *srect = NULL, *dr, *sr;
|
|
|
|
float *drectf = NULL, *srectf = NULL, *drf, *srf;
|
|
|
|
int do_float, do_char, srcskip, destskip, x;
|
2002-10-12 13:37:38 +02:00
|
|
|
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 01:40:35 +01:00
|
|
|
if (dbuf == NULL) return;
|
2006-07-31 17:53:03 +02:00
|
|
|
|
|
|
|
IMB_rectclip(dbuf, sbuf, &destx, &desty, &srcx, &srcy, &width, &height);
|
|
|
|
|
|
|
|
if (width == 0 || height == 0) return;
|
2012-05-08 13:48:19 +02:00
|
|
|
if (sbuf && sbuf->channels != 4) return;
|
|
|
|
if (dbuf->channels != 4) return;
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 01:40:35 +01:00
|
|
|
|
2006-07-31 17:53:03 +02:00
|
|
|
do_char = (sbuf && sbuf->rect && dbuf->rect);
|
|
|
|
do_float = (sbuf && sbuf->rect_float && dbuf->rect_float);
|
|
|
|
|
|
|
|
if (do_char) drect = dbuf->rect + desty * dbuf->x + destx;
|
2012-05-08 13:48:19 +02:00
|
|
|
if (do_float) drectf = dbuf->rect_float + (desty * dbuf->x + destx) * 4;
|
2006-07-31 17:53:03 +02:00
|
|
|
|
|
|
|
destskip = dbuf->x;
|
2004-08-31 16:23:29 +02:00
|
|
|
|
2006-07-31 17:53:03 +02:00
|
|
|
if (sbuf) {
|
|
|
|
if (do_char) srect = sbuf->rect + srcy * sbuf->x + srcx;
|
2012-05-08 13:48:19 +02:00
|
|
|
if (do_float) srectf = sbuf->rect_float + (srcy * sbuf->x + srcx) * 4;
|
2006-07-31 17:53:03 +02:00
|
|
|
srcskip = sbuf->x;
|
2012-03-24 07:38:07 +01:00
|
|
|
}
|
|
|
|
else {
|
2002-10-12 13:37:38 +02:00
|
|
|
srect = drect;
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 01:40:35 +01:00
|
|
|
srectf = drectf;
|
2006-07-31 17:53:03 +02:00
|
|
|
srcskip = destskip;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mode == IMB_BLEND_COPY) {
|
|
|
|
/* copy */
|
2012-05-08 13:48:19 +02:00
|
|
|
for (; height > 0; height--) {
|
2006-07-31 17:53:03 +02:00
|
|
|
if (do_char) {
|
2012-04-29 17:47:02 +02:00
|
|
|
memcpy(drect, srect, width * sizeof(int));
|
2006-07-31 17:53:03 +02:00
|
|
|
drect += destskip;
|
|
|
|
srect += srcskip;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (do_float) {
|
2012-04-29 17:47:02 +02:00
|
|
|
memcpy(drectf, srectf, width * sizeof(float) * 4);
|
2012-05-08 13:48:19 +02:00
|
|
|
drectf += destskip * 4;
|
|
|
|
srectf += srcskip * 4;
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mode == IMB_BLEND_COPY_RGB) {
|
|
|
|
/* copy rgb only */
|
2012-05-08 13:48:19 +02:00
|
|
|
for (; height > 0; height--) {
|
2006-07-31 17:53:03 +02:00
|
|
|
if (do_char) {
|
|
|
|
dr = drect;
|
|
|
|
sr = srect;
|
2012-05-08 13:48:19 +02:00
|
|
|
for (x = width; x > 0; x--, dr++, sr++) {
|
|
|
|
((char *)dr)[0] = ((char *)sr)[0];
|
|
|
|
((char *)dr)[1] = ((char *)sr)[1];
|
|
|
|
((char *)dr)[2] = ((char *)sr)[2];
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
|
|
|
drect += destskip;
|
|
|
|
srect += srcskip;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (do_float) {
|
|
|
|
drf = drectf;
|
|
|
|
srf = srectf;
|
2012-05-08 13:48:19 +02:00
|
|
|
for (x = width; x > 0; x--, drf += 4, srf += 4) {
|
|
|
|
drf[0] = srf[0];
|
|
|
|
drf[1] = srf[1];
|
|
|
|
drf[2] = srf[2];
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
2012-05-08 13:48:19 +02:00
|
|
|
drectf += destskip * 4;
|
|
|
|
srectf += srcskip * 4;
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mode == IMB_BLEND_COPY_ALPHA) {
|
|
|
|
/* copy alpha only */
|
2012-05-08 13:48:19 +02:00
|
|
|
for (; height > 0; height--) {
|
2006-07-31 17:53:03 +02:00
|
|
|
if (do_char) {
|
|
|
|
dr = drect;
|
|
|
|
sr = srect;
|
2012-05-08 13:48:19 +02:00
|
|
|
for (x = width; x > 0; x--, dr++, sr++)
|
|
|
|
((char *)dr)[3] = ((char *)sr)[3];
|
2006-07-31 17:53:03 +02:00
|
|
|
drect += destskip;
|
|
|
|
srect += srcskip;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (do_float) {
|
|
|
|
drf = drectf;
|
|
|
|
srf = srectf;
|
2012-05-08 13:48:19 +02:00
|
|
|
for (x = width; x > 0; x--, drf += 4, srf += 4)
|
|
|
|
drf[3] = srf[3];
|
|
|
|
drectf += destskip * 4;
|
|
|
|
srectf += srcskip * 4;
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
|
|
|
}
|
2002-10-12 13:37:38 +02:00
|
|
|
}
|
2006-07-31 17:53:03 +02:00
|
|
|
else {
|
|
|
|
/* blend */
|
2012-05-08 13:48:19 +02:00
|
|
|
for (; height > 0; height--) {
|
2006-07-31 17:53:03 +02:00
|
|
|
if (do_char) {
|
|
|
|
dr = drect;
|
|
|
|
sr = srect;
|
2012-05-08 13:48:19 +02:00
|
|
|
for (x = width; x > 0; x--, dr++, sr++)
|
|
|
|
*dr = IMB_blend_color(*dr, *sr, ((char *)sr)[3], mode);
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2006-07-31 17:53:03 +02:00
|
|
|
drect += destskip;
|
|
|
|
srect += srcskip;
|
|
|
|
}
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 01:40:35 +01:00
|
|
|
|
2006-07-31 17:53:03 +02:00
|
|
|
if (do_float) {
|
|
|
|
drf = drectf;
|
|
|
|
srf = srectf;
|
2012-05-08 13:48:19 +02:00
|
|
|
for (x = width; x > 0; x--, drf += 4, srf += 4)
|
2006-07-31 17:53:03 +02:00
|
|
|
IMB_blend_color_float(drf, drf, srf, srf[3], mode);
|
2006-01-17 18:23:44 +01:00
|
|
|
|
2012-05-08 13:48:19 +02:00
|
|
|
drectf += destskip * 4;
|
|
|
|
srectf += srcskip * 4;
|
2012-10-21 07:46:41 +02:00
|
|
|
}
|
2006-07-31 17:53:03 +02:00
|
|
|
}
|
2002-10-12 13:37:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-31 17:53:03 +02:00
|
|
|
/* fill */
|
|
|
|
|
2011-06-15 03:56:49 +02:00
|
|
|
void IMB_rectfill(struct ImBuf *drect, const float col[4])
|
2002-10-12 13:37:38 +02:00
|
|
|
{
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 01:40:35 +01:00
|
|
|
int num;
|
2006-07-31 17:53:03 +02:00
|
|
|
|
2012-03-24 07:38:07 +01:00
|
|
|
if (drect->rect) {
|
2007-02-15 11:46:10 +01:00
|
|
|
unsigned int *rrect = drect->rect;
|
|
|
|
char ccol[4];
|
|
|
|
|
2012-05-08 13:48:19 +02:00
|
|
|
ccol[0] = (int)(col[0] * 255);
|
|
|
|
ccol[1] = (int)(col[1] * 255);
|
|
|
|
ccol[2] = (int)(col[2] * 255);
|
|
|
|
ccol[3] = (int)(col[3] * 255);
|
2007-02-15 11:46:10 +01:00
|
|
|
|
|
|
|
num = drect->x * drect->y;
|
2012-05-08 13:48:19 +02:00
|
|
|
for (; num > 0; num--)
|
|
|
|
*rrect++ = *((unsigned int *)ccol);
|
2007-02-15 11:46:10 +01:00
|
|
|
}
|
|
|
|
|
2012-03-24 07:38:07 +01:00
|
|
|
if (drect->rect_float) {
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 01:40:35 +01:00
|
|
|
float *rrectf = drect->rect_float;
|
|
|
|
|
|
|
|
num = drect->x * drect->y;
|
2012-05-08 13:48:19 +02:00
|
|
|
for (; num > 0; num--) {
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 01:40:35 +01:00
|
|
|
*rrectf++ = col[0];
|
|
|
|
*rrectf++ = col[1];
|
|
|
|
*rrectf++ = col[2];
|
|
|
|
*rrectf++ = col[3];
|
|
|
|
}
|
2012-10-21 07:46:41 +02:00
|
|
|
}
|
2002-10-12 13:37:38 +02:00
|
|
|
}
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 01:40:35 +01:00
|
|
|
|
2007-10-28 23:27:07 +01:00
|
|
|
|
2012-08-13 00:50:21 +02:00
|
|
|
void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height,
|
2012-10-21 07:46:41 +02:00
|
|
|
const float col[4], struct ColorManagedDisplay *display,
|
|
|
|
int x1, int y1, int x2, int y2)
|
2007-10-20 18:17:27 +02:00
|
|
|
{
|
|
|
|
int i, j;
|
2008-02-22 00:19:06 +01:00
|
|
|
float a; /* alpha */
|
|
|
|
float ai; /* alpha inverted */
|
|
|
|
float aich; /* alpha, inverted, ai/255.0 - Convert char to float at the same time */
|
2012-05-08 13:48:19 +02:00
|
|
|
if ((!rect && !rectf) || (!col) || col[3] == 0.0f)
|
2007-10-20 18:17:27 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* sanity checks for coords */
|
2007-10-28 23:27:07 +01:00
|
|
|
CLAMP(x1, 0, width);
|
|
|
|
CLAMP(x2, 0, width);
|
|
|
|
CLAMP(y1, 0, height);
|
|
|
|
CLAMP(y2, 0, height);
|
2007-10-20 18:17:27 +02:00
|
|
|
|
2012-05-08 13:48:19 +02:00
|
|
|
if (x1 > x2) SWAP(int, x1, x2);
|
|
|
|
if (y1 > y2) SWAP(int, y1, y2);
|
|
|
|
if (x1 == x2 || y1 == y2) return;
|
2007-10-20 18:17:27 +02:00
|
|
|
|
Patch by GSR #7628, I also added alpha for text background.
The list of changes (some are fixes):
- Properly horizontally centered tags in all fields (bug?).
- File area does not have trailing space and has leading "File " at
start instead (probably a bug).
- Small separation between to time related fields, space saving.
- Removed colons, for consistency and space saving again.
- Frame field is zero aligned for higher visual stability.
- Marker name shows a rarer name, "<none>" (using <> is typical for cases
in which there is nothing: <none>, <empty>, <blank>, etc).
- Top area for misc info that can be really long (file, note and render date).
- Bottom area for more constantly changing but short ones (marker, SMPTE,
frame, camera and scene).
- Only render date moves a line (when note field is not used), and frame one
moves if no SMPTE (still in same line, so no big jump), for extra visual
stability (marker is fixed, assuming most people would show frame and or
SMPTE).
- ISO 8601 date format for render date, localization independant.
Comparision images:
http://www.infernal-iceberg.com/blender/stamp-original.png
http://www.infernal-iceberg.com/blender/stamp-cleanup.png
2007-10-24 00:51:50 +02:00
|
|
|
a = col[3];
|
2012-05-08 13:48:19 +02:00
|
|
|
ai = 1 - a;
|
|
|
|
aich = ai / 255.0f;
|
2007-10-28 23:27:07 +01:00
|
|
|
|
|
|
|
if (rect) {
|
|
|
|
unsigned char *pixel;
|
2012-05-08 13:48:19 +02:00
|
|
|
unsigned char chr = 0, chg = 0, chb = 0;
|
|
|
|
float fr = 0, fg = 0, fb = 0;
|
2011-08-31 03:05:40 +02:00
|
|
|
|
2012-05-08 13:48:19 +02:00
|
|
|
const int alphaint = FTOCHAR(a);
|
2007-10-20 18:17:27 +02:00
|
|
|
|
2011-03-27 19:12:59 +02:00
|
|
|
if (a == 1.0f) {
|
2007-10-28 23:27:07 +01:00
|
|
|
chr = FTOCHAR(col[0]);
|
|
|
|
chg = FTOCHAR(col[1]);
|
|
|
|
chb = FTOCHAR(col[2]);
|
2012-03-24 07:38:07 +01:00
|
|
|
}
|
|
|
|
else {
|
2012-05-08 13:48:19 +02:00
|
|
|
fr = col[0] * a;
|
|
|
|
fg = col[1] * a;
|
|
|
|
fb = col[2] * a;
|
2007-10-28 23:27:07 +01:00
|
|
|
}
|
2012-05-08 13:48:19 +02:00
|
|
|
for (j = 0; j < y2 - y1; j++) {
|
|
|
|
for (i = 0; i < x2 - x1; i++) {
|
2007-10-28 23:27:07 +01:00
|
|
|
pixel = rect + 4 * (((y1 + j) * width) + (x1 + i));
|
2012-05-08 13:48:19 +02:00
|
|
|
if (pixel >= rect && pixel < rect + (4 * (width * height))) {
|
2011-03-27 19:12:59 +02:00
|
|
|
if (a == 1.0f) {
|
2007-10-28 23:27:07 +01:00
|
|
|
pixel[0] = chr;
|
|
|
|
pixel[1] = chg;
|
|
|
|
pixel[2] = chb;
|
2011-08-31 03:05:40 +02:00
|
|
|
pixel[3] = 255;
|
2012-03-24 07:38:07 +01:00
|
|
|
}
|
|
|
|
else {
|
2011-08-31 03:05:40 +02:00
|
|
|
int alphatest;
|
2012-05-08 13:48:19 +02:00
|
|
|
pixel[0] = (char)((fr + ((float)pixel[0] * aich)) * 255.0f);
|
|
|
|
pixel[1] = (char)((fg + ((float)pixel[1] * aich)) * 255.0f);
|
|
|
|
pixel[2] = (char)((fb + ((float)pixel[2] * aich)) * 255.0f);
|
|
|
|
pixel[3] = (char)((alphatest = ((int)pixel[3] + alphaint)) < 255 ? alphatest : 255);
|
2007-10-28 23:27:07 +01:00
|
|
|
}
|
Patch by GSR #7628, I also added alpha for text background.
The list of changes (some are fixes):
- Properly horizontally centered tags in all fields (bug?).
- File area does not have trailing space and has leading "File " at
start instead (probably a bug).
- Small separation between to time related fields, space saving.
- Removed colons, for consistency and space saving again.
- Frame field is zero aligned for higher visual stability.
- Marker name shows a rarer name, "<none>" (using <> is typical for cases
in which there is nothing: <none>, <empty>, <blank>, etc).
- Top area for misc info that can be really long (file, note and render date).
- Bottom area for more constantly changing but short ones (marker, SMPTE,
frame, camera and scene).
- Only render date moves a line (when note field is not used), and frame one
moves if no SMPTE (still in same line, so no big jump), for extra visual
stability (marker is fixed, assuming most people would show frame and or
SMPTE).
- ISO 8601 date format for render date, localization independant.
Comparision images:
http://www.infernal-iceberg.com/blender/stamp-original.png
http://www.infernal-iceberg.com/blender/stamp-cleanup.png
2007-10-24 00:51:50 +02:00
|
|
|
}
|
2007-10-20 18:17:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-28 23:27:07 +01:00
|
|
|
if (rectf) {
|
2012-08-13 00:50:21 +02:00
|
|
|
float col_conv[4];
|
2007-10-28 23:27:07 +01:00
|
|
|
float *pixel;
|
2012-08-13 00:50:21 +02:00
|
|
|
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 12:05:07 +02:00
|
|
|
if (display) {
|
|
|
|
copy_v4_v4(col_conv, col);
|
|
|
|
IMB_colormanagement_display_to_scene_linear_v3(col_conv, display);
|
2012-08-13 00:50:21 +02:00
|
|
|
}
|
|
|
|
else {
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 12:05:07 +02:00
|
|
|
srgb_to_linearrgb_v4(col_conv, col);
|
2012-08-13 00:50:21 +02:00
|
|
|
}
|
|
|
|
|
2012-05-08 13:48:19 +02:00
|
|
|
for (j = 0; j < y2 - y1; j++) {
|
|
|
|
for (i = 0; i < x2 - x1; i++) {
|
2007-10-28 23:27:07 +01:00
|
|
|
pixel = rectf + 4 * (((y1 + j) * width) + (x1 + i));
|
2011-03-27 19:12:59 +02:00
|
|
|
if (a == 1.0f) {
|
2012-08-13 00:50:21 +02:00
|
|
|
pixel[0] = col_conv[0];
|
|
|
|
pixel[1] = col_conv[1];
|
|
|
|
pixel[2] = col_conv[2];
|
2011-08-31 03:05:40 +02:00
|
|
|
pixel[3] = 1.0f;
|
2012-03-24 07:38:07 +01:00
|
|
|
}
|
|
|
|
else {
|
2011-08-31 03:05:40 +02:00
|
|
|
float alphatest;
|
2012-08-13 00:50:21 +02:00
|
|
|
pixel[0] = (col_conv[0] * a) + (pixel[0] * ai);
|
|
|
|
pixel[1] = (col_conv[1] * a) + (pixel[1] * ai);
|
|
|
|
pixel[2] = (col_conv[2] * a) + (pixel[2] * ai);
|
2012-05-08 13:48:19 +02:00
|
|
|
pixel[3] = (alphatest = (pixel[3] + a)) < 1.0f ? alphatest : 1.0f;
|
Patch by GSR #7628, I also added alpha for text background.
The list of changes (some are fixes):
- Properly horizontally centered tags in all fields (bug?).
- File area does not have trailing space and has leading "File " at
start instead (probably a bug).
- Small separation between to time related fields, space saving.
- Removed colons, for consistency and space saving again.
- Frame field is zero aligned for higher visual stability.
- Marker name shows a rarer name, "<none>" (using <> is typical for cases
in which there is nothing: <none>, <empty>, <blank>, etc).
- Top area for misc info that can be really long (file, note and render date).
- Bottom area for more constantly changing but short ones (marker, SMPTE,
frame, camera and scene).
- Only render date moves a line (when note field is not used), and frame one
moves if no SMPTE (still in same line, so no big jump), for extra visual
stability (marker is fixed, assuming most people would show frame and or
SMPTE).
- ISO 8601 date format for render date, localization independant.
Comparision images:
http://www.infernal-iceberg.com/blender/stamp-original.png
http://www.infernal-iceberg.com/blender/stamp-cleanup.png
2007-10-24 00:51:50 +02:00
|
|
|
}
|
2007-10-20 18:17:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-10-28 23:27:07 +01:00
|
|
|
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 12:05:07 +02:00
|
|
|
void IMB_rectfill_area(struct ImBuf *ibuf, const float col[4], int x1, int y1, int x2, int y2, struct ColorManagedDisplay *display)
|
2007-10-28 23:27:07 +01:00
|
|
|
{
|
|
|
|
if (!ibuf) return;
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 12:05:07 +02:00
|
|
|
buf_rectfill_area((unsigned char *) ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y, col, display,
|
2012-11-09 10:33:28 +01:00
|
|
|
x1, y1, x2, y2);
|
2007-10-28 23:27:07 +01:00
|
|
|
}
|
2011-06-15 03:56:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
void IMB_rectfill_alpha(ImBuf *ibuf, const float value)
|
|
|
|
{
|
|
|
|
int i;
|
2013-02-12 15:58:58 +01:00
|
|
|
|
2013-02-12 16:58:06 +01:00
|
|
|
if (ibuf->rect_float && (ibuf->channels == 4)) {
|
|
|
|
float *fbuf = ibuf->rect_float + 3;
|
2012-05-08 13:48:19 +02:00
|
|
|
for (i = ibuf->x * ibuf->y; i > 0; i--, fbuf += 4) { *fbuf = value; }
|
2011-06-15 03:56:49 +02:00
|
|
|
}
|
2013-02-12 15:58:58 +01:00
|
|
|
|
|
|
|
if (ibuf->rect) {
|
2012-05-08 13:48:19 +02:00
|
|
|
const unsigned char cvalue = value * 255;
|
|
|
|
unsigned char *cbuf = ((unsigned char *)ibuf->rect) + 3;
|
|
|
|
for (i = ibuf->x * ibuf->y; i > 0; i--, cbuf += 4) { *cbuf = cvalue; }
|
2011-06-15 03:56:49 +02:00
|
|
|
}
|
|
|
|
}
|