2
* Copyright (c) 2008,2009 Lukáš Tvrdý <lukast.dev@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_chalk_paintop.h"
20
#include "kis_chalk_paintop_settings.h"
26
#include <KoColorSpace.h>
28
#include <kis_image.h>
29
#include <kis_debug.h>
31
#include <kis_global.h>
32
#include <kis_paint_device.h>
33
#include <kis_painter.h>
34
#include <kis_types.h>
35
#include <kis_paintop.h>
36
#include <kis_paint_information.h>
38
#include <kis_pressure_opacity_option.h>
40
KisChalkPaintOp::KisChalkPaintOp(const KisChalkPaintOpSettings *settings, KisPainter * painter, KisImageWSP image)
42
, m_settings(settings)
45
m_chalkBrush = new ChalkBrush(settings);
47
m_opacityOption.readOptionSetting(settings);
48
m_opacityOption.sensor()->reset();
51
KisChalkPaintOp::~KisChalkPaintOp()
56
double KisChalkPaintOp::paintAt(const KisPaintInformation& info)
58
if (!painter()) return 1;
61
m_dab = new KisPaintDevice(painter()->device()->colorSpace());
71
quint8 origOpacity = m_opacityOption.apply(painter(), info);
72
m_chalkBrush->paint(m_dab, x1, y1, painter()->paintColor());
74
QRect rc = m_dab->extent();
76
painter()->bitBlt(rc.x(), rc.y(), m_dab, rc.x(), rc.y(), rc.width(), rc.height());
77
painter()->setOpacity(origOpacity);