1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| static void ComputeImagesHSL(QImage& oimg, QImage& H, QImage& S, QImage& L)
{
QColor colorRGB;
QColor colorH, colorS, colorL;
H = S = L = oimg; //modify!
qreal hf, sf, lf, af;
//int32_t * pRGBA = image.bits();
for (int y = 0; y <oimg.height(); y++)
{
for (int x = 0; x <oimg.width(); x++)
{
colorRGB = oimg.pixel(x, y);
colorRGB.getHslF(&hf, &sf ,&lf, &af);
int t;
if(!colorRGB.isValid())
t=0;
//qDebug("%5.3f %5.3f %5.3f %5.3f", hf,sf,lf,af);
// hf = hf/360.0f;
//hf = qMin(hf, (qreal)1.0f);
//hf = qMax(hf, (qreal)0.0f);
if(hf<0)
hf = 0;
if(hf>1)
hf=1;
colorH = QColor::fromRgbF(hf,hf,hf,af);
colorS = QColor::fromRgbF(sf,sf,sf,af);
colorL = QColor::fromRgbF(lf,lf,lf,af);
if(!colorH.isValid())
t=0;
H.setPixel(x, y, colorH.rgb());
S.setPixel(x, y, colorS.rgb());
L.setPixel(x, y, colorL.rgb());
}
} |
Partager