summaryrefslogtreecommitdiffstats
path: root/chalk/colorspaces/wetsticky/kis_wet_sticky_colorspace.cpp
blob: 3e47114aef57da28a61f7f3a0cfc951f7f09b8a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
/*
 *  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.
 */

#include <limits.h>
#include <stdlib.h>

#include <config.h>
#include LCMS_HEADER

#include <tqimage.h>

#include <tdelocale.h>
#include <kdebug.h>

#include "kis_color_conversions.h"
#include "kis_abstract_colorspace.h"
#include "kis_colorspace_registry.h"
#include "kis_image.h"
#include "kis_wet_sticky_colorspace.h"
#include "kis_integer_maths.h"
#include "kis_types.h"
#include "kis_channelinfo.h"

#define NOWSDEBUG

using namespace WetAndSticky;

enum WetStickyChannelIndex {
    BLUE_CHANNEL_INDEX,
    GREEN_CHANNEL_INDEX,
    RED_CHANNEL_INDEX,
    ALPHA_CHANNEL_INDEX,
    HUE_CHANNEL_INDEX,
    SATURATION_CHANNEL_INDEX,
    LIGHTNESS_CHANNEL_INDEX,
    LIQUID_CONTENT_CHANNEL_INDEX,
    DRYING_RATE_CHANNEL_INDEX,
    MISCIBILITY_CHANNEL_INDEX,
    GRAVITATIONAL_DIRECTION_INDEX,
    GRAVITATIONAL_STRENGTH_CHANNEL_INDEX,
    ABSORBANCY_CHANNEL_INDEX,
    PAINT_VOLUME_CHANNEL_INDEX
};

KisWetStickyColorSpace::KisWetStickyColorSpace() :
    KisAbstractColorSpace(KisID("W&S", i18n("Wet & Sticky")), 0, icMaxEnumData)
{
    TQ_INT32 pos = 0;

    // Basic representational definition
    m_channels.push_back(new KisChannelInfo(i18n("Blue"), "B", pos, COLOR, 1));
    m_channels.push_back(new KisChannelInfo(i18n("Green"), "G", ++pos, COLOR, 1));
    m_channels.push_back(new KisChannelInfo(i18n("Red"), "R", ++pos, COLOR, 1));
    m_channels.push_back(new KisChannelInfo(i18n("Alpha"), "A", ++pos, ALPHA, 1));

    // Paint definition
    m_channels.push_back(new KisChannelInfo(i18n("Hue"), "H", ++pos, COLOR, sizeof(float)));
    m_channels.push_back(new KisChannelInfo(i18n("Saturation"), "S", pos+=sizeof(float) , COLOR, sizeof(float)));
    m_channels.push_back(new KisChannelInfo(i18n("Lightness"), "L", pos+=sizeof(float), COLOR, sizeof(float)));

    m_channels.push_back(new KisChannelInfo(i18n("Liquid Content"), "Q", pos+=sizeof(float), SUBSTANCE, 1));
    m_channels.push_back(new KisChannelInfo(i18n("Drying Rate"), "D", ++pos, SUBSTANCE, 1));
    m_channels.push_back(new KisChannelInfo(i18n("Miscibility"), "M", ++pos, SUBSTANCE, 1));

    // Substrate definition
    m_channels.push_back(new KisChannelInfo(i18n("Gravitational Direction"), "Gd", ++pos, SUBSTRATE, sizeof(enumDirection)));
    m_channels.push_back(new KisChannelInfo(i18n("Gravitational Strength"), "Gs", pos+=sizeof(enumDirection), SUBSTRATE, 1));

    m_channels.push_back(new KisChannelInfo(i18n("Absorbency"), "Ad", ++pos, SUBSTRATE, 1));
    m_channels.push_back(new KisChannelInfo(i18n("Paint Volume"), "V", ++pos, SUBSTANCE, 1));

    m_alphaPos = 3;
    m_alphaSize = 1;
    setDefaultProfile( 0 );

#ifdef WSDEBUG
    TQValueVector<KisChannelInfo *>_it it;
    int i = 0;
    for (it = m_channels.begin(); it != m_channels.end(); ++it)
    {
        KisChannelInfo * ch = (*it);
        kdDebug(DBG_AREA_CMS) << "Channel: " << ch->name() << ", " << ch->pos() << ", " << i << "\n";
        ++i;
    }

    kdDebug(DBG_AREA_CMS) << "Size of cell: " << sizeof(CELL) << "\n";
#endif
}


KisWetStickyColorSpace::~KisWetStickyColorSpace()
{
}

void KisWetStickyColorSpace::fromTQColor(const TQColor& c, TQ_UINT8 *dst, KisProfile *  profile)
{
    CELL_PTR p = (CELL_PTR) dst;
    TQ_UINT8 r, g, b;

    r = c.red();
    g = c.green();
    b = c.blue();

    p -> red = r;
    p -> green = g;
    p -> blue = b;
    p -> alpha = OPACITY_OPAQUE;

    rgb_to_hls(r, g, b, &p->hue, &p->lightness, &p->saturation);

    p -> liquid_content = 0;
    p -> drying_rate = 0;
    p -> miscibility = 0;

    p -> direction = DOWN;
    p -> strength = 10;

    p -> absorbancy = 10;
    p -> volume = 0;

#ifdef WSDEBUG
    kdDebug(DBG_AREA_CMS) << "qcolor: "
        << " r: " << c.red() << " b: " << c.blue() << " g: " << c.red()
        << " native color: (" << TQString().setNum(p->red) << ", "
                              << TQString().setNum(p->green) << ", "
                              << TQString().setNum(p->blue) << ", "
                              << TQString().setNum(p->alpha) << ") "
        << ", hls: (" << p->hue << ", "
                      << p->lightness << ", "
                      << p->saturation << ")\n";
#endif
}

void KisWetStickyColorSpace::fromTQColor(const TQColor& c, TQ_UINT8 opacity, TQ_UINT8 *dst, KisProfile *  profile)
{
    CELL_PTR p = (CELL_PTR) dst;
    TQ_UINT8 r, g, b;

    r = c.red();
    g = c.green();
    b = c.blue();

    p -> red = r;
    p -> green = g;
    p -> blue = b;
    p -> alpha = opacity;
    rgb_to_hls(r, g, b, &p -> hue, &p -> lightness, &p -> saturation);

    p ->liquid_content = 0;
    p ->drying_rate = 0;
    p ->miscibility = 0;

    p -> direction = DOWN;
    p -> strength = 10;

    p -> absorbancy = 10;
    p -> volume = 0;

#ifdef WSDEBUG
    kdDebug(DBG_AREA_CMS) << "qcolor: "
        << " r: " << c.red() << " b: " << c.blue() << " g: " << c.red() << " opacity: " << opacity
        << " native color: (" << TQString().setNum(p->red) << ", "
                              << TQString().setNum(p->green) << ", "
                              << TQString().setNum(p->blue) << ", "
                              << TQString().setNum(p->alpha) << ") "
        << ", hls: (" << p->hue << ", "
                      << p->lightness << ", "
                      << p->saturation << ")\n";
#endif
}

void KisWetStickyColorSpace::toTQColor(const TQ_UINT8 *src, TQColor *c, KisProfile *  profile)
{
    CELL_PTR p = (CELL_PTR) src;

    c -> setRgb(p -> red,
            p -> green,
            p -> blue);
#ifdef WSDEBUG
    kdDebug(DBG_AREA_CMS) << "Created qcolor from wet & sticky: " << " r: " << c->red() << " b: " << c->blue() << " g: " << c->red() << "\n";
#endif
}

void KisWetStickyColorSpace::toTQColor(const TQ_UINT8 *src, TQColor *c, TQ_UINT8 *opacity, KisProfile *  profile)
{

    CELL_PTR p = (CELL_PTR) src;

    c -> setRgb(p -> red,
            p -> green,
            p -> blue);

    *opacity = p -> alpha;
#ifdef WSDEBUG
    kdDebug(DBG_AREA_CMS) << "Created qcolor from wet & sticky: " << " r: " << c->red() << " b: " << c->blue() << " g: " << c->red() << "\n";
#endif
}



KisPixelRO KisWetStickyColorSpace::toKisPixelRO(const TQ_UINT8 *src, KisProfile *  profile)
{
    return KisPixelRO (src, src, this, profile);
}

KisPixel KisWetStickyColorSpace::toKisPixel(TQ_UINT8 *src, KisProfile *  profile)
{
    return KisPixel (src, src, this, profile);
}

void KisWetStickyColorSpace::mixColors(const TQ_UINT8 **colors, const TQ_UINT8 *weights, TQ_UINT32 nColors, TQ_UINT8 *dst) const
{
}

TQ_UINT8 KisWetStickyColorSpace::getAlpha(const TQ_UINT8 *pixel) const
{
    return ((CELL_PTR)pixel)->alpha;
}

void KisWetStickyColorSpace::setAlpha(TQ_UINT8 * pixels, TQ_UINT8 alpha, TQ_INT32 nPixels) const
{
    while (nPixels > 0) {
        ((CELL_PTR)pixels)->alpha = alpha;
        --nPixels;
        pixels+=pixelSize();
    }
}

void KisWetStickyColorSpace::applyAlphaU8Mask(TQ_UINT8 * pixels, TQ_UINT8 * alpha, TQ_INT32 nPixels)
{
}

void KisWetStickyColorSpace::applyInverseAlphaU8Mask(TQ_UINT8 * pixels, TQ_UINT8 * alpha, TQ_INT32 nPixels)
{
}

TQ_UINT8 KisWetStickyColorSpace::scaleToU8(const TQ_UINT8 * srcPixel, TQ_INT32 channelPos)
{
    return 0;
}

TQ_UINT16 KisWetStickyColorSpace::scaleToU16(const TQ_UINT8 * srcPixel, TQ_INT32 channelPos)
{
    return 0;
}


TQValueVector<KisChannelInfo *> KisWetStickyColorSpace::channels() const
{
    return m_channels;
}

bool KisWetStickyColorSpace::hasAlpha() const
{
    return true;
}

TQ_INT32 KisWetStickyColorSpace::nChannels() const
{
    return 14;
}

TQ_INT32 KisWetStickyColorSpace::nColorChannels() const
{
    return 3;
}

TQ_INT32 KisWetStickyColorSpace::nSubstanceChannels() const
{
    return 4;

}

TQ_INT32 KisWetStickyColorSpace::pixelSize() const
{
    return sizeof(CELL);
}


TQImage KisWetStickyColorSpace::convertToTQImage(const TQ_UINT8 *data, TQ_INT32 width, TQ_INT32 height,
                           KisProfile *  /*srcProfile*/, KisProfile *  /*dstProfile*/,
                           TQ_INT32 /*renderingIntent*/, float /*exposure*/)
{

    TQImage img(width, height, 32, 0, TQImage::LittleEndian);

    TQ_INT32 i = 0;
    uchar *j = img.bits();

    CELL_PTR p = (CELL_PTR) data;

    while ( i < width * height) {

        const TQ_UINT8 PIXEL_BLUE = 0;
        const TQ_UINT8 PIXEL_GREEN = 1;
        const TQ_UINT8 PIXEL_RED = 2;
        const TQ_UINT8 PIXEL_ALPHA = 3;

        *( j + PIXEL_ALPHA ) = p -> alpha;
        *( j + PIXEL_RED )   = p -> red;
        *( j + PIXEL_GREEN ) = p -> green;
        *( j + PIXEL_BLUE )  = p -> blue;

        p++;
        i++;
        j += 4; // Because we're hard-coded 32 bits deep, 4 bytes
    }
    return img;
}

bool KisWetStickyColorSpace::convertPixelsTo(const TQ_UINT8 * src, KisProfile *  /*srcProfile*/,
                         TQ_UINT8 * dst, KisAbstractColorSpace * dstColorSpace, KisProfile *  dstProfile,
                         TQ_UINT32 numPixels,
                         TQ_INT32 /*renderingIntent*/)
{
    TQ_INT32 dSize = dstColorSpace -> pixelSize();
    TQ_INT32 sSize = pixelSize();

    TQ_UINT32 j = 0;
    TQ_UINT32 i = 0;
    TQColor c;
    CELL_PTR cp;
    while ( i < numPixels ) {
        cp = (CELL_PTR) (src + i);

        c.setRgb(cp -> red,
             cp -> green,
             cp -> blue);

        dstColorSpace -> fromTQColor(c, cp -> alpha, (dst + j), dstProfile);

        i += sSize;
        j += dSize;

    }
    return true;

}

void KisWetStickyColorSpace::bitBlt(TQ_UINT8 *dst,
                      TQ_INT32 dstRowStride,
                      const TQ_UINT8 *src,
                      TQ_INT32 srcRowStride,
                      const TQ_UINT8 *mask,
                      TQ_INT32 maskRowStride,
                      TQ_UINT8 opacity,
                      TQ_INT32 rows,
                      TQ_INT32 cols,
                      const KisCompositeOp& op)
{
    switch (op.op()) {
    case COMPOSITE_UNDEF:
        // Undefined == no composition
        break;
    case COMPOSITE_OVER:
        compositeOver(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
        break;
    case COMPOSITE_COPY:
    default:
        compositeCopy(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
        break;
    }

}


void KisWetStickyColorSpace::compositeOver(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStride, const TQ_UINT8 *srcRowStart, TQ_INT32 srcRowStride, const TQ_UINT8 *maskRowStart, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 numColumns, TQ_UINT8 opacity)
{
    // XXX: This is basically the same as with rgb and used to composite layers for  Composition for
    //      painting works differently


    while (rows > 0) {

        const TQ_UINT8 *src = srcRowStart;
        TQ_UINT8 *dst = dstRowStart;
        const TQ_UINT8 *mask = maskRowStart;

        TQ_INT32 columns = numColumns;

        while (columns > 0) {

            CELL_PTR dstCell = (CELL_PTR) dst;
            CELL_PTR srcCell = (CELL_PTR) src;

#ifdef WSDEBUG
            kdDebug(DBG_AREA_CMS) << "Source: " << rows << ", " << columns << " color: " <<
                srcCell->red << ", " << srcCell->blue << ", " << srcCell->green << ", " << srcCell->alpha << ", " << srcCell->volume << "\n";


            kdDebug(DBG_AREA_CMS) << "Destination: "  << rows << ", " << columns << " color: " <<
                dstCell->red << ", " << dstCell->blue << ", " << dstCell->green << ", " << dstCell->alpha << ", " << dstCell->volume << "\n";

#endif

            TQ_UINT8 srcAlpha = srcCell->alpha;

            // apply the alphamask
            if(mask != 0)
            {
                if(*mask != OPACITY_OPAQUE)
                    srcAlpha = UINT8_MULT(srcAlpha, *mask);
                mask++;
            }

            if (srcAlpha != OPACITY_TRANSPARENT) {

                if (opacity != OPACITY_OPAQUE) {
                    srcAlpha = UINT8_MULT(srcCell->alpha, opacity);
                }

                if (srcAlpha == OPACITY_OPAQUE) {
                    memcpy(dst, src, 3); // XXX: First three bytes for rgb?
                } else {
                    TQ_UINT8 dstAlpha = dstCell->alpha;

                    TQ_UINT8 srcBlend;

                    if (dstAlpha == OPACITY_OPAQUE) {
                        srcBlend = srcAlpha;
                    } else {
                        TQ_UINT8 newAlpha = dstAlpha + UINT8_MULT(OPACITY_OPAQUE - dstAlpha, srcAlpha);
                        dstCell->alpha = newAlpha;

                        if (newAlpha != 0) {
                            srcBlend = UINT8_DIVIDE(srcAlpha, newAlpha);
                        } else {
                            srcBlend = srcAlpha;
                        }
                    }

                    if (srcBlend == OPACITY_OPAQUE) {
                        memcpy(dst, src, 3); //XXX: First three bytes for rgb?
                    } else {
                        dstCell->red = UINT8_BLEND(srcCell->red, dstCell->red, srcBlend);
                        dstCell->green = UINT8_BLEND(srcCell->green, dstCell->green, srcBlend);
                        dstCell->blue = UINT8_BLEND(srcCell->blue, dstCell->blue, srcBlend);
                    }
                }
            }
            columns--;
            src += sizeof(CELL);
            dst += sizeof(CELL);
        }
        rows--;
        srcRowStart += srcRowStride;
        dstRowStart += dstRowStride;

        if(maskRowStart)
            maskRowStart += maskRowStride;
    }

}

void KisWetStickyColorSpace::compositeCopy(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *mask, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT8 opacity)
{
    TQ_INT32 linesize = sizeof(CELL) * columns;
    TQ_UINT8 *d;
    const TQ_UINT8 *s;
    d = dst;
    s = src;

    while (rows-- > 0) {
        memcpy(d, s, linesize);
        d += dstRowStride;
        s += srcRowStride;
    }

}


KisCompositeOpList KisWetStickyColorSpace::userVisiblecompositeOps() const
{
    KisCompositeOpList list;

    list.append(KisCompositeOp(COMPOSITE_OVER));

    return list;
}

TQString KisWetStickyColorSpace::channelValueText(const TQ_UINT8 *U8_pixel, TQ_UINT32 channelIndex) const
{
    Q_ASSERT(channelIndex < nChannels());
    const CELL *pixel = reinterpret_cast<const CELL *>(U8_pixel);

    switch (channelIndex) {
    case BLUE_CHANNEL_INDEX:
        return TQString().setNum(pixel -> blue);
    case GREEN_CHANNEL_INDEX:
        return TQString().setNum(pixel -> green);
    case RED_CHANNEL_INDEX:
        return TQString().setNum(pixel -> red);
    case ALPHA_CHANNEL_INDEX:
        return TQString().setNum(pixel -> alpha);
    case HUE_CHANNEL_INDEX:
        return TQString().setNum(pixel -> hue);
    case SATURATION_CHANNEL_INDEX:
        return TQString().setNum(pixel -> saturation);
    case LIGHTNESS_CHANNEL_INDEX:
        return TQString().setNum(pixel -> lightness);
    case LIQUID_CONTENT_CHANNEL_INDEX:
        return TQString().setNum(pixel -> liquid_content);
    case DRYING_RATE_CHANNEL_INDEX:
        return TQString().setNum(pixel -> drying_rate);
    case MISCIBILITY_CHANNEL_INDEX:
        return TQString().setNum(pixel -> miscibility);
    case GRAVITATIONAL_DIRECTION_INDEX:
        {
            switch (pixel -> direction) {
            case UP:
                return i18n("Up");
            case DOWN:
                return i18n("Down");
            case LEFT:
                return i18n("Left");
            case RIGHT:
                return i18n("Right");
            default:
                Q_ASSERT(false);
                return TQString();
            }
        }
    case GRAVITATIONAL_STRENGTH_CHANNEL_INDEX:
        return TQString().setNum(pixel -> strength);
    case ABSORBANCY_CHANNEL_INDEX:
        return TQString().setNum(pixel -> absorbancy);
    case PAINT_VOLUME_CHANNEL_INDEX:
        return TQString().setNum(pixel -> volume);
    default:
        Q_ASSERT(false);
        return TQString();
    }
}

TQString KisWetStickyColorSpace::normalisedChannelValueText(const TQ_UINT8 *U8_pixel, TQ_UINT32 channelIndex) const
{
    Q_ASSERT(channelIndex < nChannels());
    const CELL *pixel = reinterpret_cast<const CELL *>(U8_pixel);

    //XXX: Are these right?

    switch (channelIndex) {
    case BLUE_CHANNEL_INDEX:
        return TQString().setNum(static_cast<float>(pixel -> blue) / UINT8_MAX);
    case GREEN_CHANNEL_INDEX:
        return TQString().setNum(static_cast<float>(pixel -> green) / UINT8_MAX);
    case RED_CHANNEL_INDEX:
        return TQString().setNum(static_cast<float>(pixel -> red) / UINT8_MAX);
    case ALPHA_CHANNEL_INDEX:
        return TQString().setNum(static_cast<float>(pixel -> alpha) / UINT8_MAX);
    case HUE_CHANNEL_INDEX:
        return TQString().setNum(pixel -> hue);
    case SATURATION_CHANNEL_INDEX:
        return TQString().setNum(pixel -> saturation);
    case LIGHTNESS_CHANNEL_INDEX:
        return TQString().setNum(pixel -> lightness);
    case LIQUID_CONTENT_CHANNEL_INDEX:
        return TQString().setNum(static_cast<float>(pixel -> liquid_content) / UINT8_MAX);
    case DRYING_RATE_CHANNEL_INDEX:
        return TQString().setNum(static_cast<float>(pixel -> drying_rate) / UINT8_MAX);
    case MISCIBILITY_CHANNEL_INDEX:
        return TQString().setNum(static_cast<float>(pixel -> miscibility) / UINT8_MAX);
    case GRAVITATIONAL_DIRECTION_INDEX:
        {
            switch (pixel -> direction) {
            case UP:
                return i18n("Up");
            case DOWN:
                return i18n("Down");
            case LEFT:
                return i18n("Left");
            case RIGHT:
                return i18n("Right");
            default:
                Q_ASSERT(false);
                return TQString();
            }
        }
    case GRAVITATIONAL_STRENGTH_CHANNEL_INDEX:
        return TQString().setNum(static_cast<float>(pixel -> strength) / UINT8_MAX);
    case ABSORBANCY_CHANNEL_INDEX:
        return TQString().setNum(static_cast<float>(pixel -> absorbancy) / UINT8_MAX);
    case PAINT_VOLUME_CHANNEL_INDEX:
        return TQString().setNum(static_cast<float>(pixel -> volume) / UINT8_MAX);
    default:
        Q_ASSERT(false);
        return TQString();
    }
}