You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
koffice/chalk/chalkcolor/kis_color.h

91 lines
2.9 KiB

/*
* Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _KIS_COLOR_H_
#define _KIS_COLOR_H_
#include <tqcolor.h>
#include "ksharedptr.h"
#include "kis_global.h"
#include "kis_profile.h"
#include "kis_colorspace.h"
/**
* A KisColor describes a color in a certain colorspace.
*
*/
class KisColor {
public:
/// Create an empty KisColor. It will be valid, but also black and transparent
KisColor();
virtual ~KisColor();
/// Create a KisColor from a TQColor. The TQColor is immediately converted to native. The TQColor
/// is assumed to have the current monitor profile.
KisColor(const TQColor & color, KisColorSpace * colorSpace);
/// Create a KisColor from a TQColor. The TQColor is immediately converted to native. The TQColor
/// is assumed to have the current monitor profile.
KisColor(const TQColor & color, TQ_UINT8 alpha, KisColorSpace * colorSpace);
/// Create a KisColor using a native color strategy. The data is copied.
KisColor(const TQ_UINT8 * data, KisColorSpace * colorSpace);
/// Create a KisColor by converting src into another colorspace
KisColor(const KisColor &src, KisColorSpace * colorSpace);
/// Copy constructor -- deep copies the colors.
KisColor(const KisColor & rhs);
/// Effective C++, item 11
KisColor &operator=(const KisColor &);
/// For easy memcpy'ing etc.
TQ_UINT8 * data() const { return m_data; }
KisColorSpace * colorSpace() const { return m_colorSpace; }
KisProfile * profile() const { return m_colorSpace->getProfile(); }
/// Convert this KisColor to the specified colorspace. If the specified colorspace is the
/// same as the original colorspace, do nothing. Returns the converted KisColor.
void convertTo(KisColorSpace * cs);
/// Replace the existing color data, and colorspace with the specified data.
void setColor(TQ_UINT8 * data, KisColorSpace * colorSpace = 0);
/// To save the user the trouble of doing color->colorSpace()->toTQColor(color->data(), &c, &a
void toTQColor(TQColor *c) const;
void toTQColor(TQColor *c, TQ_UINT8 *opacity) const;
TQColor toTQColor() const;
void dump() const;
private:
TQ_UINT8 * m_data;
KisColorSpace * m_colorSpace;
};
#endif