71 lines
2.8 KiB
C
71 lines
2.8 KiB
C
|
/***************************************************************************
|
||
|
* Copyright (C) 2012 Stefan Bühler <stbuehler@web.de> *
|
||
|
* *
|
||
|
* This program is free software; you can redistribute it and/or modify *
|
||
|
* it under the terms of the GNU General Public License as published by *
|
||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||
|
* (at your option) any later version. *
|
||
|
* *
|
||
|
* This program is distributed in the hope that it will be useful, *
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||
|
* GNU General Public License for more details. *
|
||
|
* *
|
||
|
* You should have received a copy of the GNU General Public License *
|
||
|
* along with this program; if not, write to the *
|
||
|
* Free Software Foundation, Inc., *
|
||
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||
|
***************************************************************************/
|
||
|
#ifndef LIBQNONO_NONOGRAMIMAGE_H
|
||
|
#define LIBQNONO_NONOGRAMIMAGE_H
|
||
|
|
||
|
#include <QSize>
|
||
|
#include <QImage>
|
||
|
|
||
|
namespace libqnono {
|
||
|
class NonogramImageView {
|
||
|
public:
|
||
|
virtual bool pixel(int coord1, int coord2) const = 0;
|
||
|
virtual bool & pixel(int coord1, int coord2) = 0;
|
||
|
};
|
||
|
|
||
|
class NonogramImage {
|
||
|
public:
|
||
|
NonogramImage();
|
||
|
NonogramImage(QSize size);
|
||
|
NonogramImage(const NonogramImage & other);
|
||
|
NonogramImage(const QImage & image);
|
||
|
~NonogramImage();
|
||
|
NonogramImage& operator=(const NonogramImage & other);
|
||
|
bool operator==(const NonogramImage & other) const;
|
||
|
|
||
|
bool pixel(int x, int y) const { return m_data[y*m_size.width()+x]; }
|
||
|
bool & pixel(int x, int y) { return m_data[y*m_size.width()+x]; }
|
||
|
void setPixel(int x, int y, bool value) { m_data[y*m_size.width()+x] = value; }
|
||
|
void fill(bool value);
|
||
|
|
||
|
int blackPixels() const { return m_blackPixels; }
|
||
|
|
||
|
QSize size() const { return m_size; }
|
||
|
int width() const { return m_size.width(); }
|
||
|
int height() const { return m_size.height(); }
|
||
|
void resize(QSize size);
|
||
|
|
||
|
NonogramImageView* viewRowColumn();
|
||
|
NonogramImageView* viewColumnRow();
|
||
|
|
||
|
bool readFromStream(QDataStream & stream);
|
||
|
void writeToStream(QDataStream & stream) const;
|
||
|
|
||
|
private:
|
||
|
QSize m_size;
|
||
|
bool *m_data;
|
||
|
int m_blackPixels;
|
||
|
};
|
||
|
|
||
|
QDataStream & operator<<(QDataStream & stream, const NonogramImage & image);
|
||
|
QDataStream & operator>>(QDataStream & stream, NonogramImage & image);
|
||
|
}
|
||
|
|
||
|
#endif // LIBQNONO_NONOGRAMIMAGE_H
|