~smartboyhw/ubuntu/raring/calligra/2.6.0-0ubuntu1

« back to all changes in this revision

Viewing changes to krita/image/kis_random_sub_accessor.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-09-17 14:19:19 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20120917141919-wz02w3j1br9fdnle
Tags: 1:2.5.2-0ubuntu1
* New upstream bugfix release
* Remove kubuntu_01_arm_fixes.diff now upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
#include "kis_paint_device.h"
28
28
 
29
 
KisRandomSubAccessor::KisRandomSubAccessor(const KisPaintDeviceSP device)
 
29
KisRandomSubAccessor::KisRandomSubAccessor(KisPaintDeviceSP device)
30
30
        : m_device(device)
31
31
        , m_currentPoint(0, 0)
32
 
        , m_randomAccessor(device->createRandomConstAccessorNG(0, 0))
 
32
        , m_randomAccessor(device->createRandomAccessorNG(0, 0))
33
33
{
34
34
}
35
35
 
63
63
    pixels[3] = m_randomAccessor->oldRawData();
64
64
    m_device->colorSpace()->mixColorsOp()->mixColors(pixels, weights, 4, dst);
65
65
}
 
66
 
 
67
 
 
68
void KisRandomSubAccessor::sampledRawData(quint8* dst)
 
69
{
 
70
    const quint8* pixels[4];
 
71
    qint16 weights[4];
 
72
    int x = (int)floor(m_currentPoint.x());
 
73
    int y = (int)floor(m_currentPoint.y());
 
74
    double hsub = m_currentPoint.x() - x;
 
75
    if (hsub < 0.0) hsub = 1.0 + hsub;
 
76
    double vsub = m_currentPoint.y() - y;
 
77
    if (vsub < 0.0) vsub = 1.0 + vsub;
 
78
    weights[0] = (int)round((1.0 - hsub) * (1.0 - vsub) * 255);
 
79
    m_randomAccessor->moveTo(x, y);
 
80
    pixels[0] = m_randomAccessor->rawData();
 
81
    weights[1] = (int)round((1.0 - vsub) * hsub * 255);
 
82
    m_randomAccessor->moveTo(x + 1, y);
 
83
    pixels[1] = m_randomAccessor->rawData();
 
84
    weights[2] = (int)round(vsub * (1.0 - hsub) * 255);
 
85
    m_randomAccessor->moveTo(x, y + 1);
 
86
    pixels[2] = m_randomAccessor->rawData();
 
87
    weights[3] = (int)round(hsub * vsub * 255);
 
88
    m_randomAccessor->moveTo(x + 1, y + 1);
 
89
    pixels[3] = m_randomAccessor->rawData();
 
90
    m_device->colorSpace()->mixColorsOp()->mixColors(pixels, weights, 4, dst);
 
91
}