~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to plugins/colorengines/lcms/colorspaces/gray_u8/GrayU8ColorSpace.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-21 15:36:35 UTC
  • mfrom: (1.4.1 upstream) (60.2.11 maverick)
  • Revision ID: james.westby@ubuntu.com-20100921153635-6tejqkiro2u21ydi
Tags: 1:2.2.2-0ubuntu3
Add kubuntu_03_fix-crash-on-closing-sqlite-connection-2.2.2.diff and
kubuntu_04_support-large-memo-values-for-msaccess-2.2.2.diff as
recommended by upstream http://kexi-
project.org/wiki/wikiview/index.php@Kexi2.2_Patches.html#sqlite_stab
ility

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (c) 2006 Cyrille Berger <cberger@cberger.net>
 
3
 *
 
4
 *  This program is free software; you can redistribute it and/or modify
 
5
 *  it under the terms of the GNU General Public License as published by
 
6
 *  the Free Software Foundation; either version 2 of the License, or
 
7
 *  (at your option) any later version.
 
8
 *
 
9
 *  This program is distributed in the hope that it will be useful,
 
10
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 *  GNU General Public License for more details.
 
13
 *
 
14
 *  You should have received a copy of the GNU General Public License
 
15
 *  along with this program; if not, write to the Free Software
 
16
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
17
 */
 
18
#include <GrayU8ColorSpace.h>
 
19
 
 
20
#include <QDomElement>
 
21
 
 
22
#include <kdebug.h>
 
23
#include <klocale.h>
 
24
 
 
25
#include <KoIntegerMaths.h>
 
26
#include <KoColorSpaceRegistry.h>
 
27
 
 
28
#include "compositeops/KoCompositeOpOver.h"
 
29
#include "compositeops/KoCompositeOpErase.h"
 
30
#include "compositeops/KoCompositeOpMultiply.h"
 
31
#include "compositeops/KoCompositeOpDivide.h"
 
32
#include "compositeops/KoCompositeOpBurn.h"
 
33
 
 
34
KoGrayAU8ColorSpace ::KoGrayAU8ColorSpace(KoColorProfile *p) :
 
35
        LcmsColorSpace<GrayAU8Traits>("GRAYA", i18n("Grayscale (8-bit integer/channel)"), TYPE_GRAYA_8, icSigGrayData, p)
 
36
{
 
37
    addChannel(new KoChannelInfo(i18n("Gray"), 0, 0, KoChannelInfo::COLOR, KoChannelInfo::UINT8));
 
38
    addChannel(new KoChannelInfo(i18n("Alpha"), 1, 1, KoChannelInfo::ALPHA, KoChannelInfo::UINT8));
 
39
 
 
40
    init();
 
41
 
 
42
    addCompositeOp(new KoCompositeOpOver<GrayAU8Traits>(this));
 
43
    addCompositeOp(new KoCompositeOpErase<GrayAU8Traits>(this));
 
44
    addCompositeOp(new KoCompositeOpMultiply<GrayAU8Traits>(this));
 
45
    addCompositeOp(new KoCompositeOpDivide<GrayAU8Traits>(this));
 
46
    addCompositeOp(new KoCompositeOpBurn<GrayAU8Traits>(this));
 
47
}
 
48
 
 
49
KoColorSpace* KoGrayAU8ColorSpace::clone() const
 
50
{
 
51
    return new KoGrayAU8ColorSpace(profile()->clone());
 
52
}
 
53
 
 
54
void KoGrayAU8ColorSpace::colorToXML(const quint8* pixel, QDomDocument& doc, QDomElement& colorElt) const
 
55
{
 
56
    const GrayAU8Traits::channels_type* p = reinterpret_cast<const GrayAU8Traits::channels_type*>(pixel);
 
57
    QDomElement labElt = doc.createElement("Gray");
 
58
    labElt.setAttribute("g", KoColorSpaceMaths< GrayAU8Traits::channels_type, qreal>::scaleToA(p[0]));
 
59
    labElt.setAttribute("space", profile()->name());
 
60
    colorElt.appendChild(labElt);
 
61
}
 
62
 
 
63
void KoGrayAU8ColorSpace::colorFromXML(quint8* pixel, const QDomElement& elt) const
 
64
{
 
65
    GrayAU8Traits::channels_type* p = reinterpret_cast<GrayAU8Traits::channels_type*>(pixel);
 
66
    p[0] = KoColorSpaceMaths< qreal, GrayAU8Traits::channels_type >::scaleToA(elt.attribute("g").toDouble());
 
67
    p[1] = KoColorSpaceMathsTraits<quint8>::max;
 
68
}
 
69