![]() |
Mixxx
|
00001 #include "imgcolor.h" 00002 00003 QColor ImgHueInv::doColorCorrection(QColor c) { 00004 int h, s, v; 00005 c.getHsv(&h, &s, &v); 00006 int r, g, b; 00007 c.getRgb(&r, &g, &b); 00008 c.setRgb(0xff - r, 0xff - g, 0xff - b); 00009 int hi, si, vi; 00010 c.getHsv(&hi, &si, &vi); 00011 c.setHsv(hi, s, v); 00012 return c; 00013 } 00014 00015 QColor ImgHueRot::doColorCorrection(QColor c) { 00016 int h, s, v; 00017 c.getHsv(&h, &s, &v); 00018 h = (h + m_amt) % 256; 00019 if (h < 0) { h += 256; } 00020 c.setHsv(h, s, v); 00021 return c; 00022 } 00023 00024 QColor ImgScaleWhite::doColorCorrection(QColor c) { 00025 int h, s, v; 00026 c.getHsv(&h, &s, &v); 00027 if (s < 50) { v *= m_amt; } 00028 if (v > 255) { v = 255; } 00029 c.setHsv(h, s, v); 00030 return c; 00031 } 00032 00033 ImgAdd::ImgAdd(ImgSource * parent, int amt) 00034 : ImgColorProcessor(parent), m_amt(amt) { 00035 // Nothing left to do 00036 } 00037 00038 QColor ImgAdd::doColorCorrection(QColor c) { 00039 int r = c.red() + m_amt; 00040 int g = c.green() + m_amt; 00041 int b = c.blue() + m_amt; 00042 if (r < 0) { r = 0; } 00043 if (g < 0) { g = 0; } 00044 if (b < 0) { b = 0; } 00045 if (r > 255) { r = 255; } 00046 if (g > 255) { g = 255; } 00047 if (b > 255) { b = 255; } 00048 return QColor(r, g, b); 00049 } 00050 00051 ImgMax::ImgMax(ImgSource * parent, int amt) 00052 : ImgColorProcessor(parent), m_amt(amt) { 00053 } 00054 00055 QColor ImgMax::doColorCorrection(QColor c) { 00056 int r = c.red(); 00057 int g = c.green(); 00058 int b = c.blue(); 00059 if (r > m_amt) { r = m_amt; } 00060 if (g > m_amt) { g = m_amt; } 00061 if (b > m_amt) { b = m_amt; } 00062 return QColor(r, g, b); 00063 } 00064 00065 00066 QColor ImgHSVTweak::doColorCorrection(QColor c) { 00067 int h, s, v; 00068 c.getHsv(&h, &s, &v); 00069 00070 if (h >= m_hmin && h <= m_hmax && s >= m_smin && s <= m_smax && 00071 v >= m_vmin && v <= m_vmax) { 00072 h *= m_hfact; 00073 s *= m_sfact; 00074 v *= m_vfact; 00075 h += m_hconst; 00076 s += m_sconst; 00077 v += m_vconst; 00078 00079 h = h % 360; 00080 if (h < 0) { h += 360; } 00081 if (s < 0) { s = 0; } 00082 if (s > 255) { s = 255; } 00083 if (v < 0) { v = 0; } 00084 if (v > 255) { v = 255; } 00085 00086 c.setHsv(h, s, v); 00087 } 00088 return c; 00089 } 00090