KoColorSpace.cpp 1.51 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 *  Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
 *
 *  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 of the License, or
 *  (at your option) any later version.
 *
 *  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, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

19
#include "KoColorSpace.h"
20

21
KoColorSpace::KoColorSpace(const KoID &id, KoColorSpaceFactoryRegistry * parent)
22 23
    : m_id(id)
    , m_parent( parent )
24
{
25
    m_dcop = 0;
26 27
}

28
KoColorSpace::~KoColorSpace()
29
{
30 31 32
    delete m_dcop;
}

33
quint8 *KoColorSpace::allocPixelBuffer(quint32 numPixels) const
34 35 36 37
{
    return new quint8[pixelSize()*numPixels];
}

38
bool KoColorSpace::convertPixelsTo(const quint8 * src,
39
					    quint8 * dst,
40
					    KoColorSpace * dstColorSpace,
41 42 43 44 45 46 47 48 49 50 51 52 53
					    quint32 numPixels,
					    qint32 renderingIntent)
{
    // 4 channels: labA, 2 bytes per lab channel
    quint8 *pixels = new quint8[2*4*numPixels];

    toLabA16(src, pixels,numPixels);
    dstColorSpace->fromLabA16(pixels, dst,numPixels);

    delete [] pixels;

    return true;
}