chalk

kis_random_accessor.cpp
1/*
2 * This file is part of the Chalk project
3 *
4 * Copyright (c) 2006 Cyrille Berger <cberger@cberger.net>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20#include "kis_random_accessor.h"
21
22#include "kis_tiled_random_accessor.h"
23
24KisRandomAccessor::KisRandomAccessor(KisTiledDataManager *ktm, TQ_INT32 x, TQ_INT32 y, TQ_INT32 offsetx, TQ_INT32 offsety, bool writable) : m_offsetx(offsetx), m_offsety(offsety)
25{
26 m_accessor = new KisTiledRandomAccessor(ktm, x, y, writable);
27}
28
29KisRandomAccessor::KisRandomAccessor(const KisRandomAccessor& rhs) {
30 m_accessor = rhs.m_accessor;
31}
32
33KisRandomAccessor::~KisRandomAccessor()
34{
35
36}
37
38void KisRandomAccessor::moveTo(TQ_INT32 x, TQ_INT32 y)
39{
40 m_accessor->moveTo(x - m_offsetx, y - m_offsety);
41}
42
43TQ_UINT8* KisRandomAccessor::rawData() const
44{
45 return m_accessor->rawData();
46}
47
48const TQ_UINT8* KisRandomAccessor::oldRawData() const
49{
50 return m_accessor->oldRawData();
51}
52
53KisRandomAccessorPixel::KisRandomAccessorPixel(KisTiledDataManager *ktm, KisTiledDataManager *ktmselect, TQ_INT32 x, TQ_INT32 y, TQ_INT32 offsetx, TQ_INT32 offsety, bool writable) :
54 KisRandomAccessor( ktm, x, y, offsetx, offsety, writable),
55 KisRandomAccessorPixelTrait( this, (ktmselect) ? new KisRandomAccessor(ktm, x, y, offsetx, offsety, false) : 0 )
56{
57
58}