File indexing completed on 2024-05-12 15:58:39

0001 /*
0002  *  This file is part of the KDE project
0003  *
0004  *  SPDX-FileCopyrightText: 2006 Cyrille Berger <cberger@cberger.net>
0005  *
0006  *  SPDX-License-Identifier: GPL-2.0-or-later
0007  */
0008 
0009 #ifndef KIS_RANDOM_SUB_ACCESSOR_H
0010 #define KIS_RANDOM_SUB_ACCESSOR_H
0011 
0012 
0013 #include "kis_random_accessor_ng.h"
0014 #include "kis_types.h"
0015 #include <kritaimage_export.h>
0016 #include "kis_shared.h"
0017 
0018 /**
0019  * Gives a random access to the sampled subpixels of an image. Use the
0020  * moveTo function to select the pixel. And then rawData to access the
0021  * value of a pixel.
0022  */
0023 class  KRITAIMAGE_EXPORT KisRandomSubAccessor : public KisShared
0024 {
0025 public:
0026     KisRandomSubAccessor(KisPaintDeviceSP device);
0027     ~KisRandomSubAccessor();
0028     /**
0029      * Copy the sampled old value to destination
0030      */
0031     void sampledOldRawData(quint8* dst);
0032 
0033     /**
0034      * Copy the sampled value to destination
0035      */
0036     void sampledRawData(quint8* dst);
0037 
0038     inline void moveTo(qreal x, qreal y) {
0039         m_currentPoint.setX(x); m_currentPoint.setY(y);
0040     }
0041     inline void moveTo(const QPointF& p) {
0042         m_currentPoint = p;
0043     }
0044 
0045 private:
0046     KisPaintDeviceSP m_device;
0047     QPointF m_currentPoint;
0048     KisRandomConstAccessorSP m_randomAccessor;
0049 };
0050 
0051 #endif