/*************************************************************************** * Copyright (C) 2012 Stefan Bühler * * * * 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 #include namespace libqnono { class NonogramMarker; class NonogramImage { public: NonogramImage(); explicit NonogramImage(QSize size); NonogramImage(const NonogramImage & other); explicit NonogramImage(const QImage & image); explicit NonogramImage(const NonogramMarker & marker); ~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]; } 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); bool readFromStream(QDataStream & stream); void writeToStream(QDataStream & stream) const; void load(const QImage & image); void load(const NonogramMarker & marker); 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