chalk

kis_paint_device_iface.cpp
1/*
2 * This file is part of the KDE project
3 *
4 * Copyright (C) 2005 Boudewijn Rempt <boud@valdyas.org>
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; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19*/
20#include <tdeapplication.h>
21
22#include <dcopclient.h>
23
24#include "kis_paint_device_iface.h"
25#include "kis_colorspace_iface.h"
26#include "kis_colorspace.h"
27
28#include "kis_paint_device.h"
29
30KisPaintDeviceIface::KisPaintDeviceIface( KisPaintDevice * parent )
31 : DCOPObject("paintdevice")
32{
33 m_parent = parent;
34}
35
36TQ_INT32 KisPaintDeviceIface::pixelSize() const
37{
38 return m_parent->pixelSize();
39}
40
41TQ_INT32 KisPaintDeviceIface::nChannels() const
42{
43 return m_parent->nChannels();
44}
45
46TQByteArray KisPaintDeviceIface::readBytes(TQ_INT32 x, TQ_INT32 y, TQ_INT32 w, TQ_INT32 h)
47{
48 TQByteArray b (w * h * m_parent->pixelSize());
49
50 m_parent->readBytes((TQ_UINT8*)b.data(), x, y, w, h);
51 return b;
52}
53
54void KisPaintDeviceIface::writeBytes(TQByteArray bytes, TQ_INT32 x, TQ_INT32 y, TQ_INT32 w, TQ_INT32 h)
55{
56 m_parent->writeBytes((TQ_UINT8*)bytes.data(), x, y, w, h);
57}
58
59DCOPRef KisPaintDeviceIface::colorSpace() const
60{
61 KisColorSpace * cs = m_parent->colorSpace();
62 if ( !cs )
63 return DCOPRef();
64 else
65 return DCOPRef( kapp->dcopClient()->appId(),
66 cs->dcopObject()->objId(),
67 "KisColorSpaceIface" );
68}
69
70void KisPaintDeviceIface::setColorSpace(DCOPRef)
71{
72 // XXX: Figure out how to get the correct object from
73 // the dcopref
74}
A colorspace is the definition of a certain color model in Chalk.
A paint device contains the actual pixel data and offers methods to read and write pixels.
virtual TQ_INT32 pixelSize() const
Return the number of bytes a pixel takes.