2
* Copyright (c) 2010 Dmitry Kazakov <dimula73@gmail.com>
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.
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.
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.
19
#include "kis_abstract_compression.h"
21
KisAbstractCompression::KisAbstractCompression()
25
KisAbstractCompression::~KisAbstractCompression()
29
void KisAbstractCompression::adjustForDataSize(qint32 dataSize)
34
void KisAbstractCompression::linearizeColors(quint8 *input, quint8 *output,
35
qint32 dataSize, qint32 pixelSize)
37
quint8 *outputByte = output;
38
quint8 *lastByte = input + dataSize -1;
40
for(qint32 i = 0; i < pixelSize; i++) {
41
quint8 *inputByte = input + i;
42
while (inputByte <= lastByte) {
43
*outputByte = *inputByte;
50
void KisAbstractCompression::delinearizeColors(quint8 *input, quint8 *output,
51
qint32 dataSize, qint32 pixelSize)
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
61
quint8 *outputByte = output;
62
quint8 *lastByte = output + dataSize -1;
64
qint32 strideSize = dataSize / pixelSize;
65
quint8 *startByte = input;
67
while (outputByte <= lastByte) {
68
quint8 *inputByte = startByte;
70
for(qint32 i = 0; i < pixelSize; i++) {
71
*outputByte = *inputByte;
73
inputByte += strideSize;