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

« back to all changes in this revision

Viewing changes to krita/image/tiles3/swap/kis_abstract_compression.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-10-27 17:52:57 UTC
  • mfrom: (0.12.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101027175257-s04zqqk5bs8ckm9o
Tags: 1:2.2.83-0ubuntu1
* Merge with Debian git remaining changes:
 - Add build-deps on librcps-dev, opengtl-dev, libqtgtl-dev, freetds-dev,
   create-resources, libspnav-dev
 - Remove needless build-dep on libwv2-dev
 - koffice-libs recommends create-resources
 - krita recommends pstoedit
 - Keep our patches
* New upstream release 2.3 beta 3
  - Remove debian/patches fixed by upstream
  - Update install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (c) 2010 Dmitry Kazakov <dimula73@gmail.com>
 
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
 
 
19
#include "kis_abstract_compression.h"
 
20
 
 
21
KisAbstractCompression::KisAbstractCompression()
 
22
{
 
23
}
 
24
 
 
25
KisAbstractCompression::~KisAbstractCompression()
 
26
{
 
27
}
 
28
 
 
29
void KisAbstractCompression::adjustForDataSize(qint32 dataSize)
 
30
{
 
31
    Q_UNUSED(dataSize);
 
32
}
 
33
 
 
34
void KisAbstractCompression::linearizeColors(quint8 *input, quint8 *output,
 
35
                                             qint32 dataSize, qint32 pixelSize)
 
36
{
 
37
    quint8 *outputByte = output;
 
38
    quint8 *lastByte = input + dataSize -1;
 
39
 
 
40
    for(qint32 i = 0; i < pixelSize; i++) {
 
41
        quint8 *inputByte = input + i;
 
42
        while (inputByte <= lastByte) {
 
43
            *outputByte = *inputByte;
 
44
            outputByte++;
 
45
            inputByte+=pixelSize;
 
46
        }
 
47
    }
 
48
}
 
49
 
 
50
void KisAbstractCompression::delinearizeColors(quint8 *input, quint8 *output,
 
51
                                               qint32 dataSize, qint32 pixelSize)
 
52
{
 
53
    /**
 
54
     * In the beginning, i wrote "delinearization" in a way,
 
55
     * that looks like a "linearization", but it turned to be quite
 
56
     * inefficient. It seems like reading from random positions is
 
57
     * much faster than writing to random areas. So this version is
 
58
     * 13% faster.
 
59
     */
 
60
 
 
61
    quint8 *outputByte = output;
 
62
    quint8 *lastByte = output + dataSize -1;
 
63
 
 
64
    qint32 strideSize = dataSize / pixelSize;
 
65
    quint8 *startByte = input;
 
66
 
 
67
    while (outputByte <= lastByte) {
 
68
        quint8 *inputByte = startByte;
 
69
 
 
70
        for(qint32 i = 0; i < pixelSize; i++) {
 
71
            *outputByte = *inputByte;
 
72
            outputByte++;
 
73
            inputByte += strideSize;
 
74
        }
 
75
 
 
76
        startByte++;
 
77
    }
 
78
}