Warning, file /office/calligra/libs/pigment/KoColorConversions.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org> 0003 * 0004 * This library is free software; you can redistribute it and/or modify 0005 * it under the terms of the GNU Lesser General Public License as published 0006 * by the Free Software Foundation; either version 2.1 of the License, or 0007 * (at your option) any later version. 0008 * 0009 * This library is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0012 * GNU Lesser General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU Lesser General Public License 0015 * along with this program; if not, write to the Free Software 0016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0017 */ 0018 0019 #ifndef _KO_COLORCONVERSIONS_H_ 0020 #define _KO_COLORCONVERSIONS_H_ 0021 0022 #include <QtGlobal> 0023 #include "pigment_export.h" 0024 0025 /** 0026 * A number of often-used conversions between color models 0027 */ 0028 0029 // 8-bit integer versions. RGBSL are 0-255, H is 0-360. 0030 PIGMENTCMS_EXPORT void rgb_to_hsv(int R, int G, int B, int *H, int *S, int *V); 0031 PIGMENTCMS_EXPORT void hsv_to_rgb(int H, int S, int V, int *R, int *G, int *B); 0032 0033 // Floating point versions. RGBSL are 0-1, H is 0-360. 0034 PIGMENTCMS_EXPORT void RGBToHSV(float r, float g, float b, float *h, float *s, float *v); 0035 PIGMENTCMS_EXPORT void HSVToRGB(float h, float s, float v, float *r, float *g, float *b); 0036 0037 PIGMENTCMS_EXPORT void RGBToHSL(float r, float g, float b, float *h, float *s, float *l); 0038 PIGMENTCMS_EXPORT void HSLToRGB(float h, float sl, float l, float *r, float *g, float *b); 0039 0040 PIGMENTCMS_EXPORT void rgb_to_hls(quint8 r, quint8 g, quint8 b, float * h, float * l, float * s); 0041 0042 PIGMENTCMS_EXPORT float hue_value(float n1, float n2, float hue); 0043 0044 PIGMENTCMS_EXPORT void hls_to_rgb(float h, float l, float s, quint8 * r, quint8 * g, quint8 * b); 0045 0046 PIGMENTCMS_EXPORT void rgb_to_hls(quint8 r, quint8 g, quint8 b, int * h, int * l, int * s); 0047 PIGMENTCMS_EXPORT void hls_to_rgb(int h, int l, int s, quint8 * r, quint8 * g, quint8 * b); 0048 0049 //HSI and HSY' functions. 0050 //These are modified to calculate a cylinder, this is good for colour selectors sliders. 0051 //All eight expect 0.0-1.0 for all parameters. 0052 //HSI measures the Tone, Intensity, by adding the r, g and b components and then normalising that. 0053 PIGMENTCMS_EXPORT void HSIToRGB(const qreal h, const qreal s, const qreal i, qreal *red, qreal *green, qreal *blue); 0054 PIGMENTCMS_EXPORT void RGBToHSI(qreal r, qreal g, qreal b, qreal *h, qreal *s, qreal *i); 0055 0056 //HSY' measures the tone, Luma, by weighting the r, g, and b components before adding them up. 0057 //The R, G, B reffers to the weights, and defaults to the 601 rec for luma. 0058 PIGMENTCMS_EXPORT void RGBToHSY( qreal r, qreal g, qreal b, qreal *h, qreal *s, qreal *y, qreal R=0.299, qreal G=0.587, qreal B=0.114); 0059 PIGMENTCMS_EXPORT void HSYToRGB(const qreal h, const qreal s, const qreal y, qreal *red, qreal *green, qreal *blue, qreal R=0.299, qreal G=0.587, qreal B=0.114); 0060 0061 0062 //HCI and HCY' functions. 0063 //These are the original conversion functions, producing cones. Put in for completion. 0064 //There's HCI to RGB is based on the HCY to RGB one for now, it may not be correct. 0065 PIGMENTCMS_EXPORT void HCIToRGB(const qreal h, const qreal s, const qreal i, qreal *red, qreal *green, qreal *blue); 0066 PIGMENTCMS_EXPORT void RGBToHCI(const qreal r, const qreal g, const qreal b, qreal *h, qreal *c, qreal *i); 0067 0068 PIGMENTCMS_EXPORT void HCYToRGB(const qreal h, const qreal s, const qreal y, qreal *red, qreal *green, qreal *blue, qreal R=0.299, qreal G=0.587, qreal B=0.114); 0069 PIGMENTCMS_EXPORT void RGBToHCY(const qreal r, const qreal g, const qreal b, qreal *h, qreal *c, qreal *y, qreal R=0.299, qreal G=0.587, qreal B=0.114); 0070 0071 PIGMENTCMS_EXPORT void RGBToYUV( qreal r, qreal g, qreal b, qreal *y, qreal *cb, qreal *cr, qreal R=0.299, qreal G=0.587, qreal B=0.114); 0072 PIGMENTCMS_EXPORT void YUVToRGB(const qreal y, const qreal cb, const qreal cr, qreal *r, qreal *g, qreal *b, qreal R=0.299, qreal G=0.587, qreal B=0.114); 0073 0074 PIGMENTCMS_EXPORT void LabToLCH(const qreal l, const qreal a, const qreal b, qreal *L, qreal *C, qreal *H); 0075 PIGMENTCMS_EXPORT void LCHToLab(const qreal L, const qreal C, const qreal H, qreal *l, qreal *a, qreal *b); 0076 0077 PIGMENTCMS_EXPORT void XYZToxyY(const qreal X, const qreal Y, const qreal Z, qreal *x, qreal *y, qreal *yY); 0078 PIGMENTCMS_EXPORT void xyYToXYZ(const qreal x, const qreal y, const qreal yY, qreal *X, qreal *Y, qreal *Z); 0079 0080 PIGMENTCMS_EXPORT void CMYToCMYK(qreal *c, qreal *m, qreal *y, qreal *k); 0081 PIGMENTCMS_EXPORT void CMYKToCMY(qreal *c, qreal *m, qreal *y, qreal *k); 0082 0083 #endif // _KO_COLORCONVERSIONS_H_ 0084