Commit 67a710d0 authored by Cyrille Berger's avatar Cyrille Berger

share some constants between traits and colorspace

svn path=/trunk/koffice/; revision=621736
parent 9a9d1b1d
......@@ -31,6 +31,7 @@
#include <kactioncollection.h>
#include <KoColorSpaceRegistry.h>
#include <KoColorSpaceTraits.h>
#include "kis_config.h"
#include "kis_cursor.h"
......@@ -54,7 +55,7 @@ K_EXPORT_COMPONENT_FACTORY( kritabracketing2hdr, Bracketing2HDRPluginFactory( "k
Bracketing2HDRPlugin::Bracketing2HDRPlugin(QObject *parent, const QStringList &)
: KParts::Plugin(parent), m_wdgBracketing2HDR(0),
m_responseType(RESPONSE_LINEAR), m_bitDepth(8), m_numberOfInputLevels(2 << (m_bitDepth-1))
m_responseType(RESPONSE_LINEAR), m_bitDepth(16), m_numberOfInputLevels(2 << (m_bitDepth-1))
{
if ( parent->inherits("KisView2") )
{
......@@ -203,7 +204,8 @@ void Bracketing2HDRPlugin::createHDRPaintDevice( KisPaintDeviceSP device )
m_images[k].it = new KisHLineConstIteratorPixel( m_images[k].device->createHLineConstIterator(0, 0, width) );
}
KisHLineIteratorPixel dstIt = device->createHLineIterator(0, 0, width);
QColor c;
// QColor c;
quint8* c = KoRgbU16Traits::allocate(1);
struct { double rsum, rdiv, gsum, gdiv, bsum, bdiv; } v;
// Loop over pixels
for(int j = 0; j < height; j++)
......@@ -215,13 +217,13 @@ void Bracketing2HDRPlugin::createHDRPaintDevice( KisPaintDeviceSP device )
for(int k = 0; k < m_images.size(); k++)
{
double coef = m_images[k].apexBrightness;
m_images[k].device->colorSpace()->toQColor(m_images[k].it->rawData(), &c);
v.rsum += m_intensityR[ c.red() ] * m_weights[ c.red() ] * coef ;
v.rdiv += m_weights[ c.red() ] * coef * coef ;
v.gsum += m_intensityG[ c.green() ] * m_weights[ c.green() ] * coef ;
v.gdiv += m_weights[ c.green() ] * coef * coef ;
v.bsum += m_intensityB[ c.blue() ] * m_weights[ c.blue() ] * coef ;
v.bdiv += m_weights[ c.blue() ] * coef * coef ;
m_images[k].device->colorSpace()->toRgbA16(m_images[k].it->rawData(), c, 1);
v.rsum += m_intensityR[ KoRgbU16Traits::red(c) ] * m_weights[ KoRgbU16Traits::red(c) ] * coef ;
v.rdiv += m_weights[ KoRgbU16Traits::red(c) ] * coef * coef ;
v.gsum += m_intensityG[ KoRgbU16Traits::green(c) ] * m_weights[ KoRgbU16Traits::green(c) ] * coef ;
v.gdiv += m_weights[ KoRgbU16Traits::green(c) ] * coef * coef ;
v.bsum += m_intensityB[ KoRgbU16Traits::blue(c) ] * m_weights[ KoRgbU16Traits::blue(c) ] * coef ;
v.bdiv += m_weights[ KoRgbU16Traits::blue(c) ] * coef * coef ;
++(*m_images[k].it);
}
float* pixelData = reinterpret_cast<float*>(dstIt.rawData());
......@@ -284,6 +286,7 @@ void Bracketing2HDRPlugin::computeCameraResponse()
kError() << "NOT IMPLEMENTED YET !" << endl;
Q_ASSERT(false);
}
return ;
// Now optimize the camera response
// Create a temporary paint device and fill it with the current value
KoColorSpace* cs = KoColorSpaceRegistry::instance()->colorSpace("RGBAF32", 0);
......
......@@ -31,6 +31,7 @@
#include <q3valuevector.h>
#include <q3valuelist.h>
#include "KoColorSpaceConstants.h"
#include <KoChannelInfo.h>
#include <KoID.h>
#include <koffice_export.h>
......@@ -42,9 +43,6 @@ class KoColorTransformation;
class KisMathToolbox;
class KisFilter;
const quint8 OPACITY_TRANSPARENT = 0;
const quint8 OPACITY_OPAQUE = UCHAR_MAX;
enum ColorSpaceIndependence {
FULLY_INDEPENDENT,
TO_LAB16,
......
......@@ -23,6 +23,7 @@
#include <klocale.h>
#include <KoColorSpace.h>
#include "KoColorSpaceConstants.h"
#include <KoColorSpaceMaths.h>
#include <KoIntegerMaths.h>
#include "KoCompositeOp.h"
......
/*
* Copyright (c) 2006 Cyrille Berger <cberger@cberger.bet
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef _KO_COLOR_SPACE_CONSTANTS_H_
#define _KO_COLOR_SPACE_CONSTANTS_H_
// TODO: find a better place or way to define those stuff
const quint8 OPACITY_TRANSPARENT = 0;
const quint8 OPACITY_OPAQUE = UCHAR_MAX;
#endif
......@@ -20,6 +20,9 @@
#ifndef _KO_COLORSPACE_TRAITS_H_
#define _KO_COLORSPACE_TRAITS_H_
#include "KoColorSpaceConstants.h"
#include "KoColorSpaceMaths.h"
/**
* This class is the base class to define the main characteristics of a colorspace
* which inherits KoColorSpaceAbstract.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment