Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 22211 → Rev 22212

/trunk/Scribus/doc/en/scripterapi-color.html
17,14 → 17,30
<p>Note : deprecated, use changeColorCMYK() instead</p>
<p>May raise <a href="scripterapi.html#NotFoundError">NotFoundError</a> if the named color wasn't found. May raise ValueError if an invalid color name is specified.</p></dd>
 
<dt><a name="-changeColorCMYK"><strong>changeColorCMYK</strong></a>(...)</dt>
<dd><code>changeColorCMYK("name", c, m, y, k)</code>
<p>Changes the color "name" to the specified CMYK value. The color value is defined via four components c = Cyan, m = Magenta, y = Yellow and k = Black. Color components should be in the range from 0 to 255.</p>
<p>May raise <a href="scripterapi.html#NotFoundError">NotFoundError</a> if the named color wasn't found. May raise ValueError if an invalid color name is specified.</p></dd>
 
<dt><a name="-changeColorCMYKFloat"><strong>changeColorCMYKFloat</strong></a>(...)</dt>
<dd><code>changeColorCMYKFloat("name", c, m, y, k)</code>
<p>Changes the color "name" to the specified CMYK value. The color value is defined via four components c = Cyan, m = Magenta, y = Yellow and k = Black. Color components are floating point values between 0 and 100.</p>
<p>May raise <a href="scripterapi.html#NotFoundError">NotFoundError</a> if the named color wasn't found. May raise ValueError if an invalid color name is specified.</p></dd>
 
<dt><a name="-changeColorLab"><strong>changeColorLab</strong></a>(...)</dt>
<dd><code>changeColorLab("name", L, a, b)</code>
<p>Changes the color \"name\" to the specified CIELab values. The color value is defined via three components: L = luminosity, a = green/red, b = blue/yellow. Color components are floating point values with L between 0 and 100, a and b between -128 and 128.</p>
<p>Note : deprecated, use changeColorCMYK() instead</p>
<p>May raise <a href="scripterapi.html#NotFoundError">NotFoundError</a> if the named color wasn't found. May raise ValueError if an invalid color name is specified.</p></dd>
 
<dt><a name="-changeColorRGB"><strong>changeColorRGB</strong></a>(...)</dt>
<dd><code>changeColorRGB("name", r, g, b)</code>
<p>Changes the color "name" to the specified RGB value. The color value is defined via three components r = red, g = green, b = blue. Color components should be in the range from 0 to 255.</p>
<p>May raise <a href="scripterapi.html#NotFoundError">NotFoundError</a> if the named color wasn't found. May raise ValueError if an invalid color name is specified.</p></dd>
 
<dt><a name="-changeColorCMYK"><strong>changeColorCMYK</strong></a>(...)</dt>
<dd><code>changeColorCMYK("name", c, m, y, k)</code>
<p>Changes the color "name" to the specified CMYK value. The color value is defined via four components c = Cyan, m = Magenta, y = Yellow and k = Black. Color components should be in the range from 0 to 255.</p>
<dt><a name="-changeColorRGBFloat"><strong>changeColorRGBFloat</strong></a>(...)</dt>
<dd><code>changeColorRGBFloat("name", r, g, b)</code>
<p>Changes the color "name" to the specified RGB value. The color value is defined via three components r = red, g = green, b = blue. Color components are floating point values between 0 and 255.</p>
<p>May raise <a href="scripterapi.html#NotFoundError">NotFoundError</a> if the named color wasn't found. May raise ValueError if an invalid color name is specified.</p></dd>
 
<dt><a name="-defineColor"><strong>defineColor</strong></a>(...)</dt>
33,14 → 49,29
<p>Note : deprecated, use defineColorCMYK() instead.</p>
<p>May raise ValueError if an invalid color name is specified.</p></dd>
 
<dt><a name="-defineColorCMYK"><strong>defineColorCMYK</strong></a>(...)</dt>
<dd><code>defineColorCMYK("name", c, m, y, k)</code>
<p>Defines a new color "name". The color Value is defined via three components: c = Cyan, m = Magenta, y = Yellow and k = Black. Color components should be in the range from 0 to 255.</p>
<p>May raise ValueError if an invalid color name is specified.</p></dd>
 
<dt><a name="-defineColorCMYKFloat"><strong>defineColorCMYKFloat</strong></a>(...)</dt>
<dd><code>defineColorCMYKFloat("name", c, m, y, k)</code>
<p>Defines a new color "name". The color Value is defined via three components: c = Cyan, m = Magenta, y = Yellow and k = Black. Color components are floating point values between 0 and 100.</p>
<p>May raise ValueError if an invalid color name is specified.</p></dd>
 
<dt><a name="-defineColorLab"><strong>defineColorLab</strong></a>(...)</dt>
<dd><code>defineColorLab("name", L, a,b)</code>
<p>Defines a new color \"name\" using CIELab values. The color value is defined via three components: L = luminosity, a = green/red, b = blue/yellow. Color components are floating point values with L between 0 and 100, a and b between -128 and 128.</p>
<p>May raise ValueError if an invalid color name is specified.</p></dd>
 
<dt><a name="-defineColorRGB"><strong>defineColorRGB</strong></a>(...)</dt>
<dd><code>defineColorRGB("name", r, g, b)</code>
<p>Defines a new color "name". The color Value is defined via three components: r = red, g = green, b = blue. Color components should be in the range from 0 to 255.</p>
<p>May raise ValueError if an invalid color name is specified.</p></dd>
 
<dt><a name="-defineColorCMYK"><strong>defineColorCMYK</strong></a>(...)</dt>
<dd><code>defineColorCMYK("name", c, m, y, k)</code>
<p>Defines a new color "name". The color Value is defined via three components: c = Cyan, m = Magenta, y = Yellow and k = Black. Color components should be in the range from 0 to 255.</p>
<dt><a name="-defineColorRGBFloat"><strong>defineColorRGBFloat</strong></a>(...)</dt>
<dd><code>defineColorRGBFloat("name", r, g, b)</code>
<p>Defines a new color "name". The color Value is defined via three components: r = red, g = green, b = blue. Color components are floating point values between 0 and 255.</p>
<p>May raise ValueError if an invalid color name is specified.</p></dd>
 
<dt><a name="-deleteColor"><strong>deleteColor</strong></a>(...)</dt>
54,11 → 85,21
<p>Returns a tuple (C, M, Y, K) containing the four color components of the color "name" from the current document. If no document is open, returns the value of the named color from the default document colors.</p>
<p>May raise <a href="scripterapi.html#NotFoundError">NotFoundError</a> if the named color wasn't found. May raise ValueError if an invalid color name is specified.</p></dd>
 
<dt><a name="-getColorFloat"><strong>getColorFloat</strong></a>(...)</dt>
<dd><code>getColorFloat("name") -&gt; tuple</code>
<p>Returns a tuple (C, M, Y, K) containing the four color components of the color "name" from the current document. Color components are floating point values between 0 and 100. If no document is open, returns the value of the named color from the default document colors.</p>
<p>May raise <a href="scripterapi.html#NotFoundError">NotFoundError</a> if the named color wasn't found. May raise ValueError if an invalid color name is specified.</p></dd>
 
<dt><a name="-getColorAsRGB"><strong>getColorAsRGB</strong>(...)</a></dt>
<dd><code>getColorAsRGB("name") -&gt; tuple</code>
<p>Returns a tuple (R,G,B) containing the three color components of the color "name" from the current document, converted to the RGB color space. If no document is open, returns the value of the named color from the default document colors.</p>
<p>May raise NotFoundError if the named color wasn't found. May raise ValueError if an invalid color name is specified.</p></dd>
 
<dt><a name="-getColorAsRGBFloat"><strong>getColorAsRGBFloat</strong>(...)</a></dt>
<dd><code>getColorAsRGBFloat("name") -&gt; tuple</code>
<p>Returns a tuple (R,G,B) containing the three color components of the color "name" from the current document, converted to the RGB color space. Color components are floating point values between 0 and 255. If no document is open, returns the value of the named color from the default document colors.</p>
<p>May raise NotFoundError if the named color wasn't found. May raise ValueError if an invalid color name is specified.</p></dd>
 
<dt><a name="-getColorNames"><strong>getColorNames</strong></a>(...)</dt>
<dd><code>getColorNames() -&gt; list</code>
<p>Returns a list containing the names of all defined colors in the document. If no document is open, returns a list of the default document colors.</p></dd>
/trunk/Scribus/resources/swatches/Shades_of_K.xml
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
/trunk/Scribus/scribus/colorsetmanager.cpp
53,74 → 53,99
appPrefs.colorPrefs.DColors.insert("Yellow", ScColor(0, 0, 255, 0));
appPrefs.colorPrefs.DColors.insert("Magenta", ScColor(0, 255, 0, 0));
appPrefs.colorPrefs.DColorSet = "Scribus_Small";
return;
}
else
 
if (fiC.open(QIODevice::ReadOnly))
{
if (fiC.open(QIODevice::ReadOnly))
QString ColorEn, Cname;
int Rval, Gval, Bval;
QTextStream tsC(&fiC);
ColorEn = tsC.readLine();
if (ColorEn.startsWith("<?xml version="))
{
QString ColorEn, Cname;
int Rval, Gval, Bval;
QTextStream tsC(&fiC);
ColorEn = tsC.readLine();
if (ColorEn.startsWith("<?xml version="))
QByteArray docBytes("");
loadRawText(defaultSwatch, docBytes);
QString docText("");
docText = QString::fromUtf8(docBytes);
QDomDocument docu("scridoc");
docu.setContent(docText);
ScColor lf = ScColor();
QDomElement elem = docu.documentElement();
QDomNode PAGE = elem.firstChild();
while (!PAGE.isNull())
{
QByteArray docBytes("");
loadRawText(defaultSwatch, docBytes);
QString docText("");
docText = QString::fromUtf8(docBytes);
QDomDocument docu("scridoc");
docu.setContent(docText);
ScColor lf = ScColor();
QDomElement elem = docu.documentElement();
QDomNode PAGE = elem.firstChild();
while(!PAGE.isNull())
QDomElement pg = PAGE.toElement();
if (pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None)
{
QDomElement pg = PAGE.toElement();
if(pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None)
if (pg.hasAttribute("SPACE"))
{
if (pg.hasAttribute("CMYK"))
lf.setNamedColor(pg.attribute("CMYK"));
else if (pg.hasAttribute("RGB"))
lf.fromQColor(QColor(pg.attribute("RGB")));
else
QString space = pg.attribute("SPACE");
if (space == "CMYK")
{
double L = pg.attribute("L", 0).toDouble();
double a = pg.attribute("A", 0).toDouble();
double b = pg.attribute("B", 0).toDouble();
lf.setColor(L, a, b);
double c = pg.attribute("C", "0").toDouble() / 100.0;
double m = pg.attribute("M", "0").toDouble() / 100.0;
double y = pg.attribute("Y", "0").toDouble() / 100.0;
double k = pg.attribute("K", "0").toDouble() / 100.0;
lf.setCmykColorF(c, m, y, k);
}
if (pg.hasAttribute("Spot"))
lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt()));
else
lf.setSpotColor(false);
if (pg.hasAttribute("Register"))
lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt()));
else
lf.setRegistrationColor(false);
appPrefs.colorPrefs.DColors.insert(pg.attribute("NAME"), lf);
else if (space == "RGB")
{
double r = pg.attribute("R", "0").toDouble() / 255.0;
double g = pg.attribute("G", "0").toDouble() / 255.0;
double b = pg.attribute("B", "0").toDouble() / 255.0;
lf.setRgbColorF(r, g, b);
}
else if (space == "Lab")
{
double L = pg.attribute("L", "0").toDouble();
double a = pg.attribute("A", "0").toDouble();
double b = pg.attribute("B", "0").toDouble();
lf.setLabColor(L, a, b);
}
}
PAGE=PAGE.nextSibling();
else if (pg.hasAttribute("CMYK"))
lf.setNamedColor(pg.attribute("CMYK"));
else if (pg.hasAttribute("RGB"))
lf.fromQColor(QColor(pg.attribute("RGB")));
else
{
double L = pg.attribute("L", 0).toDouble();
double a = pg.attribute("A", 0).toDouble();
double b = pg.attribute("B", 0).toDouble();
lf.setLabColor(L, a, b);
}
if (pg.hasAttribute("Spot"))
lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt()));
else
lf.setSpotColor(false);
if (pg.hasAttribute("Register"))
lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt()));
else
lf.setRegistrationColor(false);
appPrefs.colorPrefs.DColors.insert(pg.attribute("NAME"), lf);
}
PAGE=PAGE.nextSibling();
}
else
}
else
{
while (!tsC.atEnd())
{
while (!tsC.atEnd())
{
ColorEn = tsC.readLine();
QTextStream CoE(&ColorEn, QIODevice::ReadOnly);
CoE >> Rval;
CoE >> Gval;
CoE >> Bval;
CoE >> Cname;
ScColor tmp;
tmp.setColorRGB(Rval, Gval, Bval);
appPrefs.colorPrefs.DColors.insert(Cname, tmp);
}
ColorEn = tsC.readLine();
QTextStream CoE(&ColorEn, QIODevice::ReadOnly);
CoE >> Rval;
CoE >> Gval;
CoE >> Bval;
CoE >> Cname;
ScColor tmp;
tmp.setRgbColor(Rval, Gval, Bval);
appPrefs.colorPrefs.DColors.insert(Cname, tmp);
}
fiC.close();
}
appPrefs.colorPrefs.DColorSet = ScPaths::instance().shareDir() + "swatches/" + "Scribus Basic";
fiC.close();
}
appPrefs.colorPrefs.DColorSet = ScPaths::instance().shareDir() + "swatches/" + "Scribus Basic";
}
 
void ColorSetManager::findPaletteLocations()
/trunk/Scribus/scribus/imagedataloaders/scimgdataloader_psd.cpp
329,7 → 329,7
switch (signature)
{
case 0: // RGB colour
col.setColorRGB(c >> 8, m >> 8, y >> 8);
col.setRgbColor(c >> 8, m >> 8, y >> 8);
m_colorTableSc.append(col);
break;
case 1: // HSB colour
337,7 → 337,7
sc = m >> 8;
bc = y >> 8;
HSVTORGB(hc, sc, bc);
col.setColorRGB(hc, sc, bc);
col.setRgbColor(hc, sc, bc);
m_colorTableSc.append(col);
break;
case 2: // CMYK colour
/trunk/Scribus/scribus/pdflib_core.cpp
5836,11 → 5836,10
QByteArray PDFLibCore::SetColor(const ScColor& farbe, double Shade)
{
QByteArray tmp;
RGBColor rgb;
CMYKColor cmyk;
int h, s, v, k;
RGBColorF rgb;
CMYKColorF cmyk;
double h, s, v, k;
ScColor tmpC(farbe);
QColor tmpR;
if (Options.isGrayscale)
{
bool kToGray = false;
5854,17 → 5853,17
tmp = FToStr(1.0 - k / 255.0);
else
{
tmpR = ScColorEngine::getShadeColor(tmpC, &doc, Shade);
tmpR.getRgb(&h, &s, &v);
tmp = FToStr((0.3 * h + 0.59 * s + 0.11 * v) / 255.0);
ScColorEngine::getShadeColorRGB(tmpC, &doc, rgb, Shade);
rgb.getValues(h, s, v);
tmp = FToStr(0.3 * h + 0.59 * s + 0.11 * v);
}
return tmp;
}
if (Options.UseRGB)
{
tmpR = ScColorEngine::getShadeColor(tmpC, &doc, Shade);
tmpR.getRgb(&h, &s, &v);
tmp = FToStr(h / 255.0)+" "+FToStr(s / 255.0)+" "+FToStr(v / 255.0);
ScColorEngine::getShadeColorRGB(tmpC, &doc, rgb, Shade);
rgb.getValues(h, s, v);
tmp = FToStr(h) + " " + FToStr(s) + " " + FToStr(v);
}
else
{
5874,7 → 5873,7
{
ScColorEngine::getShadeColorCMYK(tmpC, &doc, cmyk, Shade);
cmyk.getValues(h, s, v, k);
tmp = FToStr(h / 255.0)+" "+FToStr(s / 255.0)+" "+FToStr(v / 255.0)+" "+FToStr(k / 255.0);
tmp = FToStr(h) + " "+ FToStr(s) + " " + FToStr(v) + " " + FToStr(k);
}
else
{
5882,13 → 5881,13
{
ScColorEngine::getShadeColorRGB(tmpC, &doc, rgb, Shade);
rgb.getValues(h, s, v);
tmp = FToStr(h / 255.0)+" "+FToStr(s / 255.0)+" "+FToStr(v / 255.0);
tmp = FToStr(h) + " " + FToStr(s) + " " + FToStr(v);
}
else
{
ScColorEngine::getShadeColorCMYK(tmpC, &doc, cmyk, Shade);
cmyk.getValues(h, s, v, k);
tmp = FToStr(h / 255.0)+" "+FToStr(s / 255.0)+" "+FToStr(v / 255.0)+" "+FToStr(k / 255.0);
tmp = FToStr(h) + " " + FToStr(s) + " " + FToStr(v) + " " + FToStr(k);
}
}
}
5896,7 → 5895,7
{
ScColorEngine::getShadeColorCMYK(tmpC, &doc, cmyk, Shade);
cmyk.getValues(h, s, v, k);
tmp = FToStr(h / 255.0)+" "+FToStr(s / 255.0)+" "+FToStr(v / 255.0)+" "+FToStr(k / 255.0);
tmp = FToStr(h) + " " + FToStr(s) + " " + FToStr(v) + " " + FToStr(k);
}
}
return tmp;
7032,20 → 7031,17
int maxSp = spotColorSet.count() - 1;
for (int sc = 0; sc < spotColorSet.count(); sc++)
{
int cc = 0;
int mc = 0;
int yc = 0;
int kc = 0;
CMYKColor cmykValues;
double cc(0), mc(0), yc(0), kc(0);
CMYKColorF cmykValues;
ScColorEngine::getCMYKValues(doc.PageColors[spotColorSet.at(maxSp - sc)], &doc, cmykValues);
cmykValues.getValues(cc, mc, yc, kc);
if (sc == 0)
colorDesc += "dup "+FToStr(static_cast<double>(cc) / 255.0)+" mul ";
colorDesc += "dup " + FToStr(cc) + " mul ";
else
colorDesc += Pdf::toPdf(sc*4 + 1)+" -1 roll dup "+FToStr(static_cast<double>(cc) / 255.0)+" mul ";
colorDesc += "exch dup "+FToStr(static_cast<double>(mc) / 255.0)+" mul ";
colorDesc += "exch dup "+FToStr(static_cast<double>(yc) / 255.0)+" mul ";
colorDesc += "exch "+FToStr(static_cast<double>(kc) / 255.0)+" mul\n";
colorDesc += Pdf::toPdf(sc*4 + 1) + " -1 roll dup " + FToStr(cc) + " mul ";
colorDesc += "exch dup " + FToStr(mc) + " mul ";
colorDesc += "exch dup " + FToStr(yc) + " mul ";
colorDesc += "exch " + FToStr(kc) + " mul\n";
}
for (int sc = 0; sc < spotColorSet.count(); sc++)
{
7362,20 → 7358,17
int maxSp = spotColorSet.count() - 1;
for (int sc = 0; sc < spotColorSet.count(); sc++)
{
int cc = 0;
int mc = 0;
int yc = 0;
int kc = 0;
CMYKColor cmykValues;
double cc(0), mc(0), yc(0), kc(0);
CMYKColorF cmykValues;
ScColorEngine::getCMYKValues(doc.PageColors[spotColorSet.at(maxSp - sc)], &doc, cmykValues);
cmykValues.getValues(cc, mc, yc, kc);
if (sc == 0)
colorDesc += "dup "+FToStr(static_cast<double>(cc) / 255.0)+" mul ";
colorDesc += "dup " + FToStr(cc) + " mul ";
else
colorDesc += Pdf::toPdf(sc*4 + 1)+" -1 roll dup "+FToStr(static_cast<double>(cc) / 255.0)+" mul ";
colorDesc += "exch dup "+FToStr(static_cast<double>(mc) / 255.0)+" mul ";
colorDesc += "exch dup "+FToStr(static_cast<double>(yc) / 255.0)+" mul ";
colorDesc += "exch "+FToStr(static_cast<double>(kc) / 255.0)+" mul\n";
colorDesc += Pdf::toPdf(sc*4 + 1) + " -1 roll dup " + FToStr(cc) + " mul ";
colorDesc += "exch dup " + FToStr(mc) + " mul ";
colorDesc += "exch dup " + FToStr(yc) + " mul ";
colorDesc += "exch " + FToStr(kc) + " mul\n";
}
for (int sc = 0; sc < spotColorSet.count(); sc++)
{
7798,20 → 7791,17
int maxSp = spotColorSet.count() - 1;
for (int sc = 0; sc < spotColorSet.count(); sc++)
{
int cc = 0;
int mc = 0;
int yc = 0;
int kc = 0;
CMYKColor cmykValues;
double cc(0), mc(0), yc(0), kc(0);
CMYKColorF cmykValues;
ScColorEngine::getCMYKValues(doc.PageColors[spotColorSet.at(maxSp - sc)], &doc, cmykValues);
cmykValues.getValues(cc, mc, yc, kc);
if (sc == 0)
colorDesc += "dup "+FToStr(static_cast<double>(cc) / 255.0)+" mul ";
colorDesc += "dup " + FToStr(cc) + " mul ";
else
colorDesc += Pdf::toPdf(sc*4 + 1)+" -1 roll dup "+FToStr(static_cast<double>(cc) / 255.0)+" mul ";
colorDesc += "exch dup "+FToStr(static_cast<double>(mc) / 255.0)+" mul ";
colorDesc += "exch dup "+FToStr(static_cast<double>(yc) / 255.0)+" mul ";
colorDesc += "exch "+FToStr(static_cast<double>(kc) / 255.0)+" mul\n";
colorDesc += Pdf::toPdf(sc*4 + 1) + " -1 roll dup " + FToStr(cc) + " mul ";
colorDesc += "exch dup " + FToStr(mc) + " mul ";
colorDesc += "exch dup " + FToStr(yc) + " mul ";
colorDesc += "exch " + FToStr(kc) + " mul\n";
}
for (int sc = 0; sc < spotColorSet.count(); sc++)
{
8121,20 → 8111,17
int maxSp = spotColorSet.count() - 1;
for (int sc = 0; sc < spotColorSet.count(); sc++)
{
int cc = 0;
int mc = 0;
int yc = 0;
int kc = 0;
CMYKColor cmykValues;
double cc(0), mc(0), yc(0), kc(0);
CMYKColorF cmykValues;
ScColorEngine::getCMYKValues(doc.PageColors[spotColorSet.at(maxSp - sc)], &doc, cmykValues);
cmykValues.getValues(cc, mc, yc, kc);
if (sc == 0)
colorDesc += "dup "+FToStr(static_cast<double>(cc) / 255.0)+" mul ";
colorDesc += "dup " + FToStr(cc) + " mul ";
else
colorDesc += Pdf::toPdf(sc*4 + 1)+" -1 roll dup "+FToStr(static_cast<double>(cc) / 255.0)+" mul ";
colorDesc += "exch dup "+FToStr(static_cast<double>(mc) / 255.0)+" mul ";
colorDesc += "exch dup "+FToStr(static_cast<double>(yc) / 255.0)+" mul ";
colorDesc += "exch "+FToStr(static_cast<double>(kc) / 255.0)+" mul\n";
colorDesc += Pdf::toPdf(sc*4 + 1) + " -1 roll dup " + FToStr(cc) + " mul ";
colorDesc += "exch dup " + FToStr(mc) + " mul ";
colorDesc += "exch dup " + FToStr(yc) + " mul ";
colorDesc += "exch " + FToStr(kc) + " mul\n";
}
for (int sc = 0; sc < spotColorSet.count(); sc++)
{
8577,20 → 8564,17
int maxSp = spotColorSet.count() - 1;
for (int sc = 0; sc < spotColorSet.count(); sc++)
{
int cc = 0;
int mc = 0;
int yc = 0;
int kc = 0;
CMYKColor cmykValues;
double cc(0), mc(0), yc(0), kc(0);
CMYKColorF cmykValues;
ScColorEngine::getCMYKValues(doc.PageColors[spotColorSet.at(maxSp - sc)], &doc, cmykValues);
cmykValues.getValues(cc, mc, yc, kc);
if (sc == 0)
colorDesc += "dup "+FToStr(static_cast<double>(cc) / 255.0)+" mul ";
colorDesc += "dup " + FToStr(cc) + " mul ";
else
colorDesc += Pdf::toPdf(sc*4 + 1)+" -1 roll dup "+FToStr(static_cast<double>(cc) / 255.0)+" mul ";
colorDesc += "exch dup "+FToStr(static_cast<double>(mc) / 255.0)+" mul ";
colorDesc += "exch dup "+FToStr(static_cast<double>(yc) / 255.0)+" mul ";
colorDesc += "exch "+FToStr(static_cast<double>(kc) / 255.0)+" mul\n";
colorDesc += Pdf::toPdf(sc*4 + 1) + " -1 roll dup " + FToStr(cc) + " mul ";
colorDesc += "exch dup " + FToStr(mc) + " mul ";
colorDesc += "exch dup " + FToStr(yc) + " mul ";
colorDesc += "exch " + FToStr(kc) + " mul\n";
}
for (int sc = 0; sc < spotColorSet.count(); sc++)
{
/trunk/Scribus/scribus/plugins/colorwheel/cwdialog.cpp
68,7 → 68,7
if (!colorName.isEmpty() && m_Doc->PageColors.contains(colorName))
color = m_Doc->PageColors[colorName];
else
color.setColorRGB(0, 0, 0); //Trigger use of defaults
color.setRgbColor(0, 0, 0); //Trigger use of defaults
}
// Handle achromatic colors
QColor rgb = ScColorEngine::getRGBColor(color, m_Doc);
426,13 → 426,13
 
void CWDialog::setupCMYKComponent(ScColor col)
{
CMYKColor cmyk;
CMYKColorF cmyk;
ScColorEngine::getCMYKValues(col, m_Doc, cmyk);
connectSlots(false);
cSpin->setValue(qRound(cmyk.c / 2.55));
mSpin->setValue(qRound(cmyk.m / 2.55));
ySpin->setValue(qRound(cmyk.y / 2.55));
kSpin->setValue(qRound(cmyk.k / 2.55));
cSpin->setValue(qRound(cmyk.c * 100.0));
mSpin->setValue(qRound(cmyk.m * 100.0));
ySpin->setValue(qRound(cmyk.y * 100.0));
kSpin->setValue(qRound(cmyk.k * 100.0));
connectSlots(true);
}
 
/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
2378,7 → 2378,33
void Scribus150Format::readColor(ColorList& colors, ScXmlStreamAttributes& attrs)
{
ScColor color;
if (attrs.hasAttribute("CMYK"))
if (attrs.hasAttribute("SPACE"))
{
QString space = attrs.valueAsString("SPACE");
if (space == "CMYK")
{
double c = attrs.valueAsDouble("C", 0) / 100.0;
double m = attrs.valueAsDouble("M", 0) / 100.0;
double y = attrs.valueAsDouble("Y", 0) / 100.0;
double k = attrs.valueAsDouble("K", 0) / 100.0;
color.setCmykColorF(c, m, y, k);
}
else if (space == "RGB")
{
double r = attrs.valueAsDouble("R", 0) / 255.0;
double g = attrs.valueAsDouble("G", 0) / 255.0;
double b = attrs.valueAsDouble("B", 0) / 255.0;
color.setRgbColorF(r, g, b);
}
else if (space == "Lab")
{
double L = attrs.valueAsDouble("L", 0);
double a = attrs.valueAsDouble("A", 0);
double b = attrs.valueAsDouble("B", 0);
color.setLabColor(L, a, b);
}
}
else if (attrs.hasAttribute("CMYK"))
color.setNamedColor(attrs.valueAsString("CMYK"));
else if (attrs.hasAttribute("RGB"))
color.fromQColor(QColor(attrs.valueAsString("RGB")));
2387,7 → 2413,7
double L = attrs.valueAsDouble("L", 0);
double a = attrs.valueAsDouble("A", 0);
double b = attrs.valueAsDouble("B", 0);
color.setColor(L, a, b);
color.setLabColor(L, a, b);
}
color.setSpotColor( attrs.valueAsBool("Spot", false) );
color.setRegistrationColor( attrs.valueAsBool("Register", false) );
2396,7 → 2422,7
{
color.setSpotColor(true);
color.setRegistrationColor(true);
color.setColor(255, 255, 255, 255);
color.setCmykColorF(1.0, 1.0, 1.0, 1.0);
}
// #10323 : break loading of doc which contain colors with different names
// and same definition
/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
581,26 → 581,42
usedColors = m_Doc->PageColors;
for (itc = usedColors.begin(); itc != usedColors.end(); ++itc)
{
const ScColor& color = m_Doc->PageColors[itc.key()];
docu.writeEmptyElement("COLOR");
docu.writeAttribute("NAME",itc.key());
if (m_Doc->PageColors[itc.key()].getColorModel() == colorModelRGB)
docu.writeAttribute("RGB",m_Doc->PageColors[itc.key()].nameRGB());
else if (m_Doc->PageColors[itc.key()].getColorModel() == colorModelCMYK)
docu.writeAttribute("CMYK",m_Doc->PageColors[itc.key()].nameCMYK());
docu.writeAttribute("NAME", itc.key());
if (color.getColorModel() == colorModelRGB)
{
double r, g, b;
color.getRGB(&r, &g, &b);
docu.writeAttribute("SPACE", "RGB");
docu.writeAttribute("R", r * 255.0);
docu.writeAttribute("G", g * 255.0);
docu.writeAttribute("B", b * 255.0);
}
else if (color.getColorModel() == colorModelCMYK)
{
double c, m, y, k;
color.getCMYK(&c, &m, &y, &k);
docu.writeAttribute("SPACE", "CMYK");
docu.writeAttribute("C", c * 100.0);
docu.writeAttribute("M", m * 100.0);
docu.writeAttribute("Y", y * 100.0);
docu.writeAttribute("K", k * 100.0);
}
else
{
double L, a, b;
m_Doc->PageColors[itc.key()].getLab(&L, &a, &b);
color.getLab(&L, &a, &b);
docu.writeAttribute("SPACE", "Lab");
docu.writeAttribute("L", L);
docu.writeAttribute("A", a);
docu.writeAttribute("B", b);
}
if (m_Doc->PageColors[itc.key()].isSpotColor())
docu.writeAttribute("Spot",static_cast<int>(m_Doc->PageColors[itc.key()].isSpotColor()));
if (m_Doc->PageColors[itc.key()].isRegistrationColor())
docu.writeAttribute("Register",static_cast<int>(m_Doc->PageColors[itc.key()].isRegistrationColor()));
if (color.isSpotColor())
docu.writeAttribute("Spot", static_cast<int>(color.isSpotColor()));
if (color.isRegistrationColor())
docu.writeAttribute("Register", static_cast<int>(color.isRegistrationColor()));
}
}
 
void Scribus150Format::writeGradients(ScXmlStreamWriter & docu, bool part)
/trunk/Scribus/scribus/plugins/gettext/xtgim/xtgscanner.cpp
1103,7 → 1103,7
double m = getToken().toDouble();
double y = getToken().toDouble();
double k = getToken().toDouble();
tmp.setColor(qRound(c * 2.55), qRound(m * 255), qRound(y * 255), qRound(k * 255));
tmp.setColorF(c / 100.0, m / 100.0, y / 100.0, k / 100.0);
tmp.setSpotColor(isSpot);
tmp.setRegistrationColor(false);
doc->PageColors.tryAddColor(sfcName, tmp);
1120,7 → 1120,7
double r = getToken().toDouble();
double g = getToken().toDouble();
double b = getToken().toDouble();
tmp.setColorRGB(qRound(r * 2.55), qRound(g * 255), qRound(b * 255));
tmp.setRgbColorF(r / 100.0, g / 100.0, b / 100.0);
tmp.setSpotColor(isSpot);
tmp.setRegistrationColor(false);
doc->PageColors.tryAddColor(sfcName, tmp);
1132,7 → 1132,7
 
void XtgScanner::definePStyles()
{
QString s1,s2,s3;
QString s1, s2, s3;
enterState(stringMode);
define = 2;
if (token == "[S\"")
/trunk/Scribus/scribus/plugins/import/ai/importai.cpp
1107,11 → 1107,7
Code >> m;
Code >> y;
Code >> k;
int Cc = qRound(c * 255);
int Mc = qRound(m * 255);
int Yc = qRound(y * 255);
int Kc = qRound(k * 255);
tmp.setColor(Cc, Mc, Yc, Kc);
tmp.setColorF(c, m, y, k);
tmp.setSpotColor(false);
tmp.setRegistrationColor(false);
QString namPrefix = "FromAI";
1133,8 → 1129,7
ColorList::Iterator it;
ScTextStream Code(&data, QIODevice::ReadOnly);
Code >> k;
int Kc = 255 - qRound(k * 255);
tmp.setColor(0, 0, 0, Kc);
tmp.setColorF(0, 0, 0, 1.0 - k);
tmp.setSpotColor(false);
tmp.setRegistrationColor(false);
QString namPrefix = "FromAI";
1157,10 → 1152,7
Code >> r;
Code >> g;
Code >> b;
int Rc = qRound(r * 255);
int Gc = qRound(g * 255);
int Bc = qRound(b * 255);
tmp.setColorRGB(Rc, Gc, Bc);
tmp.setRgbColorF(r, g, b);
tmp.setSpotColor(false);
tmp.setRegistrationColor(false);
QString namPrefix = "FromAI";
1192,11 → 1184,7
ScTextStream Val(&FarSha, QIODevice::ReadOnly);
Val >> sh;
shade = (1.0 - sh) * 100.0;
int Cc = qRound(c * 255);
int Mc = qRound(m * 255);
int Yc = qRound(y * 255);
int Kc = qRound(k * 255);
tmp.setColor(Cc, Mc, Yc, Kc);
tmp.setColorF(c, m, y, k);
tmp.setSpotColor(true);
tmp.setRegistrationColor(false);
QString fNam = m_Doc->PageColors.tryAddColor(FarNam, tmp);
1220,10 → 1208,7
Code >> r;
Code >> g;
Code >> b;
int Rc = qRound(r * 255);
int Gc = qRound(g * 255);
int Bc = qRound(b * 255);
tmp.setColorRGB(Rc, Gc, Bc);
tmp.setRgbColorF(r, g, b);
meshColorMode = 1;
}
else
1232,11 → 1217,7
Code >> m;
Code >> y;
Code >> k;
int Cc = qRound(c * 255);
int Mc = qRound(m * 255);
int Yc = qRound(y * 255);
int Kc = qRound(k * 255);
tmp.setColor(Cc, Mc, Yc, Kc);
tmp.setColorF(c, m, y, k);
meshColorMode = 0;
}
int an = data.indexOf("(");
2252,7 → 2233,7
}
else if (meshColorMode == 1)
{
tmpColor.setColorRGB(Cc, Mc, Yc);
tmpColor.setRgbColor(Cc, Mc, Yc);
for (it = m_Doc->PageColors.begin(); it != m_Doc->PageColors.end(); ++it)
{
if (it.value().getColorModel() == colorModelRGB)
/trunk/Scribus/scribus/plugins/import/emf/importemf.cpp
3370,7 → 3370,7
QString EmfPlug::handleColor(QColor col)
{
ScColor tmp;
tmp.setColorRGB(col.red(), col.green(), col.blue());
tmp.setRgbColor(col.red(), col.green(), col.blue());
tmp.setSpotColor(false);
tmp.setRegistrationColor(false);
QString tmpName = "FromEMF"+col.name().toUpper();
/trunk/Scribus/scribus/plugins/import/idml/importidml.cpp
785,7 → 785,7
ScColor tmp;
ScTextStream Code(&colorData, QIODevice::ReadOnly);
Code >> c >> m >> y >> k;
tmp.setColor(qRound(c * 2.55), qRound(m * 2.55), qRound(y * 2.55), qRound(k * 2.55));
tmp.setColorF(c / 100.0, m / 100.0, y / 100.0, k / 100.0);
tmp.setSpotColor(colorModel == "Spot");
tmp.setRegistrationColor(colorModel == "Registration");
QString fNam = m_Doc->PageColors.tryAddColor(colorName, tmp);
799,7 → 799,7
ScColor tmp;
ScTextStream Code(&colorData, QIODevice::ReadOnly);
Code >> r >> g >> b;
tmp.setColorRGB(r, g, b);
tmp.setRgbColor(r, g, b);
tmp.setSpotColor(false);
tmp.setRegistrationColor(false);
QString fNam = m_Doc->PageColors.tryAddColor(colorName, tmp);
847,15 → 847,15
ScColor res;
if (tmp.getColorModel() == colorModelCMYK)
{
int c, m, y, k;
double c, m, y, k;
tmp.getCMYK(&c, &m, &y, &k);
res.setColor(qRound(c * tint), qRound(m * tint), qRound(y * tint), qRound(k * tint));
res.setColorF(c * tint, m * tint, y * tint, k * tint);
}
else
{
int r, g, b;
double r, g, b;
tmp.getRGB(&r, &g, &b);
res.setColorRGB(qRound(r * tint), qRound(g * tint), qRound(b * tint));
res.setRgbColorF(r * tint, g * tint, b * tint);
}
res.setSpotColor(false);
res.setRegistrationColor(false);
/trunk/Scribus/scribus/plugins/import/pages/importpages.cpp
1173,16 → 1173,14
}
else if (type == "sfa:calibrated-rgb-color-type")
{
QColor c;
double r = spg.attribute("sfa:r", "1").toDouble();
double g = spg.attribute("sfa:g", "1").toDouble();
double b = spg.attribute("sfa:b", "1").toDouble();
c.setRgbF(r, g, b);
ScColor tmp;
tmp.fromQColor(c);
tmp.setRgbColorF(r, g, b);
tmp.setSpotColor(false);
tmp.setRegistrationColor(false);
QString newColorName = "FromPages"+c.name();
QString newColorName = "FromPages" + tmp.name();
QString fNam = m_Doc->PageColors.tryAddColor(newColorName, tmp);
if (fNam == newColorName)
importedColors.append(newColorName);
1190,12 → 1188,12
}
else if (type == "sfa:device-cmyk-color-type")
{
int c = qRound(spg.attribute("sfa:c", "1").toDouble() * 255);
int m = qRound(spg.attribute("sfa:m", "1").toDouble() * 255);
int y = qRound(spg.attribute("sfa:y", "1").toDouble() * 255);
int k = qRound(spg.attribute("sfa:k", "1").toDouble() * 255);
double c = spg.attribute("sfa:c", "1").toDouble();
double m = spg.attribute("sfa:m", "1").toDouble();
double y = spg.attribute("sfa:y", "1").toDouble();
double k = spg.attribute("sfa:k", "1").toDouble();
ScColor tmp;
tmp.setColor(c, m, y, k);
tmp.setColorF(c, m, y, k);
tmp.setSpotColor(false);
tmp.setRegistrationColor(false);
QString newColorName = "FromPages"+tmp.name();
1284,16 → 1282,14
}
else if (type == "sfa:calibrated-rgb-color-type")
{
QColor c;
double r = spg.attribute("sfa:r", "1").toDouble();
double g = spg.attribute("sfa:g", "1").toDouble();
double b = spg.attribute("sfa:b", "1").toDouble();
c.setRgbF(r, g, b);
ScColor tmp;
tmp.fromQColor(c);
tmp.setRgbColorF(r, g, b);
tmp.setSpotColor(false);
tmp.setRegistrationColor(false);
QString newColorName = "FromPages"+c.name();
QString newColorName = "FromPages" + tmp.name();
QString fNam = m_Doc->PageColors.tryAddColor(newColorName, tmp);
if (fNam == newColorName)
importedColors.append(newColorName);
1301,15 → 1297,15
}
else if (type == "sfa:device-cmyk-color-type")
{
int c = qRound(spg.attribute("sfa:c", "1").toDouble() * 255);
int m = qRound(spg.attribute("sfa:m", "1").toDouble() * 255);
int y = qRound(spg.attribute("sfa:y", "1").toDouble() * 255);
int k = qRound(spg.attribute("sfa:k", "1").toDouble() * 255);
double c = spg.attribute("sfa:c", "1").toDouble();
double m = spg.attribute("sfa:m", "1").toDouble();
double y = spg.attribute("sfa:y", "1").toDouble();
double k = spg.attribute("sfa:k", "1").toDouble();
ScColor tmp;
tmp.setColor(c, m, y, k);
tmp.setColorF(c, m, y, k);
tmp.setSpotColor(false);
tmp.setRegistrationColor(false);
QString newColorName = "FromPages"+tmp.name();
QString newColorName = "FromPages" + tmp.name();
QString fNam = m_Doc->PageColors.tryAddColor(newColorName, tmp);
if (fNam == newColorName)
importedColors.append(newColorName);
1417,16 → 1413,14
}
else if (type == "sfa:calibrated-rgb-color-type")
{
QColor c;
double r = sph.attribute("sfa:r", "1").toDouble();
double g = sph.attribute("sfa:g", "1").toDouble();
double b = sph.attribute("sfa:b", "1").toDouble();
c.setRgbF(r, g, b);
ScColor tmp;
tmp.fromQColor(c);
tmp.setRgbColorF(r, g, b);
tmp.setSpotColor(false);
tmp.setRegistrationColor(false);
QString newColorName = "FromPages"+c.name();
QString newColorName = "FromPages" + tmp.name();
QString fNam = m_Doc->PageColors.tryAddColor(newColorName, tmp);
if (fNam == newColorName)
importedColors.append(newColorName);
1434,12 → 1428,12
}
else if (type == "sfa:device-cmyk-color-type")
{
int c = qRound(sph.attribute("sfa:c", "1").toDouble() * 255);
int m = qRound(sph.attribute("sfa:m", "1").toDouble() * 255);
int y = qRound(sph.attribute("sfa:y", "1").toDouble() * 255);
int k = qRound(sph.attribute("sfa:k", "1").toDouble() * 255);
double c = sph.attribute("sfa:c", "1").toDouble();
double m = sph.attribute("sfa:m", "1").toDouble();
double y = sph.attribute("sfa:y", "1").toDouble();
double k = sph.attribute("sfa:k", "1").toDouble();
ScColor tmp;
tmp.setColor(c, m, y, k);
tmp.setColorF(c, m, y, k);
tmp.setSpotColor(false);
tmp.setRegistrationColor(false);
QString newColorName = "FromPages"+tmp.name();
1480,16 → 1474,14
}
else if (type == "sfa:calibrated-rgb-color-type")
{
QColor c;
double r = spg.attribute("sfa:r", "1").toDouble();
double g = spg.attribute("sfa:g", "1").toDouble();
double b = spg.attribute("sfa:b", "1").toDouble();
c.setRgbF(r, g, b);
ScColor tmp;
tmp.fromQColor(c);
tmp.setRgbColorF(r, g, b);
tmp.setSpotColor(false);
tmp.setRegistrationColor(false);
QString newColorName = "FromPages"+c.name();
QString newColorName = "FromPages" + tmp.name();
QString fNam = m_Doc->PageColors.tryAddColor(newColorName, tmp);
if (fNam == newColorName)
importedColors.append(newColorName);
1497,12 → 1489,12
}
else if (type == "sfa:device-cmyk-color-type")
{
int c = qRound(spg.attribute("sfa:c", "1").toDouble() * 255);
int m = qRound(spg.attribute("sfa:m", "1").toDouble() * 255);
int y = qRound(spg.attribute("sfa:y", "1").toDouble() * 255);
int k = qRound(spg.attribute("sfa:k", "1").toDouble() * 255);
double c = spg.attribute("sfa:c", "1").toDouble();
double m = spg.attribute("sfa:m", "1").toDouble();
double y = spg.attribute("sfa:y", "1").toDouble();
double k = spg.attribute("sfa:k", "1").toDouble();
ScColor tmp;
tmp.setColor(c, m, y, k);
tmp.setColorF(c, m, y, k);
tmp.setSpotColor(false);
tmp.setRegistrationColor(false);
QString newColorName = "FromPages"+tmp.name();
/trunk/Scribus/scribus/plugins/import/pct/importpct.cpp
1130,7 → 1130,7
greenC = qRound((Gc / 65535.0) * 255.0);
blueC = qRound((Bc / 65535.0) * 255.0);
QColor c = QColor(redC, greenC, blueC);
tmp.setColorRGB(redC, greenC, blueC);
tmp.setRgbColor(redC, greenC, blueC);
tmp.setSpotColor(false);
tmp.setRegistrationColor(false);
tmpName = "FromPict"+c.name();
1163,7 → 1163,7
greenC = qRound((Gc / 65535.0) * 255.0);
blueC = qRound((Bc / 65535.0) * 255.0);
QColor c = QColor(redC, greenC, blueC);
tmp.setColorRGB(redC, greenC, blueC);
tmp.setRgbColor(redC, greenC, blueC);
tmp.setSpotColor(false);
tmp.setRegistrationColor(false);
tmpName = "FromPict"+c.name();
/trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
20,9 → 20,9
#include "util_math.h"
#include <tiffio.h>
 
#define POPPLER_VERSION_ENCODE(major, minor, micro) ( \
((major) * 10000) \
+ ((minor) * 100) \
#define POPPLER_VERSION_ENCODE(major, minor, micro) ( \
((major) * 10000) \
+ ((minor) * 100) \
+ ((micro) * 1))
#define POPPLER_ENCODED_VERSION POPPLER_VERSION_ENCODE(POPPLER_VERSION_MAJOR, POPPLER_VERSION_MINOR, POPPLER_VERSION_MICRO)
 
201,10 → 201,10
{
GfxRGB rgb;
color_space->getRGB(color, &rgb);
int Rc = qRound(colToDbl(rgb.r) * 255);
int Gc = qRound(colToDbl(rgb.g) * 255);
int Bc = qRound(colToDbl(rgb.b) * 255);
tmp.setColorRGB(Rc, Gc, Bc);
double Rc = colToDbl(rgb.r);
double Gc = colToDbl(rgb.g);
double Bc = colToDbl(rgb.b);
tmp.setRgbColorF(Rc, Gc, Bc);
fNam = m_doc->PageColors.tryAddColor(namPrefix+tmp.name(), tmp);
}
else if (color_space->getMode() == csDeviceCMYK)
211,11 → 211,11
{
GfxCMYK cmyk;
color_space->getCMYK(color, &cmyk);
int Cc = qRound(colToDbl(cmyk.c) * 255);
int Mc = qRound(colToDbl(cmyk.m) * 255);
int Yc = qRound(colToDbl(cmyk.y) * 255);
int Kc = qRound(colToDbl(cmyk.k) * 255);
tmp.setColor(Cc, Mc, Yc, Kc);
double Cc = colToDbl(cmyk.c);
double Mc = colToDbl(cmyk.m);
double Yc = colToDbl(cmyk.y);
double Kc = colToDbl(cmyk.k);
tmp.setColorF(Cc, Mc, Yc, Kc);
fNam = m_doc->PageColors.tryAddColor(namPrefix+tmp.name(), tmp);
}
else if ((color_space->getMode() == csCalGray) || (color_space->getMode() == csDeviceGray))
222,8 → 222,8
{
GfxGray gray;
color_space->getGray(color, &gray);
int Kc = 255 - qRound(colToDbl(gray) * 255);
tmp.setColor(0, 0, 0, Kc);
double Kc = 1.0 - colToDbl(gray);
tmp.setColorF(0, 0, 0, Kc);
fNam = m_doc->PageColors.tryAddColor(namPrefix+tmp.name(), tmp);
}
else if (color_space->getMode() == csSeparation)
230,23 → 230,23
{
GfxCMYK cmyk;
QString name = QString(((GfxSeparationColorSpace*)color_space)->getName()->getCString());
int Cc, Mc, Yc, Kc;
double Cc, Mc, Yc, Kc;
bool isRegistrationColor = (name == "All");
if (!isRegistrationColor)
{
color_space->getCMYK(color, &cmyk);
Cc = qRound(colToDbl(cmyk.c) * 255);
Mc = qRound(colToDbl(cmyk.m) * 255);
Yc = qRound(colToDbl(cmyk.y) * 255);
Kc = qRound(colToDbl(cmyk.k) * 255);
Cc = colToDbl(cmyk.c);
Mc = colToDbl(cmyk.m);
Yc = colToDbl(cmyk.y);
Kc = colToDbl(cmyk.k);
}
else
{
Cc = Mc = Yc = Kc = 255;
Cc = Mc = Yc = Kc = 1.0;
tmp.setRegistrationColor(true);
name = "Registration";
}
tmp.setColor(Cc, Mc, Yc, Kc);
tmp.setColorF(Cc, Mc, Yc, Kc);
tmp.setSpotColor(true);
fNam = m_doc->PageColors.tryAddColor(name, tmp);
*shade = qRound(colToDbl(color->c[0]) * 100);
255,10 → 255,10
{
GfxRGB rgb;
color_space->getRGB(color, &rgb);
int Rc = qRound(colToDbl(rgb.r) * 255);
int Gc = qRound(colToDbl(rgb.g) * 255);
int Bc = qRound(colToDbl(rgb.b) * 255);
tmp.setColorRGB(Rc, Gc, Bc);
double Rc = colToDbl(rgb.r);
double Gc = colToDbl(rgb.g);
double Bc = colToDbl(rgb.b);
tmp.setRgbColorF(Rc, Gc, Bc);
fNam = m_doc->PageColors.tryAddColor(namPrefix+tmp.name(), tmp);
// qDebug() << "update fill color other colorspace" << color_space->getMode() << "treating as rgb" << Rc << Gc << Bc;
}
3965,10 → 3965,10
{
GfxRGB rgb;
color_space->getRGB(color, &rgb);
int Rc = qRound(colToDbl(rgb.r) * 255);
int Gc = qRound(colToDbl(rgb.g) * 255);
int Bc = qRound(colToDbl(rgb.b) * 255);
tmp.setColorRGB(Rc, Gc, Bc);
double Rc = colToDbl(rgb.r);
double Gc = colToDbl(rgb.g);
double Bc = colToDbl(rgb.b);
tmp.setRgbColorF(Rc, Gc, Bc);
fNam = m_doc->PageColors.tryAddColor(namPrefix+tmp.name(), tmp);
}
else if (color_space->getMode() == csDeviceCMYK)
3975,11 → 3975,11
{
GfxCMYK cmyk;
color_space->getCMYK(color, &cmyk);
int Cc = qRound(colToDbl(cmyk.c) * 255);
int Mc = qRound(colToDbl(cmyk.m) * 255);
int Yc = qRound(colToDbl(cmyk.y) * 255);
int Kc = qRound(colToDbl(cmyk.k) * 255);
tmp.setColor(Cc, Mc, Yc, Kc);
double Cc = colToDbl(cmyk.c);
double Mc = colToDbl(cmyk.m);
double Yc = colToDbl(cmyk.y);
double Kc = colToDbl(cmyk.k);
tmp.setColorF(Cc, Mc, Yc, Kc);
fNam = m_doc->PageColors.tryAddColor(namPrefix+tmp.name(), tmp);
}
else if ((color_space->getMode() == csCalGray) || (color_space->getMode() == csDeviceGray))
3986,8 → 3986,8
{
GfxGray gray;
color_space->getGray(color, &gray);
int Kc = 255 - qRound(colToDbl(gray) * 255);
tmp.setColor(0, 0, 0, Kc);
double Kc = 1.0 - colToDbl(gray);
tmp.setColorF(0, 0, 0, Kc);
fNam = m_doc->PageColors.tryAddColor(namPrefix+tmp.name(), tmp);
}
else if (color_space->getMode() == csSeparation)
3994,23 → 3994,23
{
GfxCMYK cmyk;
QString name = QString(((GfxSeparationColorSpace*)color_space)->getName()->getCString());
int Cc, Mc, Yc, Kc;
double Cc, Mc, Yc, Kc;
bool isRegistrationColor = (name == "All");
if (!isRegistrationColor)
{
color_space->getCMYK(color, &cmyk);
Cc = qRound(colToDbl(cmyk.c) * 255);
Mc = qRound(colToDbl(cmyk.m) * 255);
Yc = qRound(colToDbl(cmyk.y) * 255);
Kc = qRound(colToDbl(cmyk.k) * 255);
Cc = colToDbl(cmyk.c);
Mc = colToDbl(cmyk.m);
Yc = colToDbl(cmyk.y);
Kc = colToDbl(cmyk.k);
}
else
{
Cc = Mc = Yc = Kc = 255;
Cc = Mc = Yc = Kc = 1.0;
tmp.setRegistrationColor(true);
name = "Registration";
}
tmp.setColor(Cc, Mc, Yc, Kc);
tmp.setColorF(Cc, Mc, Yc, Kc);
tmp.setSpotColor(true);
 
fNam = m_doc->PageColors.tryAddColor(name, tmp);
4020,10 → 4020,10
{
GfxRGB rgb;
color_space->getRGB(color, &rgb);
int Rc = qRound(colToDbl(rgb.r) * 255);
int Gc = qRound(colToDbl(rgb.g) * 255);
int Bc = qRound(colToDbl(rgb.b) * 255);
tmp.setColorRGB(Rc, Gc, Bc);
double Rc = colToDbl(rgb.r);
double Gc = colToDbl(rgb.g);
double Bc = colToDbl(rgb.b);
tmp.setRgbColorF(Rc, Gc, Bc);
fNam = m_doc->PageColors.tryAddColor(namPrefix+tmp.name(), tmp);
// qDebug() << "update fill color other colorspace" << color_space->getMode() << "treating as rgb" << Rc << Gc << Bc;
}
4044,27 → 4044,27
else if (color->getSpace() == AnnotColor::colorRGB)
{
const double *color_data = color->getValues();
int Rc = qRound(color_data[0] * 255);
int Gc = qRound(color_data[1] * 255);
int Bc = qRound(color_data[2] * 255);
tmp.setColorRGB(Rc, Gc, Bc);
double Rc = color_data[0];
double Gc = color_data[1];
double Bc = color_data[2];
tmp.setRgbColorF(Rc, Gc, Bc);
fNam = m_doc->PageColors.tryAddColor(namPrefix+tmp.name(), tmp);
}
else if (color->getSpace() == AnnotColor::colorCMYK)
{
const double *color_data = color->getValues();
int Cc = qRound(color_data[0] * 255);
int Mc = qRound(color_data[1] * 255);
int Yc = qRound(color_data[2] * 255);
int Kc = qRound(color_data[3] * 255);
tmp.setColor(Cc, Mc, Yc, Kc);
double Cc = color_data[0];
double Mc = color_data[1];
double Yc = color_data[2];
double Kc = color_data[3];
tmp.setColorF(Cc, Mc, Yc, Kc);
fNam = m_doc->PageColors.tryAddColor(namPrefix+tmp.name(), tmp);
}
else if (color->getSpace() == AnnotColor::colorGray)
{
const double *color_data = color->getValues();
int Kc = 255 - qRound(color_data[0] * 255);
tmp.setColor(0, 0, 0, Kc);
double Kc = 1.0 - color_data[0];
tmp.setColorF(0, 0, 0, Kc);
fNam = m_doc->PageColors.tryAddColor(namPrefix+tmp.name(), tmp);
}
if (fNam == namPrefix+tmp.name())
/trunk/Scribus/scribus/plugins/import/svm/importsvm.cpp
2404,7 → 2404,7
QString SvmPlug::handleColor(QColor col)
{
ScColor tmp;
tmp.setColorRGB(col.red(), col.green(), col.blue());
tmp.setRgbColor(col.red(), col.green(), col.blue());
tmp.setSpotColor(false);
tmp.setRegistrationColor(false);
QString tmpName = "FromSVM"+col.name().toUpper();
/trunk/Scribus/scribus/plugins/import/viva/importviva.cpp
529,7 → 529,7
int r = grs.attribute("vc:red", "0").toInt();
int g = grs.attribute("vc:green", "0").toInt();
int b = grs.attribute("vc:blue", "0").toInt();
tmp.setColorRGB(r, g, b);
tmp.setRgbColor(r, g, b);
break;
}
else if (grs.tagName() == "vc:cmyk")
558,7 → 558,7
int r = e.attribute("vc:red", "0").toInt();
int g = e.attribute("vc:green", "0").toInt();
int b = e.attribute("vc:blue", "0").toInt();
tmp.setColorRGB(r, g, b);
tmp.setRgbColor(r, g, b);
break;
}
else if (grs.tagName() == "vc:spotColor")
577,7 → 577,7
int g = e.attribute("vc:green", "0").toInt();
int b = e.attribute("vc:blue", "0").toInt();
ScColor tmp;
tmp.setColorRGB(r, g, b);
tmp.setRgbColor(r, g, b);
tmp.setSpotColor(false);
tmp.setRegistrationColor(false);
QString fNam = m_Doc->PageColors.tryAddColor(colorName, tmp);
/trunk/Scribus/scribus/plugins/import/wpg/importwpg.cpp
122,7 → 122,7
Rc = pen.foreColor.red;
Gc = pen.foreColor.green;
Bc = pen.foreColor.blue;
tmp.setColorRGB(Rc, Gc, Bc);
tmp.setRgbColor(Rc, Gc, Bc);
tmp.setSpotColor(false);
tmp.setRegistrationColor(false);
QString newColorName = "FromWPG"+tmp.name();
184,7 → 184,7
Rc = brush.foreColor.red;
Gc = brush.foreColor.green;
Bc = brush.foreColor.blue;
tmp.setColorRGB(Rc, Gc, Bc);
tmp.setRgbColor(Rc, Gc, Bc);
tmp.setSpotColor(false);
tmp.setRegistrationColor(false);
QString newColorName = "FromWPG"+tmp.name();
206,7 → 206,7
Rc = brush.gradient.stopColor(c).red;
Gc = brush.gradient.stopColor(c).green;
Bc = brush.gradient.stopColor(c).blue;
tmp.setColorRGB(Rc, Gc, Bc);
tmp.setRgbColor(Rc, Gc, Bc);
tmp.setSpotColor(false);
tmp.setRegistrationColor(false);
QString newColorName = "FromWPG"+tmp.name();
/trunk/Scribus/scribus/plugins/import/xar/importxar.cpp
3459,11 → 3459,7
{
if (colorModel == 3)
{
int Cc = qRound(c1 * 255);
int Mc = qRound(c2 * 255);
int Yc = qRound(c3 * 255);
int Kc = qRound(c4 * 255);
tmp.setColor(Cc, Mc, Yc, Kc);
tmp.setColorF(c1, c2, c3, c4);
if (colorType == 1)
tmp.setSpotColor(true);
else
3470,7 → 3466,7
tmp.setSpotColor(false);
tmp.setRegistrationColor(false);
if (XarName.isEmpty())
tmpName = "FromXara"+c.name();
tmpName = "FromXara" + c.name();
else
tmpName = XarName;
QString fNam = m_Doc->PageColors.tryAddColor(tmpName, tmp);
3480,7 → 3476,7
}
else
{
tmp.setColorRGB(Rc, Gc, Bc);
tmp.setRgbColor(Rc, Gc, Bc);
tmp.setSpotColor(false);
tmp.setRegistrationColor(false);
if (XarName.isEmpty())
3495,7 → 3491,7
}
else
{
tmp.setColorRGB(Rc, Gc, Bc);
tmp.setRgbColor(Rc, Gc, Bc);
tmp.setSpotColor(false);
tmp.setRegistrationColor(false);
if (XarName.isEmpty())
3527,7 → 3523,7
quint8 Rc, Gc, Bc;
ts >> Rc >> Gc >> Bc;
QColor c = QColor(Rc, Gc, Bc);
tmp.setColorRGB(Rc, Gc, Bc);
tmp.setRgbColor(Rc, Gc, Bc);
tmp.setSpotColor(false);
tmp.setRegistrationColor(false);
tmpName = "FromXara"+c.name();
/trunk/Scribus/scribus/plugins/scriptplugin/cmdcolor.cpp
54,6 → 54,32
return Py_BuildValue("(iiii)", static_cast<long>(c), static_cast<long>(m), static_cast<long>(y), static_cast<long>(k));
}
 
PyObject *scribus_getcolorfloat(PyObject* /* self */, PyObject* args)
{
ColorList edc;
char *Name = const_cast<char*>("");
double c, m, y, k;
if (!PyArg_ParseTuple(args, "es", "utf-8", &Name))
return NULL;
if (strcmp(Name, "") == 0)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot get a color with an empty name.","python error").toLocal8Bit().constData());
return NULL;
}
edc = ScCore->primaryMainWindow()->HaveDoc ? ScCore->primaryMainWindow()->doc->PageColors : PrefsManager::instance()->colorSet();
ScribusDoc* currentDoc = ScCore->primaryMainWindow()->HaveDoc ? ScCore->primaryMainWindow()->doc : NULL;
QString col = QString::fromUtf8(Name);
if (!edc.contains(col))
{
PyErr_SetString(NotFoundError, QObject::tr("Color not found.","python error").toLocal8Bit().constData());
return NULL;
}
CMYKColorF cmykValues;
ScColorEngine::getCMYKValues(edc[col], currentDoc, cmykValues);
cmykValues.getValues(c, m, y, k);
return Py_BuildValue("(dddd)", c * 100.0, m * 100.0, y * 100.0, k * 100.0);
}
 
PyObject *scribus_getcolorasrgb(PyObject* /* self */, PyObject* args)
{
ColorList edc;
77,6 → 103,32
return Py_BuildValue("(iii)", static_cast<long>(rgb.red()), static_cast<long>(rgb.green()), static_cast<long>(rgb.blue()));
}
 
PyObject *scribus_getcolorasrgbfloat(PyObject* /* self */, PyObject* args)
{
ColorList edc;
double r, g, b;
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "es", "utf-8", &Name))
return NULL;
if (strcmp(Name, "") == 0)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot get a color with an empty name.","python error").toLocal8Bit().constData());
return NULL;
}
edc = ScCore->primaryMainWindow()->HaveDoc ? ScCore->primaryMainWindow()->doc->PageColors : PrefsManager::instance()->colorSet();
ScribusDoc* currentDoc = ScCore->primaryMainWindow()->HaveDoc ? ScCore->primaryMainWindow()->doc : NULL;
QString col = QString::fromUtf8(Name);
if (!edc.contains(col))
{
PyErr_SetString(NotFoundError, QObject::tr("Color not found.","python error").toLocal8Bit().constData());
return NULL;
}
RGBColorF rgbValues;
ScColorEngine::getRGBValues(edc[col], currentDoc, rgbValues);
rgbValues.getValues(r, g, b);
return Py_BuildValue("(ddd)", r * 255.0, g * 255.0, b * 255.0);
}
 
PyObject *scribus_setcolor(PyObject* self, PyObject* args)
{
return scribus_setcolorcmyk(self, args);
101,7 → 153,7
PyErr_SetString(NotFoundError, QObject::tr("Color not found in document.","python error").toLocal8Bit().constData());
return NULL;
}
ScCore->primaryMainWindow()->doc->PageColors[col].setColor(c, m, y, k);
ScCore->primaryMainWindow()->doc->PageColors[col].setCmykColor(c, m, y, k);
}
else
{
111,13 → 163,49
PyErr_SetString(NotFoundError, QObject::tr("Color not found in default colors.","python error").toLocal8Bit().constData());
return NULL;
}
(*colorList)[col].setColor(c, m, y, k);
(*colorList)[col].setCmykColor(c, m, y, k);
}
// Py_INCREF(Py_None);
// return Py_None;
Py_RETURN_NONE;
}
 
PyObject *scribus_setcolorcmykfloat(PyObject* /* self */, PyObject* args)
{
char *Name = const_cast<char*>("");
double c, m, y, k;
if (!PyArg_ParseTuple(args, "esdddd", "utf-8", &Name, &c, &m, &y, &k))
return NULL;
if (strcmp(Name, "") == 0)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot change a color with an empty name.","python error").toLocal8Bit().constData());
return NULL;
}
QString col = QString::fromUtf8(Name);
c = qMax(0.0, qMin(c , 100.0)) / 100.0;
m = qMax(0.0, qMin(m , 100.0)) / 100.0;
y = qMax(0.0, qMin(y , 100.0)) / 100.0;
k = qMax(0.0, qMin(k , 100.0)) / 100.0;
if (ScCore->primaryMainWindow()->HaveDoc)
{
if (!ScCore->primaryMainWindow()->doc->PageColors.contains(col))
{
PyErr_SetString(NotFoundError, QObject::tr("Color not found in document.","python error").toLocal8Bit().constData());
return NULL;
}
ScCore->primaryMainWindow()->doc->PageColors[col].setCmykColorF(c, m, y, k);
}
else
{
ColorList* colorList=PrefsManager::instance()->colorSetPtr();
if (!colorList->contains(col))
{
PyErr_SetString(NotFoundError, QObject::tr("Color not found in default colors.","python error").toLocal8Bit().constData());
return NULL;
}
(*colorList)[col].setCmykColorF(c, m, y, k);
}
Py_RETURN_NONE;
}
 
PyObject *scribus_setcolorrgb(PyObject* /* self */, PyObject* args)
{
char *Name = const_cast<char*>("");
137,7 → 225,7
PyErr_SetString(NotFoundError, QObject::tr("Color not found in document.","python error").toLocal8Bit().constData());
return NULL;
}
ScCore->primaryMainWindow()->doc->PageColors[col].setColorRGB(r, g, b);
ScCore->primaryMainWindow()->doc->PageColors[col].setRgbColor(r, g, b);
}
else
{
147,13 → 235,85
PyErr_SetString(NotFoundError, QObject::tr("Color not found in default colors.","python error").toLocal8Bit().constData());
return NULL;
}
(*colorList)[col].setColorRGB(r, g, b);
(*colorList)[col].setRgbColor(r, g, b);
}
// Py_INCREF(Py_None);
// return Py_None;
Py_RETURN_NONE;
}
 
PyObject *scribus_setcolorrgbfloat(PyObject* /* self */, PyObject* args)
{
char *Name = const_cast<char*>("");
double r, g, b;
if (!PyArg_ParseTuple(args, "esddd", "utf-8", &Name, &r, &g, &b))
return NULL;
if (strcmp(Name, "") == 0)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot change a color with an empty name.","python error").toLocal8Bit().constData());
return NULL;
}
QString col = QString::fromUtf8(Name);
r = qMax(0.0, qMin(r, 255.0)) / 255.0;
g = qMax(0.0, qMin(g, 255.0)) / 255.0;
b = qMax(0.0, qMin(b, 255.0)) / 255.0;
if (ScCore->primaryMainWindow()->HaveDoc)
{
if (!ScCore->primaryMainWindow()->doc->PageColors.contains(col))
{
PyErr_SetString(NotFoundError, QObject::tr("Color not found in document.","python error").toLocal8Bit().constData());
return NULL;
}
ScCore->primaryMainWindow()->doc->PageColors[col].setRgbColorF(r, g, b);
}
else
{
ColorList* colorList = PrefsManager::instance()->colorSetPtr();
if (!colorList->contains(col))
{
PyErr_SetString(NotFoundError, QObject::tr("Color not found in default colors.","python error").toLocal8Bit().constData());
return NULL;
}
(*colorList)[col].setRgbColorF(r, g, b);
}
Py_RETURN_NONE;
}
 
PyObject *scribus_setcolorlab(PyObject* /* self */, PyObject* args)
{
char *Name = const_cast<char*>("");
double L, a, b;
if (!PyArg_ParseTuple(args, "esddd", "utf-8", &Name, &L, &a, &b))
return NULL;
if (strcmp(Name, "") == 0)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot change a color with an empty name.", "python error").toLocal8Bit().constData());
return NULL;
}
QString col = QString::fromUtf8(Name);
L = qMax(0.0, qMin(L, 100.0));
a = qMax(-128.0, qMin(a, 128.0));
b = qMax(-128.0, qMin(b, 128.0));
if (ScCore->primaryMainWindow()->HaveDoc)
{
if (!ScCore->primaryMainWindow()->doc->PageColors.contains(col))
{
PyErr_SetString(NotFoundError, QObject::tr("Color not found in document.", "python error").toLocal8Bit().constData());
return NULL;
}
ScCore->primaryMainWindow()->doc->PageColors[col].setLabColor(L, a, b);
}
else
{
ColorList* colorList = PrefsManager::instance()->colorSetPtr();
if (!colorList->contains(col))
{
PyErr_SetString(NotFoundError, QObject::tr("Color not found in default colors.", "python error").toLocal8Bit().constData());
return NULL;
}
(*colorList)[col].setLabColor(L, a, b);
}
Py_RETURN_NONE;
}
 
PyObject *scribus_newcolor(PyObject* self, PyObject* args)
{
return scribus_newcolorcmyk(self, args);
178,7 → 338,7
else
// FIXME: Given that we have a changeColour function, should we really be
// silently changing colours in newColour?
ScCore->primaryMainWindow()->doc->PageColors[col].setColor(c, m, y, k);
ScCore->primaryMainWindow()->doc->PageColors[col].setCmykColor(c, m, y, k);
}
else
{
188,13 → 348,61
else
// FIXME: Given that we have a changeColour function, should we really be
// silently changing colours in newColour?
(*colorList)[col].setColor(c, m, y, k);
(*colorList)[col].setCmykColor(c, m, y, k);
}
// Py_INCREF(Py_None);
// return Py_None;
Py_RETURN_NONE;
}
 
PyObject *scribus_newcolorcmykfloat(PyObject* /* self */, PyObject* args)
{
char *Name = const_cast<char*>("");
double c, m, y, k;
if (!PyArg_ParseTuple(args, "esdddd", "utf-8", &Name, &c, &m, &y, &k))
return NULL;
if (strcmp(Name, "") == 0)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot create a color with an empty name.","python error").toLocal8Bit().constData());
return NULL;
}
QString col = QString::fromUtf8(Name);
c = qMax(0.0, qMin(c , 100.0)) / 100.0;
m = qMax(0.0, qMin(m , 100.0)) / 100.0;
y = qMax(0.0, qMin(y , 100.0)) / 100.0;
k = qMax(0.0, qMin(k , 100.0)) / 100.0;
if (ScCore->primaryMainWindow()->HaveDoc)
{
if (!ScCore->primaryMainWindow()->doc->PageColors.contains(col))
{
ScColor tmp;
tmp.setCmykColorF(c, m, y, k);
ScCore->primaryMainWindow()->doc->PageColors.insert(col, tmp);
}
else
{
// FIXME: Given that we have a changeColour function, should we really be
// silently changing colours in newColour?
ScCore->primaryMainWindow()->doc->PageColors[col].setCmykColorF(c, m, y, k);
}
}
else
{
ColorList* colorList = PrefsManager::instance()->colorSetPtr();
if (!colorList->contains(col))
{
ScColor tmp;
tmp.setCmykColorF(c, m, y, k);
colorList->insert(col, tmp);
}
else
{
// FIXME: Given that we have a changeColour function, should we really be
// silently changing colours in newColour?
(*colorList)[col].setCmykColorF(c, m, y, k);
}
}
Py_RETURN_NONE;
}
 
PyObject *scribus_newcolorrgb(PyObject* /* self */, PyObject* args)
{
char *Name = const_cast<char*>("");
214,7 → 422,7
else
// FIXME: Given that we have a changeColour function, should we really be
// silently changing colours in newColour?
ScCore->primaryMainWindow()->doc->PageColors[col].setColorRGB(r, g, b);
ScCore->primaryMainWindow()->doc->PageColors[col].setRgbColor(r, g, b);
}
else
{
224,13 → 432,109
else
// FIXME: Given that we have a changeColour function, should we really be
// silently changing colours in newColour?
(*colorList)[col].setColorRGB(r, g, b);
(*colorList)[col].setRgbColor(r, g, b);
}
// Py_INCREF(Py_None);
// return Py_None;
Py_RETURN_NONE;
}
 
PyObject *scribus_newcolorrgbfloat(PyObject* /* self */, PyObject* args)
{
char *Name = const_cast<char*>("");
double r, g, b;
if (!PyArg_ParseTuple(args, "esddd", "utf-8", &Name, &r, &g, &b))
return NULL;
if (strcmp(Name, "") == 0)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot create a color with an empty name.","python error").toLocal8Bit().constData());
return NULL;
}
QString col = QString::fromUtf8(Name);
r = qMax(0.0, qMin(r, 255.0)) / 255.0;
g = qMax(0.0, qMin(g, 255.0)) / 255.0;
b = qMax(0.0, qMin(b, 255.0)) / 255.0;
if (ScCore->primaryMainWindow()->HaveDoc)
{
if (!ScCore->primaryMainWindow()->doc->PageColors.contains(col))
{
ScColor tmp;
tmp.setRgbColorF(r, g, b);
ScCore->primaryMainWindow()->doc->PageColors.insert(col, tmp);
}
else
{
// FIXME: Given that we have a changeColour function, should we really be
// silently changing colours in newColour?
ScCore->primaryMainWindow()->doc->PageColors[col].setRgbColorF(r, g, b);
}
}
else
{
ColorList* colorList = PrefsManager::instance()->colorSetPtr();
if (!colorList->contains(col))
{
ScColor tmp;
tmp.setRgbColorF(r, g, b);
colorList->insert(col, tmp);
}
else
{
// FIXME: Given that we have a changeColour function, should we really be
// silently changing colours in newColour?
(*colorList)[col].setRgbColorF(r, g, b);
}
}
Py_RETURN_NONE;
}
 
PyObject *scribus_newcolorlab(PyObject* /* self */, PyObject* args)
{
char *Name = const_cast<char*>("");
double L, a, b;
if (!PyArg_ParseTuple(args, "esddd", "utf-8", &Name, &L, &a, &b))
return NULL;
if (strcmp(Name, "") == 0)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot create a color with an empty name.", "python error").toLocal8Bit().constData());
return NULL;
}
QString col = QString::fromUtf8(Name);
L = qMax(0.0, qMin(L, 100.0));
a = qMax(-128.0, qMin(a, 128.0));
b = qMax(-128.0, qMin(b, 128.0));
if (ScCore->primaryMainWindow()->HaveDoc)
{
if (!ScCore->primaryMainWindow()->doc->PageColors.contains(col))
{
ScColor tmp;
tmp.setLabColor(L, a, b);
ScCore->primaryMainWindow()->doc->PageColors.insert(col, tmp);
}
else
{
// FIXME: Given that we have a changeColour function, should we really be
// silently changing colours in newColour?
ScCore->primaryMainWindow()->doc->PageColors[col].setLabColor(L, a, b);
}
}
else
{
ColorList* colorList = PrefsManager::instance()->colorSetPtr();
if (!colorList->contains(col))
{
ScColor tmp;
tmp.setLabColor(L, a, b);
colorList->insert(col, tmp);
}
else
{
// FIXME: Given that we have a changeColour function, should we really be
// silently changing colours in newColour?
(*colorList)[col].setLabColor(L, a, b);
}
}
Py_RETURN_NONE;
}
 
PyObject *scribus_delcolor(PyObject* /* self */, PyObject* args)
{
char *Name = const_cast<char*>("");
/trunk/Scribus/scribus/plugins/scriptplugin/cmdcolor.h
37,6 → 37,21
PyObject *scribus_getcolor(PyObject * /*self*/, PyObject* args);
 
/*! docstring */
PyDoc_STRVAR(scribus_getcolorfloat__doc__,
QT_TR_NOOP("getColorFloat(\"name\") -> tuple\n\
\n\
Returns a tuple (C, M, Y, K) containing the four color components of the\n\
color \"name\" from the current document. Color components are floating point\n\
values between 0 and 100. If no document is open, returns the value of the\n\
named color from the default document colors.\n\
\n\
May raise NotFoundError if the named color wasn't found.\n\
May raise ValueError if an invalid color name is specified.\n\
"));
/** Returns a CMYK tuple of the specified color. */
PyObject *scribus_getcolorfloat(PyObject * /*self*/, PyObject* args);
 
/*! docstring */
PyDoc_STRVAR(scribus_getcolorasrgb__doc__,
QT_TR_NOOP("getColorAsRGB(\"name\") -> tuple\n\
\n\
52,6 → 67,22
PyObject *scribus_getcolorasrgb(PyObject * /*self*/, PyObject* args);
 
/*! docstring */
PyDoc_STRVAR(scribus_getcolorasrgbfloat__doc__,
QT_TR_NOOP("getColorAsRGBFloat(\"name\") -> tuple\n\
\n\
Returns a tuple (R,G,B) containing the three color components of the\n\
color \"name\" from the current document, converted to the RGB color\n\
space. Color components are floating point values between 0 and 255.\n\
If no document is open, returns the value of the named color\n\
from the default document colors.\n\
\n\
May raise NotFoundError if the named color wasn't found.\n\
May raise ValueError if an invalid color name is specified.\n\
"));
/** Returns a CMYK tuple of the specified color. */
PyObject *scribus_getcolorasrgbfloat(PyObject * /*self*/, PyObject* args);
 
/*! docstring */
PyDoc_STRVAR(scribus_setcolor__doc__,
QT_TR_NOOP("changeColor(\"name\", c, m, y, k)\n\
\n\
81,6 → 112,20
PyObject *scribus_setcolorcmyk(PyObject * /*self*/, PyObject* args);
 
/*! docstring */
PyDoc_STRVAR(scribus_setcolorcmykfloat__doc__,
QT_TR_NOOP("changeColorCMYKFloat(\"name\", c, m, y, k)\n\
\n\
Changes the color \"name\" to the specified CMYK value. The color value is\n\
defined via four components c = Cyan, m = Magenta, y = Yellow and k = Black.\n\
Color components are floating point values between 0 and 100.\n\
\n\
May raise NotFoundError if the named color wasn't found.\n\
May raise ValueError if an invalid color name is specified.\n\
"));
/** Sets named color with C,M,Y,K params. */
PyObject *scribus_setcolorcmykfloat(PyObject * /*self*/, PyObject* args);
 
/*! docstring */
PyDoc_STRVAR(scribus_setcolorrgb__doc__,
QT_TR_NOOP("changeColorRGB(\"name\", r, g, b)\n\
\n\
95,6 → 140,34
PyObject *scribus_setcolorrgb(PyObject * /*self*/, PyObject* args);
 
/*! docstring */
PyDoc_STRVAR(scribus_setcolorrgbfloat__doc__,
QT_TR_NOOP("changeColorRGBFloat(\"name\", r, g, b)\n\
\n\
Changes the color \"name\" to the specified RGB value. The color value is\n\
defined via three components r = red, g = green, b = blue.\n\
Color components are floating point values between 0 and 255.\n\
\n\
May raise NotFoundError if the named color wasn't found.\n\
May raise ValueError if an invalid color name is specified.\n\
"));
/** Sets named color with R, G, B params. */
PyObject *scribus_setcolorrgbfloat(PyObject * /*self*/, PyObject* args);
 
/*! docstring */
PyDoc_STRVAR(scribus_setcolorlab__doc__,
QT_TR_NOOP("changeColorLab(\"name\", r, g, b)\n\
\n\
Changes the color \"name\" to the specified CIELab values. The color value is defined\n\
via three components: L = luminosity, a = green/red, b = blue/yellow. Color components\n\
are floating point values with L between 0 and 100, a and b between -128 and 128.\n\
\n\
May raise NotFoundError if the named color wasn't found.\n\
May raise ValueError if an invalid color name is specified.\n\
"));
/** Sets named color with R, G, B params. */
PyObject *scribus_setcolorlab(PyObject * /*self*/, PyObject* args);
 
/*! docstring */
PyDoc_STRVAR(scribus_newcolor__doc__,
QT_TR_NOOP("defineColor(\"name\", c, m, y, k)\n\
\n\
122,6 → 195,19
PyObject *scribus_newcolorcmyk(PyObject * /*self*/, PyObject* args);
 
/*! docstring */
PyDoc_STRVAR(scribus_newcolorcmykfloat__doc__,
QT_TR_NOOP("defineColorCMYKFloat(\"name\", c, m, y, k)\n\
\n\
Defines a new color \"name\". The color Value is defined via four components:\n\
c = Cyan, m = Magenta, y = Yellow and k = Black. Color components are\n\
floating point values between 0 and 100.\n\
\n\
May raise ValueError if an invalid color name is specified.\n\
"));
/** Creates new color with name, C, M, Y, K params. */
PyObject *scribus_newcolorcmykfloat(PyObject * /*self*/, PyObject* args);
 
/*! docstring */
PyDoc_STRVAR(scribus_newcolorrgb__doc__,
QT_TR_NOOP("defineColorRGB(\"name\", r, g, b)\n\
\n\
135,6 → 221,32
PyObject *scribus_newcolorrgb(PyObject * /*self*/, PyObject* args);
 
/*! docstring */
PyDoc_STRVAR(scribus_newcolorrgbfloat__doc__,
QT_TR_NOOP("defineColorRGBFloat(\"name\", r, g, b)\n\
\n\
Defines a new color \"name\". The color Value is defined via three components:\n\
r = red, g = green, b = blue. Color components are floating point values\n\
between 0 and 255.\n\
\n\
May raise ValueError if an invalid color name is specified.\n\
"));
/** Creates new color with name, R, G, B params. */
PyObject *scribus_newcolorrgbfloat(PyObject * /*self*/, PyObject* args);
 
/*! docstring */
PyDoc_STRVAR(scribus_newcolorlab__doc__,
QT_TR_NOOP("defineColorLab(\"name\", r, g, b)\n\
\n\
Defines a new color \"name\" using CIELab values. The color value is defined\n\
via three components: L = luminosity, a = green/red, b = blue/yellow. Color components\n\
are floating point values with L between 0 and 100, a and b between -128 and 128.\n\
\n\
May raise ValueError if an invalid color name is specified.\n\
"));
/** Creates new color with name, L, a, b params. */
PyObject *scribus_newcolorlab(PyObject * /*self*/, PyObject* args);
 
/*! docstring */
PyDoc_STRVAR(scribus_delcolor__doc__,
QT_TR_NOOP("deleteColor(\"name\", \"replace\")\n\
\n\
/trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
302,8 → 302,11
// 2004-11-06 cr - move aliasing to dynamically generated wrapper functions, sort methoddef
{const_cast<char*>("applyMasterPage"), scribus_applymasterpage, METH_VARARGS, tr(scribus_applymasterpage__doc__)},
{const_cast<char*>("changeColor"), scribus_setcolor, METH_VARARGS, tr(scribus_setcolor__doc__)},
{const_cast<char*>("changeColorLab"), scribus_setcolorlab, METH_VARARGS, tr(scribus_setcolorlab__doc__) },
{const_cast<char*>("changeColorRGB"), scribus_setcolorrgb, METH_VARARGS, tr(scribus_setcolorrgb__doc__)},
{const_cast<char*>("changeColorRGBFloat"), scribus_setcolorrgbfloat, METH_VARARGS, tr(scribus_setcolorrgbfloat__doc__)},
{const_cast<char*>("changeColorCMYK"), scribus_setcolorcmyk, METH_VARARGS, tr(scribus_setcolorcmyk__doc__)},
{const_cast<char*>("changeColorCMYKFloat"), scribus_setcolorcmykfloat, METH_VARARGS, tr(scribus_setcolorcmykfloat__doc__)},
{const_cast<char*>("closeDoc"), (PyCFunction)scribus_closedoc, METH_NOARGS, tr(scribus_closedoc__doc__)},
{const_cast<char*>("closeMasterPage"), (PyCFunction)scribus_closemasterpage, METH_NOARGS, tr(scribus_closemasterpage__doc__)},
{const_cast<char*>("createBezierLine"), scribus_bezierline, METH_VARARGS, tr(scribus_bezierline__doc__)},
323,8 → 326,11
{const_cast<char*>("createCustomLineStyle"), scribus_createcustomlinestyle, METH_VARARGS, tr(scribus_createcustomlinestyle__doc__)},
{const_cast<char*>("currentPage"), (PyCFunction)scribus_actualpage, METH_NOARGS, tr(scribus_actualpage__doc__)},
{const_cast<char*>("defineColor"), scribus_newcolor, METH_VARARGS, tr(scribus_newcolor__doc__)},
{const_cast<char*>("defineColorLab"), scribus_newcolorlab, METH_VARARGS, tr(scribus_newcolorlab__doc__) },
{const_cast<char*>("defineColorRGB"), scribus_newcolorrgb, METH_VARARGS, tr(scribus_newcolorrgb__doc__)},
{const_cast<char*>("defineColorRGBFloat"), scribus_newcolorrgb, METH_VARARGS, tr(scribus_newcolorrgbfloat__doc__)},
{const_cast<char*>("defineColorCMYK"), scribus_newcolorcmyk, METH_VARARGS, tr(scribus_newcolorcmyk__doc__)},
{const_cast<char*>("defineColorCMYKFloat"), scribus_newcolorcmykfloat, METH_VARARGS, tr(scribus_newcolorcmykfloat__doc__)},
{const_cast<char*>("deleteColor"), scribus_delcolor, METH_VARARGS, tr(scribus_delcolor__doc__)},
{const_cast<char*>("deleteLayer"), scribus_removelayer, METH_VARARGS, tr(scribus_removelayer__doc__)},
{const_cast<char*>("deleteMasterPage"), scribus_deletemasterpage, METH_VARARGS, tr(scribus_deletemasterpage__doc__)},
348,7 → 354,9
{const_cast<char*>("getCellFillColor"), scribus_getcellfillcolor, METH_VARARGS, tr(scribus_getcellfillcolor__doc__)},
{const_cast<char*>("getColorNames"), (PyCFunction)scribus_colornames, METH_NOARGS, tr(scribus_colornames__doc__)},
{const_cast<char*>("getColor"), scribus_getcolor, METH_VARARGS, tr(scribus_getcolor__doc__)},
{const_cast<char*>("getColorFloat"), scribus_getcolorfloat, METH_VARARGS, tr(scribus_getcolorfloat__doc__)},
{const_cast<char*>("getColorAsRGB"), scribus_getcolorasrgb, METH_VARARGS, tr(scribus_getcolorasrgb__doc__)},
{const_cast<char*>("getColorAsRGBFloat"), scribus_getcolorasrgbfloat, METH_VARARGS, tr(scribus_getcolorasrgbfloat__doc__)},
{const_cast<char*>("isSpotColor"), scribus_isspotcolor, METH_VARARGS, tr(scribus_isspotcolor__doc__)},
{const_cast<char*>("setSpotColor"), scribus_setspotcolor, METH_VARARGS, tr(scribus_setspotcolor__doc__)},
{const_cast<char*>("getTextDistances"), scribus_gettextdistances, METH_VARARGS, tr(scribus_gettextdistances__doc__)},
/trunk/Scribus/scribus/pslib.cpp
129,7 → 129,7
if (gc.isControlGlyphs() || gc.isEmpty())
return;
 
int h, s, v, k;
double h, s, v, k;
QVector<double> dum;
dum.clear();
m_ps->PS_save();
154,7 → 154,7
m_ps->putColorNoDraw(fillColor().color, fillColor().shade);
m_ps->PS_showSub(gl.glyph, m_ps->FontSubsetMap[font().scName()], fontSize(), false);
m_ps->SetColor(strokeColor().color, strokeColor().shade, &h, &s, &v, &k);
m_ps->PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
m_ps->PS_setcmykcolor_stroke(h, s, v, k);
m_ps->SetClipPath(&gly, true);
m_ps->PS_closepath();
m_ps->putColor(strokeColor().color, strokeColor().shade, false);
167,7 → 167,7
 
void PSPainter::drawRect(QRectF rect)
{
int h, s, v, k;
double h, s, v, k;
m_ps->PS_save();
applyTransform();
m_ps->PS_moveto(x() + rect.x(), -y() - rect.y());
176,7 → 176,7
m_ps->PS_lineto(x() + rect.x(), -y() - rect.y() - rect.height());
m_ps->PS_closepath();
m_ps->SetColor(fillColor().color, fillColor().shade, &h, &s, &v, &k);
m_ps->PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
m_ps->PS_setcmykcolor_fill(h, s, v, k);
m_ps->putColor(fillColor().color, fillColor().shade, true);
m_ps->PS_restore();
}
183,7 → 183,7
 
void PSPainter::drawLine(QPointF start, QPointF end)
{
int h, s, v, k ;
double h, s, v, k;
QVector<double> dum;
dum.clear();
m_ps->PS_save();
193,7 → 193,7
m_ps->PS_setcapjoin(Qt::FlatCap, Qt::MiterJoin);
m_ps->PS_setdash(Qt::SolidLine, 0, dum);
m_ps->SetColor(fillColor().color,fillColor().shade, &h, &s, &v, &k);
m_ps->PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
m_ps->PS_setcmykcolor_stroke(h, s, v, k);
}
m_ps->PS_setlinewidth(strokeWidth());
m_ps->PS_moveto(x() + start.x(), -y() - start.y());
244,9 → 244,9
GrayCalc += " oldsetgray} bind def\n";
Farben = "";
FNamen = "";
CMYKColor cmykValues;
CMYKColorF cmykValues;
ColorList::Iterator itf;
int c, m, y, k;
double c, m, y, k;
int spotCount = 1;
bool erst = true;
colorsToUse = DocColors;
264,11 → 264,11
else
colorDesc += itf.key();
colorDesc += ")\n";
colorDesc += "/DeviceCMYK\n{\ndup "+ToStr(static_cast<double>(c) / 255)+"\nmul exch dup ";
colorDesc += ToStr(static_cast<double>(m) / 255)+"\nmul exch dup ";
colorDesc += ToStr(static_cast<double>(y) / 255)+"\nmul exch ";
colorDesc += ToStr(static_cast<double>(k) / 255)+" mul }] setcolorspace setcolor} bind def\n";
spotMap.insert(itf.key(), "Spot"+QString::number(spotCount));
colorDesc += "/DeviceCMYK\n{\ndup " + ToStr(c) + "\nmul exch dup ";
colorDesc += ToStr(m) + "\nmul exch dup ";
colorDesc += ToStr(y) + "\nmul exch ";
colorDesc += ToStr(k) + " mul }] setcolorspace setcolor} bind def\n";
spotMap.insert(itf.key(), "Spot" + QString::number(spotCount));
++spotCount;
}
if ((itf.key() != "Cyan") && (itf.key() != "Magenta") && (itf.key() != "Yellow") && (itf.key() != "Black") && DocColors[itf.key()].isSpotColor())
1772,7 → 1772,7
 
bool PSLib::ProcessItem(ScribusDoc* Doc, ScPage* a, PageItem* c, uint PNr, bool sep, bool farb, bool master, bool embedded, bool useTemplate)
{
int h, s, v, k;
double h, s, v, k;
QVector<double> dum;
if (c->printEnabled())
{
1786,12 → 1786,12
if (c->fillColor() != CommonStrings::None)
{
SetColor(c->fillColor(), c->fillShade(), &h, &s, &v, &k);
PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
PS_setcmykcolor_fill(h, s, v, k);
}
if (c->lineColor() != CommonStrings::None)
{
SetColor(c->lineColor(), c->lineShade(), &h, &s, &v, &k);
PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
PS_setcmykcolor_stroke(h, s, v, k);
}
PS_setlinewidth(c->lineWidth());
PS_setcapjoin(c->PLineEnd, c->PLineJoin);
1869,7 → 1869,7
else if (c->lineColor() != CommonStrings::None)
{
SetColor(c->lineColor(), c->lineShade(), &h, &s, &v, &k);
PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
PS_setcmykcolor_stroke(h, s, v, k);
putColor(c->lineColor(), c->lineShade(), false);
}
}
1882,7 → 1882,7
if (ml[it].Color != CommonStrings::None) // && (ml[it].Width != 0))
{
SetColor(ml[it].Color, ml[it].Shade, &h, &s, &v, &k);
PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
PS_setcmykcolor_stroke(h, s, v, k);
PS_setlinewidth(ml[it].Width);
PS_setcapjoin(static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
PS_setdash(static_cast<Qt::PenStyle>(ml[it].Dash), 0, dum);
1972,7 → 1972,7
else if (c->lineColor() != CommonStrings::None)
{
SetColor(c->lineColor(), c->lineShade(), &h, &s, &v, &k);
PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
PS_setcmykcolor_stroke(h, s, v, k);
putColor(c->lineColor(), c->lineShade(), false);
}
}
1985,7 → 1985,7
if (ml[it].Color != CommonStrings::None) //&& (ml[it].Width != 0))
{
SetColor(ml[it].Color, ml[it].Shade, &h, &s, &v, &k);
PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
PS_setcmykcolor_stroke(h, s, v, k);
PS_setlinewidth(ml[it].Width);
PS_setcapjoin(static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
PS_setdash(static_cast<Qt::PenStyle>(ml[it].Dash), 0, dum);
2038,7 → 2038,7
if (ml[it].Color != CommonStrings::None) //&& (ml[it].Width != 0))
{
SetColor(ml[it].Color, ml[it].Shade, &h, &s, &v, &k);
PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
PS_setcmykcolor_stroke(h, s, v, k);
PS_setlinewidth(ml[it].Width);
PS_setcapjoin(static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
PS_setdash(static_cast<Qt::PenStyle>(ml[it].Dash), 0, dum);
2114,7 → 2114,7
if (ml[it].Color != CommonStrings::None) //&& (ml[it].Width != 0))
{
SetColor(ml[it].Color, ml[it].Shade, &h, &s, &v, &k);
PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
PS_setcmykcolor_stroke(h, s, v, k);
PS_setlinewidth(ml[it].Width);
PS_setcapjoin(static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
PS_setdash(static_cast<Qt::PenStyle>(ml[it].Dash), 0, dum);
2170,7 → 2170,7
if (ml[it].Color != CommonStrings::None) //&& (ml[it].Width != 0))
{
SetColor(ml[it].Color, ml[it].Shade, &h, &s, &v, &k);
PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
PS_setcmykcolor_stroke(h, s, v, k);
PS_setlinewidth(ml[it].Width);
PS_setcapjoin(static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
PS_setdash(static_cast<Qt::PenStyle>(ml[it].Dash), 0, dum);
2252,7 → 2252,7
if (ml[it].Color != CommonStrings::None) //&& (ml[it].Width != 0))
{
SetColor(ml[it].Color, ml[it].Shade, &h, &s, &v, &k);
PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
PS_setcmykcolor_stroke(h, s, v, k);
PS_setlinewidth(ml[it].Width);
PS_setcapjoin(static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
PS_setdash(static_cast<Qt::PenStyle>(ml[it].Dash), 0, dum);
2550,9 → 2550,9
PS_setlinewidth(line.width());
getDashArray(line.style(), qMax(line.width(), 1.0), DashValues);
PS_setdash(line.style(), 0, DashValues);
int h, s, v, k;
double h, s, v, k;
SetColor(line.color(), line.shade(), &h, &s, &v, &k);
PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
PS_setcmykcolor_stroke(h, s, v, k);
PS_setcapjoin(Qt::FlatCap, Qt::MiterJoin);
putColor(line.color(), line.shade(), false);
}
2618,7 → 2618,7
bool PSLib::ProcessMasterPageLayer(ScribusDoc* Doc, ScPage* page, ScLayer& layer, uint PNr, bool sep, bool farb)
{
bool success = true;
int h, s, v, k;
double h, s, v, k;
QVector<double> dum;
ScPage* mPage = Doc->MasterPages.at(Doc->MasterNames[page->MPageNam]);
if (layer.isPrintable)
2853,7 → 2853,7
if (ite->fillColor() != CommonStrings::None)
{
SetColor(ite->fillColor(), ite->fillShade(), &h, &s, &v, &k);
PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
PS_setcmykcolor_fill(h, s, v, k);
}
PS_translate(ite->xPos() - mPage->xOffset(), mPage->height() - (ite->yPos() - mPage->yOffset()));
if (ite->rotation() != 0)
2905,7 → 2905,7
else if (ite->lineColor() != CommonStrings::None)
{
SetColor(ite->lineColor(), ite->lineShade(), &h, &s, &v, &k);
PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
PS_setcmykcolor_stroke(h, s, v, k);
putColor(ite->lineColor(), ite->lineShade(), false);
}
}
2918,7 → 2918,7
if (ml[it].Color != CommonStrings::None) //&& (ml[it].Width != 0))
{
SetColor(ml[it].Color, ml[it].Shade, &h, &s, &v, &k);
PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
PS_setcmykcolor_stroke(h, s, v, k);
PS_setlinewidth(ml[it].Width);
PS_setcapjoin(static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
PS_setdash(static_cast<Qt::PenStyle>(ml[it].Dash), 0, dum);
2967,7 → 2967,7
if (ml[it].Color != CommonStrings::None) //&& (ml[it].Width != 0))
{
SetColor(ml[it].Color, ml[it].Shade, &h, &s, &v, &k);
PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
PS_setcmykcolor_stroke(h, s, v, k);
PS_setlinewidth(ml[it].Width);
PS_setcapjoin(static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
PS_setdash(static_cast<Qt::PenStyle>(ml[it].Dash), 0, dum);
3118,7 → 3118,7
void PSLib::HandleMeshGradient(PageItem* c)
{
QString hs,ss,vs,ks;
int ch,cs,cv,ck;
double ch,cs,cv,ck;
QStringList cols;
QStringList colorValues;
QStringList spotColorSet;
3170,7 → 3170,7
else
{
SetColor(cols.at(ac), colsSh.at(ac), &ch, &cs, &cv, &ck);
colorVal += hs.setNum(ch / 255.0)+" "+ss.setNum(cs / 255.0)+" "+vs.setNum(cv / 255.0)+" "+ks.setNum(ck / 255.0);
colorVal += hs.setNum(ch) + " " + ss.setNum(cs)+" "+vs.setNum(cv) + " " + ks.setNum(ck);
for (int sc = 0; sc < spotColorSet.count(); sc++)
{
colorVal += " 0";
3182,9 → 3182,9
{
SetColor(cols.at(ac), colsSh.at(ac), &ch, &cs, &cv, &ck);
if (GraySc)
colorVal += hs.setNum((255.0 - qMin(0.3 * ch + 0.59 * cs + 0.11 * cv + ck, 255.0)) / 255.0);
colorVal += hs.setNum(1.0 - qMin(0.3 * ch + 0.59 * cs + 0.11 * cv + ck, 1.0));
else
colorVal += hs.setNum(ch / 255.0)+" "+ss.setNum(cs / 255.0)+" "+vs.setNum(cv / 255.0)+" "+ks.setNum(ck / 255.0);
colorVal += hs.setNum(ch) + " " + ss.setNum(cs) + " " + vs.setNum(cv) + " " + ks.setNum(ck);
if (DoSep)
{
int pla = Plate - 1 < 0 ? 3 : Plate - 1;
3219,20 → 3219,17
int maxSp = spotColorSet.count() - 1;
for (int sc = 0; sc < spotColorSet.count(); sc++)
{
int cc = 0;
int mc = 0;
int yc = 0;
int kc = 0;
CMYKColor cmykValues;
double cc(0), mc(0), yc(0), kc(0);
CMYKColorF cmykValues;
ScColorEngine::getCMYKValues(m_Doc->PageColors[spotColorSet.at(maxSp - sc)], m_Doc, cmykValues);
cmykValues.getValues(cc, mc, yc, kc);
if (sc == 0)
PutStream("dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul ");
PutStream("dup " + ToStr(cc) + " mul ");
else
PutStream(IToStr(sc*4 + 1)+" -1 roll dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul ");
PutStream("exch dup "+ToStr(static_cast<double>(mc) / 255.0)+" mul ");
PutStream("exch dup "+ToStr(static_cast<double>(yc) / 255.0)+" mul ");
PutStream("exch "+ToStr(static_cast<double>(kc) / 255.0)+" mul\n");
PutStream(IToStr(sc*4 + 1) + " -1 roll dup " + ToStr(cc)+" mul ");
PutStream("exch dup " + ToStr(mc) + " mul ");
PutStream("exch dup " + ToStr(yc) + " mul ");
PutStream("exch " + ToStr(kc) + " mul\n");
}
for (int sc = 0; sc < spotColorSet.count(); sc++)
{
3295,7 → 3292,7
void PSLib::HandlePatchMeshGradient(PageItem* c)
{
QString hs,ss,vs,ks;
int ch,cs,cv,ck;
double ch,cs,cv,ck;
QStringList cols;
QStringList colorValues;
QStringList spotColorSet;
3355,7 → 3352,7
else
{
SetColor(cols.at(ac), colsSh.at(ac), &ch, &cs, &cv, &ck);
colorVal += hs.setNum(ch / 255.0)+" "+ss.setNum(cs / 255.0)+" "+vs.setNum(cv / 255.0)+" "+ks.setNum(ck / 255.0);
colorVal += hs.setNum(ch) + " " + ss.setNum(cs) + " " + vs.setNum(cv) + " " + ks.setNum(ck);
for (int sc = 0; sc < spotColorSet.count(); sc++)
{
colorVal += " 0";
3367,9 → 3364,9
{
SetColor(cols.at(ac), colsSh.at(ac), &ch, &cs, &cv, &ck);
if (GraySc)
colorVal += hs.setNum((255.0 - qMin(0.3 * ch + 0.59 * cs + 0.11 * cv + ck, 255.0)) / 255.0);
colorVal += hs.setNum(1.0 - qMin(0.3 * ch + 0.59 * cs + 0.11 * cv + ck, 1.0));
else
colorVal += hs.setNum(ch / 255.0)+" "+ss.setNum(cs / 255.0)+" "+vs.setNum(cv / 255.0)+" "+ks.setNum(ck / 255.0);
colorVal += hs.setNum(ch) + " " + ss.setNum(cs) + " " + vs.setNum(cv) + " " + ks.setNum(ck);
if (DoSep)
{
int pla = Plate - 1 < 0 ? 3 : Plate - 1;
3404,20 → 3401,17
int maxSp = spotColorSet.count() - 1;
for (int sc = 0; sc < spotColorSet.count(); sc++)
{
int cc = 0;
int mc = 0;
int yc = 0;
int kc = 0;
CMYKColor cmykValues;
double cc(0), mc(0), yc(0), kc(0);
CMYKColorF cmykValues;
ScColorEngine::getCMYKValues(m_Doc->PageColors[spotColorSet.at(maxSp - sc)], m_Doc, cmykValues);
cmykValues.getValues(cc, mc, yc, kc);
if (sc == 0)
PutStream("dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul ");
PutStream("dup " + ToStr(cc)+" mul ");
else
PutStream(IToStr(sc*4 + 1)+" -1 roll dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul ");
PutStream("exch dup "+ToStr(static_cast<double>(mc) / 255.0)+" mul ");
PutStream("exch dup "+ToStr(static_cast<double>(yc) / 255.0)+" mul ");
PutStream("exch "+ToStr(static_cast<double>(kc) / 255.0)+" mul\n");
PutStream(IToStr(sc*4 + 1) + " -1 roll dup " + ToStr(cc) + " mul ");
PutStream("exch dup " + ToStr(mc) + " mul ");
PutStream("exch dup " + ToStr(yc) + " mul ");
PutStream("exch " + ToStr(kc) + " mul\n");
}
for (int sc = 0; sc < spotColorSet.count(); sc++)
{
3479,7 → 3473,7
void PSLib::HandleDiamondGradient(PageItem* c)
{
QString hs,ss,vs,ks;
int ch,cs,cv,ck;
double ch,cs,cv,ck;
QStringList cols;
QStringList colorValues;
QStringList spotColorSet;
3536,7 → 3530,7
else
{
SetColor(cols.at(ac), colsSh.at(ac), &ch, &cs, &cv, &ck);
colorVal += hs.setNum(ch / 255.0)+" "+ss.setNum(cs / 255.0)+" "+vs.setNum(cv / 255.0)+" "+ks.setNum(ck / 255.0);
colorVal += hs.setNum(ch) + " " + ss.setNum(cs) + " " + vs.setNum(cv) + " " + ks.setNum(ck);
for (int sc = 0; sc < spotColorSet.count(); sc++)
{
colorVal += " 0";
3548,9 → 3542,9
{
SetColor(cols.at(ac), colsSh.at(ac), &ch, &cs, &cv, &ck);
if (GraySc)
colorVal += hs.setNum((255.0 - qMin(0.3 * ch + 0.59 * cs + 0.11 * cv + ck, 255.0)) / 255.0);
colorVal += hs.setNum(1.0 - qMin(0.3 * ch + 0.59 * cs + 0.11 * cv + ck, 1.0));
else
colorVal += hs.setNum(ch / 255.0)+" "+ss.setNum(cs / 255.0)+" "+vs.setNum(cv / 255.0)+" "+ks.setNum(ck / 255.0);
colorVal += hs.setNum(ch) + " " + ss.setNum(cs) + " " + vs.setNum(cv) + " " + ks.setNum(ck);
if (DoSep)
{
int pla = Plate - 1 < 0 ? 3 : Plate - 1;
3580,20 → 3574,17
int maxSp = spotColorSet.count() - 1;
for (int sc = 0; sc < spotColorSet.count(); sc++)
{
int cc = 0;
int mc = 0;
int yc = 0;
int kc = 0;
CMYKColor cmykValues;
double cc(0), mc(0), yc(0), kc(0);
CMYKColorF cmykValues;
ScColorEngine::getCMYKValues(m_Doc->PageColors[spotColorSet.at(maxSp - sc)], m_Doc, cmykValues);
cmykValues.getValues(cc, mc, yc, kc);
if (sc == 0)
PutStream("dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul ");
PutStream("dup " + ToStr(cc) + " mul ");
else
PutStream(IToStr(sc*4 + 1)+" -1 roll dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul ");
PutStream("exch dup "+ToStr(static_cast<double>(mc) / 255.0)+" mul ");
PutStream("exch dup "+ToStr(static_cast<double>(yc) / 255.0)+" mul ");
PutStream("exch "+ToStr(static_cast<double>(kc) / 255.0)+" mul\n");
PutStream(IToStr(sc*4 + 1) + " -1 roll dup " + ToStr(cc) + " mul ");
PutStream("exch dup " + ToStr(mc) + " mul ");
PutStream("exch dup " + ToStr(yc) + " mul ");
PutStream("exch " + ToStr(kc) + " mul\n");
}
for (int sc = 0; sc < spotColorSet.count(); sc++)
{
3698,7 → 3689,7
{
QString GCol;
QString hs,ss,vs,ks;
int ch,cs,cv,ck;
double ch,cs,cv,ck;
QStringList cols;
QStringList spotColorSet;
QList<int> colsSh;
3732,20 → 3723,17
int maxSp = spotColorSet.count() - 1;
for (int sc = 0; sc < spotColorSet.count(); sc++)
{
int cc = 0;
int mc = 0;
int yc = 0;
int kc = 0;
CMYKColor cmykValues;
double cc(0), mc(0), yc(0), kc(0);
CMYKColorF cmykValues;
ScColorEngine::getCMYKValues(m_Doc->PageColors[spotColorSet.at(maxSp - sc)], m_Doc, cmykValues);
cmykValues.getValues(cc, mc, yc, kc);
if (sc == 0)
PutStream("dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul ");
PutStream("dup " + ToStr(cc) + " mul ");
else
PutStream(IToStr(sc*4 + 1)+" -1 roll dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul ");
PutStream("exch dup "+ToStr(static_cast<double>(mc) / 255.0)+" mul ");
PutStream("exch dup "+ToStr(static_cast<double>(yc) / 255.0)+" mul ");
PutStream("exch "+ToStr(static_cast<double>(kc) / 255.0)+" mul\n");
PutStream(IToStr(sc*4 + 1) + " -1 roll dup " + ToStr(cc) + " mul ");
PutStream("exch dup " + ToStr(mc) + " mul ");
PutStream("exch dup " + ToStr(yc) + " mul ");
PutStream("exch " + ToStr(kc) + " mul\n");
}
for (int sc = 0; sc < spotColorSet.count(); sc++)
{
3781,7 → 3769,7
else
{
SetColor(cols.at(ac), colsSh.at(ac), &ch, &cs, &cv, &ck);
GCol = hs.setNum(ch / 255.0)+" "+ss.setNum(cs / 255.0)+" "+vs.setNum(cv / 255.0)+" "+ks.setNum(ck / 255.0);
GCol = hs.setNum(ch) +" " + ss.setNum(cs) + " " + vs.setNum(cv) + " " + ks.setNum(ck);
PutStream(GCol);
for (int sc = 0; sc < spotColorSet.count(); sc++)
{
3794,9 → 3782,9
{
SetColor(cols.at(ac), colsSh.at(ac), &ch, &cs, &cv, &ck);
if (GraySc)
GCol = hs.setNum((255.0 - qMin(0.3 * ch + 0.59 * cs + 0.11 * cv + ck, 255.0)) / 255.0);
GCol = hs.setNum(1.0 - qMin(0.3 * ch + 0.59 * cs + 0.11 * cv + ck, 1.0));
else
GCol = hs.setNum(ch / 255.0)+" "+ss.setNum(cs / 255.0)+" "+vs.setNum(cv / 255.0)+" "+ks.setNum(ck / 255.0);
GCol = hs.setNum(ch) + " " + ss.setNum(cs) + " " + vs.setNum(cv) + " " + ks.setNum(ck);
if (DoSep)
{
int pla = Plate - 1 < 0 ? 3 : Plate - 1;
3954,20 → 3942,17
int maxSp = spotColorSet.count() - 1;
for (int sc = 0; sc < spotColorSet.count(); sc++)
{
int cc = 0;
int mc = 0;
int yc = 0;
int kc = 0;
CMYKColor cmykValues;
double cc(0), mc(0), yc(0), kc(0);
CMYKColorF cmykValues;
ScColorEngine::getCMYKValues(m_Doc->PageColors[spotColorSet.at(maxSp - sc)], m_Doc, cmykValues);
cmykValues.getValues(cc, mc, yc, kc);
if (sc == 0)
PutStream("dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul ");
PutStream("dup " + ToStr(cc) + " mul ");
else
PutStream(IToStr(sc*4 + 1)+" -1 roll dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul ");
PutStream("exch dup "+ToStr(static_cast<double>(mc) / 255.0)+" mul ");
PutStream("exch dup "+ToStr(static_cast<double>(yc) / 255.0)+" mul ");
PutStream("exch "+ToStr(static_cast<double>(kc) / 255.0)+" mul\n");
PutStream(IToStr(sc*4 + 1) + " -1 roll dup " + ToStr(cc) + " mul ");
PutStream("exch dup " + ToStr(mc) + " mul ");
PutStream("exch dup " + ToStr(yc) + " mul ");
PutStream("exch " + ToStr(kc) + " mul\n");
}
for (int sc = 0; sc < spotColorSet.count(); sc++)
{
4008,7 → 3993,7
{
QString GCol, GCol2;
QString hs,ss,vs,ks;
int ch,cs,cv,ck;
double ch,cs,cv,ck;
entx += "0 1 ";
PutStream("<<\n");
PutStream("/FunctionType 2\n");
4029,7 → 4014,7
else
{
SetColor(colorNames.at(cc), colorShades.at(cc), &ch, &cs, &cv, &ck);
GCol = hs.setNum(ch / 255.0)+" "+ss.setNum(cs / 255.0)+" "+vs.setNum(cv / 255.0)+" "+ks.setNum(ck / 255.0);
GCol = hs.setNum(ch) + " " + ss.setNum(cs) + " " + vs.setNum(cv) + " " + ks.setNum(ck);
PutStream("/C0 ["+GCol);
for (int sc = 0; sc < spotColorSet.count(); sc++)
{
4051,7 → 4036,7
else
{
SetColor(colorNames.at(cc+1), colorShades.at(cc+1), &ch, &cs, &cv, &ck);
GCol2 = hs.setNum(ch / 255.0)+" "+ss.setNum(cs / 255.0)+" "+vs.setNum(cv / 255.0)+" "+ks.setNum(ck / 255.0);
GCol2 = hs.setNum(ch) + " " + ss.setNum(cs) + " " + vs.setNum(cv) + " " + ks.setNum(ck);
PutStream("/C1 ["+GCol2);
for (int sc = 0; sc < spotColorSet.count(); sc++)
{
4064,26 → 4049,26
{
SetColor(colorNames.at(cc), colorShades.at(cc), &ch, &cs, &cv, &ck);
if (GraySc)
GCol = hs.setNum((255.0 - qMin(0.3 * ch + 0.59 * cs + 0.11 * cv + ck, 255.0)) / 255.0);
GCol = hs.setNum(1.0 - qMin(0.3 * ch + 0.59 * cs + 0.11 * cv + ck, 1.0));
else
GCol = hs.setNum(ch / 255.0)+" "+ss.setNum(cs / 255.0)+" "+vs.setNum(cv / 255.0)+" "+ks.setNum(ck / 255.0);
GCol = hs.setNum(ch) + " " + ss.setNum(cs) + " " + vs.setNum(cv) + " " + ks.setNum(ck);
SetColor(colorNames.at(cc+1), colorShades.at(cc+1), &ch, &cs, &cv, &ck);
if (GraySc)
GCol2 = hs.setNum((255.0 - qMin(0.3 * ch + 0.59 * cs + 0.11 * cv + ck, 255.0)) / 255.0);
GCol2 = hs.setNum(1.0 - qMin(0.3 * ch + 0.59 * cs + 0.11 * cv + ck, 1.0));
else
GCol2 = hs.setNum(ch / 255.0)+" "+ss.setNum(cs / 255.0)+" "+vs.setNum(cv / 255.0)+" "+ks.setNum(ck / 255.0);
GCol2 = hs.setNum(ch) + " " + ss.setNum(cs) + " " + vs.setNum(cv) + " " + ks.setNum(ck);
if (DoSep)
{
int pla = Plate - 1 < 0 ? 3 : Plate - 1;
QStringList cols1 = GCol.split(" ", QString::SkipEmptyParts);
QStringList cols2 = GCol2.split(" ", QString::SkipEmptyParts);
PutStream("/C1 ["+ToStr(1 - ScCLocale::toDoubleC(cols1[pla]))+"]\n");
PutStream("/C0 ["+ToStr(1 - ScCLocale::toDoubleC(cols2[pla]))+"]\n");
PutStream("/C1 [" + ToStr(1 - ScCLocale::toDoubleC(cols1[pla])) + "]\n");
PutStream("/C0 [" + ToStr(1 - ScCLocale::toDoubleC(cols2[pla])) + "]\n");
}
else
{
PutStream("/C0 ["+GCol+"]\n");
PutStream("/C1 ["+GCol2+"]\n");
PutStream("/C0 [" + GCol + "]\n");
PutStream("/C1 [" + GCol2 +"]\n");
}
}
PutStream("/N 1\n");
4148,7 → 4133,7
{
PS_save();
QVector<double> dum;
int h, s, v, k;
double h, s, v, k;
PS_setlinewidth(1);
PS_setcapjoin(Qt::FlatCap, Qt::MiterJoin);
PS_setdash(Qt::SolidLine, 0, dum);
4155,7 → 4140,7
if ((currItem->hatchBackground != CommonStrings::None) && (currItem->hatchUseBackground))
{
SetColor(currItem->hatchBackground, 100, &h, &s, &v, &k);
PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
PS_setcmykcolor_fill(h, s, v, k);
putColor(currItem->hatchBackground, 100, true);
SetPathAndClip(currItem->PoLine, currItem->fillRule);
}
4164,7 → 4149,7
if (currItem->hatchForeground != CommonStrings::None)
{
SetColor(currItem->hatchForeground, 100, &h, &s, &v, &k);
PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
PS_setcmykcolor_stroke(h, s, v, k);
}
PS_translate(currItem->width() / 2.0, -currItem->height() / 2.0);
double lineLen = sqrt((currItem->width() / 2.0) * (currItem->width() / 2.0) + (currItem->height() / 2.0) * (currItem->height() / 2.0));
4229,13 → 4214,13
if (currItem->lineColor() != CommonStrings::None)
{
SetColor(currItem->lineColor(), currItem->lineShade(), &h, &s, &v, &k);
PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
PS_setcmykcolor_stroke(h, s, v, k);
}
}
 
void PSLib::drawArrow(PageItem *ite, QTransform &arrowTrans, int arrowIndex)
{
int h, s, v, k;
double h, s, v, k;
QVector<double> dum;
FPointArray arrow = m_Doc->arrowStyles().at(arrowIndex-1).points.copy();
if (ite->NamedLStyle.isEmpty())
4290,7 → 4275,7
else if (ite->lineColor() != CommonStrings::None)
{
SetColor(ite->lineColor(), ite->lineShade(), &h, &s, &v, &k);
PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
PS_setcmykcolor_fill(h, s, v, k);
PS_newpath();
SetClipPath(&arrow);
PS_closepath();
4303,7 → 4288,7
if (ml[0].Color != CommonStrings::None)
{
SetColor(ml[0].Color, ml[0].Shade, &h, &s, &v, &k);
PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
PS_setcmykcolor_fill(h, s, v, k);
PS_newpath();
SetClipPath(&arrow);
PS_closepath();
4314,7 → 4299,7
if (ml[it].Color != CommonStrings::None)
{
SetColor(ml[it].Color, ml[it].Shade, &h, &s, &v, &k);
PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
PS_setcmykcolor_stroke(h, s, v, k);
PS_setlinewidth(ml[it].Width);
PS_setcapjoin(Qt::FlatCap, Qt::MiterJoin);
PS_setdash(Qt::SolidLine, 0, dum);
4326,7 → 4311,7
}
}
 
void PSLib::SetColor(const QString& farb, double shade, int *h, int *s, int *v, int *k)
void PSLib::SetColor(const QString& farb, double shade, double *h, double *s, double *v, double *k)
{
if (farb == CommonStrings::None)
{
4340,39 → 4325,39
SetColor(col, shade, h, s, v, k);
}
 
void PSLib::SetColor(const ScColor& farb, double shade, int *h, int *s, int *v, int *k)
void PSLib::SetColor(const ScColor& farb, double shade, double *c, double *m, double *y, double *k)
{
int h1 = *h, s1 = *s, v1 = *v, k1 = *k;
double c1 = *c, m1 = *m, y1 = *y, k1 = *k;
ScColor tmp(farb);
if (farb.getColorModel() != colorModelCMYK)
tmp = ScColorEngine::convertToModel(farb, m_Doc, colorModelCMYK);
if ((Options.doGCR) && (!farb.isRegistrationColor()))
ScColorEngine::applyGCR(tmp, m_Doc);
tmp.getCMYK(&h1, &s1, &v1, &k1);
tmp.getCMYK(&c1, &m1, &y1, &k1);
if ((m_Doc->HasCMS) && (ScCore->haveCMS()) && (solidTransform))
{
h1 = qRound(h1 * shade / 100.0);
s1 = qRound(s1 * shade / 100.0);
v1 = qRound(v1 * shade / 100.0);
k1 = qRound(k1 * shade / 100.0);
c1 = c1 * shade / 100.0;
m1 = m1 * shade / 100.0;
y1 = y1 * shade / 100.0;
k1 = k1 * shade / 100.0;
unsigned short inC[4];
unsigned short outC[4];
inC[0] = h1 * 257;
inC[1] = s1 * 257;
inC[2] = v1 * 257;
inC[3] = k1 * 257;
inC[0] = c1 * 65535.0;
inC[1] = m1 * 65535.0;
inC[2] = y1 * 65535.0;
inC[3] = k1 * 65535.0;
solidTransform.apply(inC, outC, 1);
*h= outC[0] / 257;
*s = outC[1] / 257;
*v = outC[2] / 257;
*k = outC[3] / 257;
*c = outC[0] / 65535.0;
*m = outC[1] / 65535.0;
*y = outC[2] / 65535.0;
*k = outC[3] / 65535.0;
}
else
{
*h = qRound(h1 * shade / 100.0);
*s = qRound(s1 * shade / 100.0);
*v = qRound(v1 * shade / 100.0);
*k = qRound(k1 * shade / 100.0);
*c = c1 * shade / 100.0;
*m = m1 * shade / 100.0;
*y = y1 * shade / 100.0;
*k = k1 * shade / 100.0;
}
}
 
4472,10 → 4457,10
}
else
{
int c=0, m=0, y=0, k=0;
double c=0, m=0, y=0, k=0;
SetColor(color, shade, &c, &m, &y, &k);
if (!DoSep || (Plate == 0 || Plate == 1 || Plate == 2 || Plate == 3))
PutStream(ToStr(c / 255.0) + " " + ToStr(m / 255.0) + " " + ToStr(y / 255.0) + " " + ToStr(k / 255.0) + " cmyk\n");
PutStream(ToStr(c) + " " + ToStr(m) + " " + ToStr(y) + " " + ToStr(k) + " cmyk\n");
else
PutStream("0 0 0 0 cmyk\n");
}
/trunk/Scribus/scribus/pslib.h
140,8 → 140,8
virtual void HandleDiamondGradient(PageItem* c);
virtual void HandleTensorGradient(PageItem* c);
virtual void HandleGradientFillStroke(PageItem *c, bool stroke = true, bool forArrow = false);
virtual void SetColor(const QString& color, double shade, int *h, int *s, int *v, int *k);
virtual void SetColor(const ScColor& color, double shade, int *h, int *s, int *v, int *k);
virtual void SetColor(const QString& color, double shade, double *c, double *m, double *y, double *k);
virtual void SetColor(const ScColor& color, double shade, double *c, double *m, double *y, double *k);
virtual void setTextSt(ScribusDoc* Doc, PageItem* ite, uint a, ScPage* pg, bool sep, bool farb, bool master);
bool psExport;
 
/trunk/Scribus/scribus/sccolor.cpp
35,10 → 35,10
// Model = colorModelCMYK;
// CR = MG = YB = K = 0;
m_Model = colorModelRGB;
m_CR = 150;
m_MG = 100;
m_YB = 50;
m_K = 0;
m_values[0] = 0.6;
m_values[1] = 0.4;
m_values[2] = 0.2;
m_values[3] = 0.0;
m_L_val = m_a_val = m_b_val = 0;
m_Spot = false;
m_Regist = false;
54,11 → 54,11
ScColor::ScColor(int r, int g, int b)
{
m_K = 0;
m_values[3] = 0.0;
m_L_val = m_a_val = m_b_val = 0;
m_Spot = false;
m_Regist = false;
setColorRGB(r, g, b);
setRgbColor(r, g, b);
}
 
ScColor::ScColor(double l, double a, double b)
71,10 → 71,10
m_a_val = a;
m_b_val = b;
 
m_CR = 150;
m_MG = 100;
m_YB = 50;
m_K = 0;
m_values[0] = 0.6;
m_values[1] = 0.4;
m_values[2] = 0.2;
m_values[3] = 0.0;
}
 
bool ScColor::operator==(const ScColor& other) const
87,11 → 87,11
return false;
if (m_Model == colorModelRGB)
{
return ((m_CR == other.m_CR) && (m_MG == other.m_MG) && (m_YB == other.m_YB));
return ((m_values[0] == other.m_values[0]) && (m_values[1] == other.m_values[1]) && (m_values[2] == other.m_values[2]));
}
if (m_Model == colorModelCMYK)
{
return ((m_CR == other.m_CR) && (m_MG == other.m_MG) && (m_YB == other.m_YB) && (m_K == other.m_K));
return ((m_values[0] == other.m_values[0]) && (m_values[1] == other.m_values[1]) && (m_values[2] == other.m_values[2]) && (m_values[3] == other.m_values[3]));
}
return false;
}
98,15 → 98,59
 
void ScColor::setColor(int c, int m, int y, int k)
{
m_CR = c;
m_MG = m;
m_YB = y;
m_K = k;
m_values[0] = c / 255.0;
m_values[1] = m / 255.0;
m_values[2] = y / 255.0;
m_values[3] = k / 255.0;
m_Model = colorModelCMYK;
}
 
void ScColor::setColor(double l, double a, double b)
void ScColor::setColorF(double c, double m, double y, double k)
{
m_values[0] = qMax(0.0, qMin(c, 1.0));
m_values[1] = qMax(0.0, qMin(m, 1.0));
m_values[2] = qMax(0.0, qMin(y, 1.0));
m_values[3] = qMax(0.0, qMin(k, 1.0));
m_Model = colorModelCMYK;
}
 
void ScColor::setCmykColor(int c, int m, int y, int k)
{
m_values[0] = c / 255.0;
m_values[1] = m / 255.0;
m_values[2] = y / 255.0;
m_values[3] = k / 255.0;
m_Model = colorModelCMYK;
}
 
void ScColor::setCmykColorF(double c, double m, double y, double k)
{
m_values[0] = qMax(0.0, qMin(c, 1.0));
m_values[1] = qMax(0.0, qMin(m, 1.0));
m_values[2] = qMax(0.0, qMin(y, 1.0));
m_values[3] = qMax(0.0, qMin(k, 1.0));
m_Model = colorModelCMYK;
}
 
void ScColor::setRgbColor(int r, int g, int b)
{
m_values[0] = r / 255.0;
m_values[1] = g / 255.0;
m_values[2] = b / 255.0;
m_Model = colorModelRGB;
}
 
void ScColor::setRgbColorF(double r, double g, double b)
{
m_values[0] = qMax(0.0, qMin(r, 1.0));
m_values[1] = qMax(0.0, qMin(g, 1.0));
m_values[2] = qMax(0.0, qMin(b, 1.0));
m_Model = colorModelRGB;
}
 
/** \brief Same as the Constructor but for an existing Color */
void ScColor::setLabColor(double l, double a, double b)
{
m_Model = colorModelLab;
m_L_val = l;
m_a_val = a;
113,14 → 157,6
m_b_val = b;
}
 
void ScColor::setColorRGB(int r, int g, int b)
{
m_CR = r;
m_MG = g;
m_YB = b;
m_Model = colorModelRGB;
}
 
colorModel ScColor::getColorModel () const
{
return m_Model;
138,7 → 174,7
{
int r, g, b;
color.getRgb(&r, &g, &b);
setColorRGB(r, g, b);
setRgbColor(r, g, b);
}
}
 
146,15 → 182,15
{
if (m_Model == colorModelRGB)
{
*r = m_CR;
*g = m_MG;
*b = m_YB;
*r = qRound(m_values[0] * 255.0);
*g = qRound(m_values[1] * 255.0);
*b = qRound(m_values[2] * 255.0);
}
else
{
*r = 255-qMin(255, m_CR + m_K);
*g = 255-qMin(255, m_MG + m_K);
*b = 255-qMin(255, m_YB + m_K);
*r = 255 - qMin(255, qRound((m_values[0] + m_values[3]) * 255.0));
*g = 255 - qMin(255, qRound((m_values[1] + m_values[3]) * 255.0));
*b = 255 - qMin(255, qRound((m_values[2] + m_values[3]) * 255.0));
}
}
 
161,8 → 197,17
QColor ScColor::getRawRGBColor() const
{
if (m_Model == colorModelRGB)
return QColor(m_CR, m_MG, m_YB);
return QColor(255-qMin(255, m_CR + m_K), 255-qMin(255, m_MG + m_K), 255 - qMin(255, m_YB + m_K));
{
int r = qRound(m_values[0] * 255.0);
int g = qRound(m_values[1] * 255.0);
int b = qRound(m_values[2] * 255.0);
return QColor(r, g, b);
}
 
double dR = 1.0 - qMin(1.0, m_values[0] + m_values[3]);
double dG = 1.0 - qMin(1.0, m_values[1] + m_values[3]);
double dB = 1.0 - qMin(1.0, m_values[2] + m_values[3]);
return QColor(qRound(dR * 255.0), qRound(dG * 255.0), qRound(dB * 255.0));
}
 
void ScColor::getRGB(int *r, int *g, int *b) const
169,21 → 214,40
{
if (m_Model != colorModelRGB)
qDebug("calling getRGB with a cmyk color");
*r = m_CR;
*g = m_MG;
*b = m_YB;
*r = qRound(m_values[0] * 255.0);
*g = qRound(m_values[1] * 255.0);
*b = qRound(m_values[2] * 255.0);
}
 
void ScColor::getRGB(double *r, double *g, double *b) const
{
if (m_Model != colorModelRGB)
qDebug("calling getRGB with a cmyk color");
*r = m_values[0];
*g = m_values[1];
*b = m_values[2];
}
 
void ScColor::getCMYK(int *c, int *m, int *y, int *k) const
{
if (m_Model != colorModelCMYK)
qDebug("calling getCMYK with a rgb color");
*c = m_CR;
*m = m_MG;
*y = m_YB;
*k = m_K;
*c = qRound(m_values[0] * 255.0);
*m = qRound(m_values[1] * 255.0);
*y = qRound(m_values[2] * 255.0);
*k = qRound(m_values[3] * 255.0);
}
 
void ScColor::getCMYK(double *c, double *m, double *y, double *k) const
{
if (m_Model != colorModelCMYK)
qDebug("calling getCMYK with a rgb color");
*c = m_values[0];
*m = m_values[1];
*y = m_values[2];
*k = m_values[3];
}
 
void ScColor::getLab(double *L, double *a, double *b) const
{
if (m_Model != colorModelLab)
193,39 → 257,48
*b = m_b_val;
}
 
QString ScColor::name()
QString ScColor::name() const
{
int value;
QString tmp, name="#";
 
switch (m_Model)
{
case colorModelCMYK:
tmp.setNum(m_CR, 16);
value = qRound(m_values[0] * 255.0);
tmp.setNum(value, 16);
if (tmp.length() < 2)
tmp.insert(0, "0");
name += tmp;
tmp.setNum(m_MG, 16);
value = qRound(m_values[1] * 255.0);
tmp.setNum(value, 16);
if (tmp.length() < 2)
tmp.insert(0, "0");
name += tmp;
tmp.setNum(m_YB, 16);
value = qRound(m_values[2] * 255.0);
tmp.setNum(value, 16);
if (tmp.length() < 2)
tmp.insert(0, "0");
name += tmp;
tmp.setNum(m_K, 16);
value = qRound(m_values[3] * 255.0);
tmp.setNum(value, 16);
if (tmp.length() < 2)
tmp.insert(0, "0");
name += tmp;
break;
case colorModelRGB:
tmp.setNum(m_CR, 16);
value = qRound(m_values[0] * 255.0);
tmp.setNum(value, 16);
if (tmp.length() < 2)
tmp.insert(0, "0");
name += tmp;
tmp.setNum(m_MG, 16);
value = qRound(m_values[1] * 255.0);
tmp.setNum(value, 16);
if (tmp.length() < 2)
tmp.insert(0, "0");
name += tmp;
tmp.setNum(m_YB, 16);
value = qRound(m_values[2] * 255.0);
tmp.setNum(value, 16);
if (tmp.length() < 2)
tmp.insert(0, "0");
name += tmp;
236,7 → 309,7
return name;
}
 
QString ScColor::nameCMYK(const ScribusDoc* doc)
QString ScColor::nameCMYK(const ScribusDoc* doc) const
{
if ((m_Model != colorModelCMYK) && (!doc))
qDebug("calling nameCMYK with a rgb color");
265,7 → 338,7
return name;
}
 
QString ScColor::nameRGB(const ScribusDoc* doc)
QString ScColor::nameRGB(const ScribusDoc* doc) const
{
if ((m_Model != colorModelRGB) && (!doc))
qDebug("calling nameRGB with a cmyk color");
306,7 → 379,7
int r = name.midRef(1,2).toInt(&ok, 16);
int g = name.midRef(3,2).toInt(&ok, 16);
int b = name.midRef(5,2).toInt(&ok, 16);
setColorRGB(r, g, b);
setRgbColor(r, g, b);
}
}
 
/trunk/Scribus/scribus/sccolor.h
58,27 → 58,34
ScColor(void);
/** \brief Constructs a ScColor with 4 Components in the range from 0 - 255 */
ScColor(int c, int m, int y, int k);
/** \brief Constructs a RGBColor with 3 Components in the range from 0 - 255 */
/** \brief Constructs a RGB color with 3 Components in the range from 0 - 255 */
ScColor(int r, int g, int b);
/** \brief Constructs a LabColor with 3 Components */
/** \brief Constructs a Lab color with 3 Components */
ScColor(double l, double a, double b);
bool operator==(const ScColor& other) const;
 
/** \brief Set color from an existing document */
void setColor(ScribusDoc* doc, const QString& name);
 
/** \brief Same as the Constructor but for an existing Color */
void setColor(int c, int m, int y, int k);
 
/** \brief Same as the Constructor but for an existing Color */
void setColor(double l, double a, double b);
void setColorF(double c, double m, double y, double k);
 
/** \brief Computes a ScColor from an RGB-Color
* Applies Gray-Component-Removal to the resulting ScColor
* or if color management is enabled, an approriate transform */
void setColorRGB(int r, int g, int b);
/** \brief Define color as a CMYK color with specified values */
void setCmykColor(int c, int m, int y, int k);
 
/** \brief Define color as a CMYK color with specified values */
void setCmykColorF(double c, double m, double y, double k);
 
/** \brief Define color as a RGB color with specified values */
void setRgbColor(int r, int g, int b);
 
/** \brief Define color as a RGB color with specified values */
void setRgbColorF(double r, double g, double b);
 
/** \brief Define color as a Lab color with specified values */
void setLabColor(double l, double a, double b);
 
/** \brief get the color model */
colorModel getColorModel () const;
 
95,11 → 102,21
* Must not be called if color is the None Color. */
void getCMYK(int *c, int *m, int *y, int *k) const;
 
/** \brief Returns the 4 Values that form an ScColor.
* Returns meaningful results only if color is a cmyk color.
* Must not be called if color is the None Color. */
void getCMYK(double *c, double *m, double *y, double *k) const;
 
/** \brief Returns the 3 Values that form an RGBColor
* Returns meaningful results only if color is a rgb color.
* Must not be called if color is the None Color. */
void getRGB(int *r, int *g, int *b) const;
 
/** \brief Returns the 3 Values that form an RGBColor
* Returns meaningful results only if color is a rgb color.
* Must not be called if color is the None Color. */
void getRGB(double *r, double *g, double *b) const;
 
/** \brief Returns the 3 Values that form an LabColor
* Returns meaningful results only if color is a Lab color.
* Must not be called if color is the None Color. */
107,13 → 124,13
 
/** \brief Returns the ScColor as an Hex-String in the Form #CCYYMMKK for a CMYK color or ##RRGGBB for a RGB color.
* For the None color return the "None" string. */
QString name();
QString name() const;
/** \brief Returns the ScColor as an Hex-String in the Form #RRGGBB
* If doc member is not specified, return meaningful result only for RGB colors. */
QString nameRGB(const ScribusDoc* doc = NULL);
QString nameRGB(const ScribusDoc* doc = NULL) const;
/** \brief Returns the ScColor as an Hex-String in the Form #CCYYMMKK
* If doc member is not specified, return meaningful result only for CMYK colors. */
QString nameCMYK(const ScribusDoc* doc = NULL);
QString nameCMYK(const ScribusDoc* doc = NULL) const;
 
/** \brief Sets the Values of a color from an Hex-String in the Form #CCMMYYKK or #RRGGBB */
void setNamedColor(QString nam);
129,14 → 146,8
 
private:
 
/** \brief Cyan or Red Component of Color (depends of color model)*/
int m_CR;
/** \brief Magenta or Green Component of Color (depends of color model)*/
int m_MG;
/** \brief Yellow or Blue Component of Color (depends of color model)*/
int m_YB;
/** \brief Black-Component of Color */
int m_K;
/** \brief Color values (depends of color model) */
double m_values[4];
/** \brief L component of Color */
double m_L_val;
/** \brief a component of Color */
/trunk/Scribus/scribus/sccolorengine.cpp
42,15 → 42,15
ScColor newCol;
if (model == colorModelRGB)
{
RGBColor rgb;
RGBColorF rgb;
getRGBValues(color, doc, rgb);
newCol.setColorRGB(rgb.r, rgb.g, rgb.b);
newCol.setRgbColorF(rgb.r, rgb.g, rgb.b);
}
else if (model == colorModelCMYK)
{
CMYKColor cmyk;
CMYKColorF cmyk;
getCMYKValues(color, doc, cmyk);
newCol.setColor(cmyk.c, cmyk.m, cmyk.y, cmyk.k);
newCol.setColorF(cmyk.c, cmyk.m, cmyk.y, cmyk.k);
}
else if (model == colorModelLab)
{
62,25 → 62,25
ScColorTransform trans = engine.createTransform(profRGB, Format_RGB_16, profLab, Format_Lab_Dbl, Intent_Perceptual, 0);
double outC[3];
unsigned short inC[3];
inC[0] = color.m_CR * 257;
inC[1] = color.m_MG * 257;
inC[2] = color.m_YB * 257;
inC[0] = qRound(color.m_values[0] * 65535);
inC[1] = qRound(color.m_values[1] * 65535);
inC[2] = qRound(color.m_values[2] * 65535);
trans.apply(inC, outC, 1);
newCol.setColor(outC[0], outC[1], outC[2]);
newCol.setLabColor(outC[0], outC[1], outC[2]);
}
else
{
ScColorProfile profRGB = doc ? doc->DocInputCMYKProf : ScCore->defaultCMYKProfile;
ScColorProfile profCMYK = doc ? doc->DocInputCMYKProf : ScCore->defaultCMYKProfile;
ScColorProfile profLab = ScCore->defaultLabProfile;
ScColorTransform trans = engine.createTransform(profRGB, Format_CMYK_16, profLab, Format_Lab_Dbl, Intent_Perceptual, 0);
ScColorTransform trans = engine.createTransform(profCMYK, Format_CMYK_16, profLab, Format_Lab_Dbl, Intent_Perceptual, 0);
double outC[3];
unsigned short inC[4];
inC[0] = color.m_CR * 257;
inC[1] = color.m_MG * 257;
inC[2] = color.m_YB * 257;
inC[3] = color.m_K * 257;
inC[0] = qRound(color.m_values[0] * 65535);
inC[1] = qRound(color.m_values[1] * 65535);
inC[2] = qRound(color.m_values[2] * 65535);
inC[3] = qRound(color.m_values[3] * 65535);
trans.apply(inC, outC, 1);
newCol.setColor(outC[0], outC[1], outC[2]);
newCol.setLabColor(outC[0], outC[1], outC[2]);
}
}
return newCol;
94,18 → 94,18
{
if (model == colorModelRGB)
{
rgb.r = color.m_CR;
rgb.g = color.m_MG;
rgb.b = color.m_YB;
rgb.r = qRound(color.m_values[0] * 255.0);
rgb.g = qRound(color.m_values[1] * 255.0);
rgb.b = qRound(color.m_values[2] * 255.0);
}
else if (model == colorModelCMYK)
{
unsigned short inC[4];
unsigned short outC[4];
inC[0] = color.m_CR * 257;
inC[1] = color.m_MG * 257;
inC[2] = color.m_YB * 257;
inC[3] = color.m_K * 257;
inC[0] = qRound(color.m_values[0] * 65535);
inC[1] = qRound(color.m_values[1] * 65535);
inC[2] = qRound(color.m_values[2] * 65535);
inC[3] = qRound(color.m_values[3] * 65535);
transRGB.apply(inC, outC, 1);
rgb.r = outC[0] / 257;
rgb.g = outC[1] / 257;
127,15 → 127,18
}
else if (model == colorModelCMYK)
{
rgb.r = 255 - qMin(255, color.m_CR + color.m_K);
rgb.g = 255 - qMin(255, color.m_MG + color.m_K);
rgb.b = 255 - qMin(255, color.m_YB + color.m_K);
double r = 1.0 - qMin(1.0, color.m_values[0] + color.m_values[3]);
double g = 1.0 - qMin(1.0, color.m_values[1] + color.m_values[3]);
double b = 1.0 - qMin(1.0, color.m_values[2] + color.m_values[3]);
rgb.r = qRound(r * 255.0);
rgb.g = qRound(g * 255.0);
rgb.b = qRound(b * 255.0);
}
else if (model == colorModelRGB)
{
rgb.r = color.m_CR;
rgb.g = color.m_MG;
rgb.b = color.m_YB;
rgb.r = qRound(color.m_values[0] * 255.0);
rgb.g = qRound(color.m_values[1] * 255.0);
rgb.b = qRound(color.m_values[2] * 255.0);
}
else if (model == colorModelLab)
{
191,6 → 194,111
}
}
 
void ScColorEngine::getRGBValues(const ScColor& color, const ScribusDoc* doc, RGBColorF& rgb)
{
colorModel model = color.getColorModel();
ScColorTransform transRGB = doc ? doc->stdTransRGB : ScCore->defaultCMYKToRGBTrans;
if (ScCore->haveCMS() && transRGB)
{
if (model == colorModelRGB)
{
rgb.r = color.m_values[0];
rgb.g = color.m_values[1];
rgb.b = color.m_values[2];
}
else if (model == colorModelCMYK)
{
unsigned short inC[4];
unsigned short outC[4];
inC[0] = qRound(color.m_values[0] * 65535);
inC[1] = qRound(color.m_values[1] * 65535);
inC[2] = qRound(color.m_values[2] * 65535);
inC[3] = qRound(color.m_values[3] * 65535);
transRGB.apply(inC, outC, 1);
rgb.r = outC[0] / 65535.0;
rgb.g = outC[1] / 65535.0;
rgb.b = outC[2] / 65535.0;
}
else if (model == colorModelLab)
{
ScColorTransform trans = doc ? doc->stdLabToRGBTrans : ScCore->defaultLabToRGBTrans;
double inC[3];
inC[0] = color.m_L_val;
inC[1] = color.m_a_val;
inC[2] = color.m_b_val;
quint16 outC[3];
trans.apply(inC, outC, 1);
rgb.r = outC[0] / 65535.0;
rgb.g = outC[1] / 65535.0;
rgb.b = outC[2] / 65535.0;
}
}
else if (model == colorModelCMYK)
{
rgb.r = 1.0 - qMin(1.0, color.m_values[0] + color.m_values[3]);
rgb.g = 1.0 - qMin(1.0, color.m_values[1] + color.m_values[3]);
rgb.b = 1.0 - qMin(1.0, color.m_values[2] + color.m_values[3]);
}
else if (model == colorModelRGB)
{
rgb.r = color.m_values[0];
rgb.g = color.m_values[1];
rgb.b = color.m_values[2];
}
else if (model == colorModelLab)
{
// First step: Lab -> XYZ
double var_Y = (color.m_L_val + 16) / 116.0;
double var_X = color.m_a_val / 500.0 + var_Y;
double var_Z = var_Y - color.m_b_val / 200.0;
if (pow(var_Y, 3) > 0.008856)
var_Y = pow(var_Y, 3);
else
var_Y = (var_Y - 16.0 / 116.0) / 7.787;
if (pow(var_X, 3) > 0.008856)
var_X = pow(var_X, 3);
else
var_X = (var_X - 16.0 / 116.0) / 7.787;
if (pow(var_Z, 3) > 0.008856)
var_Z = pow(var_Z, 3);
else
var_Z = (var_Z - 16.0 / 116.0) / 7.787;
// Second step: XYZ -> RGB
// Whitepoint D50
var_X = 0.990720 * var_X;
var_Y = 1.00000 * var_Y;
var_Z = 0.825210 * var_Z;
double var_R = var_X * 3.2406 + var_Y * -1.5372 + var_Z * -0.4986;
double var_G = var_X * -0.9689 + var_Y * 1.8758 + var_Z * 0.0415;
double var_B = var_X * 0.0557 + var_Y * -0.2040 + var_Z * 1.0570;
if (var_R > 0.0031308)
var_R = 1.055 * (pow(var_R, (1.0 / 2.4))) - 0.055;
else
var_R = 12.92 * var_R;
if (var_G > 0.0031308)
var_G = 1.055 * (pow(var_G, (1.0 / 2.4))) - 0.055;
else
var_G = 12.92 * var_G;
if (var_B > 0.0031308)
var_B = 1.055 * (pow(var_B, (1.0 / 2.4))) - 0.055;
else
var_B = 12.92 * var_B;
rgb.r = qMax(0.0, qMin(var_R, 1.0));
rgb.g = qMax(0.0, qMin(var_G, 1.0));
rgb.b = qMax(0.0, qMin(var_B, 1.0));
/* ScColorTransform trans = doc ? doc->stdLabToRGBTrans : ScCore->defaultLabToRGBTrans;
double inC[3];
inC[0] = color.L_val;
inC[1] = color.a_val;
inC[2] = color.b_val;
quint16 outC[3];
trans.apply(inC, outC, 1);
rgb.r = outC[0] / 65535.0;
rgb.g = outC[1] / 65535.0;
rgb.b = outC[2] / 65535.0;*/
}
}
 
void ScColorEngine::getCMYKValues(const ScColor& color, const ScribusDoc* doc, CMYKColor& cmyk)
{
unsigned short inC[4];
201,17 → 309,17
{
if (model == colorModelRGB)
{
// allow RGB greys to go got to CMYK greys without transform
if (color.m_CR == color.m_MG && color.m_MG == color.m_YB)
// allow RGB greys to go to CMYK greys without transform
if (color.m_values[0] == color.m_values[1] && color.m_values[1] == color.m_values[2])
{
cmyk.c = cmyk.m = cmyk.y = 0;
cmyk.k = 255 - color.m_CR;
cmyk.k = 255 - qRound(color.m_values[0] * 255.0);
}
else
{
inC[0] = color.m_CR * 257;
inC[1] = color.m_MG * 257;
inC[2] = color.m_YB * 257;
inC[0] = qRound(color.m_values[0] * 65535.0);
inC[1] = qRound(color.m_values[1] * 65535.0);
inC[2] = qRound(color.m_values[2] * 65535.0);
transCMYK.apply(inC, outC, 1);
cmyk.c = outC[0] / 257;
cmyk.m = outC[1] / 257;
221,10 → 329,10
}
else if (model == colorModelCMYK)
{
cmyk.c = color.m_CR;
cmyk.m = color.m_MG;
cmyk.y = color.m_YB;
cmyk.k = color.m_K;
cmyk.c = qRound(color.m_values[0] * 255.0);
cmyk.m = qRound(color.m_values[1] * 255.0);
cmyk.y = qRound(color.m_values[2] * 255.0);
cmyk.k = qRound(color.m_values[3] * 255.0);
}
else if (model == colorModelLab)
{
243,17 → 351,18
}
else if (model == colorModelRGB)
{
cmyk.k = qMin(qMin(255 - color.m_CR, 255 - color.m_MG), 255 - color.m_YB);
cmyk.c = 255 - color.m_CR - cmyk.k;
cmyk.m = 255 - color.m_MG - cmyk.k;
cmyk.y = 255 - color.m_YB - cmyk.k;
double k = qMin(qMin(1.0 - color.m_values[0], 1.0 - color.m_values[1]), 1.0 - color.m_values[2]);
cmyk.k = qRound(k * 255.0);
cmyk.c = 255 - qRound((color.m_values[0] - k) * 255.0);
cmyk.m = 255 - qRound((color.m_values[1] - k) * 255.0);
cmyk.y = 255 - qRound((color.m_values[2] - k) * 255.0);
}
else if (model == colorModelCMYK)
{
cmyk.c = color.m_CR;
cmyk.m = color.m_MG;
cmyk.y = color.m_YB;
cmyk.k = color.m_K;
cmyk.c = qRound(color.m_values[0] * 255.0);
cmyk.m = qRound(color.m_values[1] * 255.0);
cmyk.y = qRound(color.m_values[2] * 255.0);
cmyk.k = qRound(color.m_values[3] * 255.0);
}
else if (model == colorModelLab)
{
271,12 → 380,92
}
}
 
void ScColorEngine::getCMYKValues(const ScColor& color, const ScribusDoc* doc, CMYKColorF& cmyk)
{
unsigned short inC[4];
unsigned short outC[4];
colorModel model = color.getColorModel();
ScColorTransform transCMYK = doc ? doc->stdTransCMYK : ScCore->defaultRGBToCMYKTrans;
if (ScCore->haveCMS() && transCMYK)
{
if (model == colorModelRGB)
{
// allow RGB greys to go to CMYK greys without transform
if (color.m_values[0] == color.m_values[1] && color.m_values[1] == color.m_values[2])
{
cmyk.c = cmyk.m = cmyk.y = 0;
cmyk.k = 1.0 - color.m_values[0];
}
else
{
inC[0] = qRound(color.m_values[0] * 65535.0);
inC[1] = qRound(color.m_values[1] * 65535.0);
inC[2] = qRound(color.m_values[2] * 65535.0);
transCMYK.apply(inC, outC, 1);
cmyk.c = outC[0] / 65535.0;
cmyk.m = outC[1] / 65535.0;
cmyk.y = outC[2] / 65535.0;
cmyk.k = outC[3] / 65535.0;
}
}
else if (model == colorModelCMYK)
{
cmyk.c = color.m_values[0];
cmyk.m = color.m_values[1];
cmyk.y = color.m_values[2];
cmyk.k = color.m_values[3];
}
else if (model == colorModelLab)
{
ScColorTransform trans = doc ? doc->stdLabToCMYKTrans : ScCore->defaultLabToCMYKTrans;
double inC[3];
inC[0] = color.m_L_val;
inC[1] = color.m_a_val;
inC[2] = color.m_b_val;
quint16 outC[4];
trans.apply(inC, outC, 1);
cmyk.c = outC[0] / 65535.0;
cmyk.m = outC[1] / 65535.0;
cmyk.y = outC[2] / 65535.0;
cmyk.k = outC[3] / 65535.0;
}
}
else if (model == colorModelRGB)
{
cmyk.k = qMin(qMin(1.0 - color.m_values[0], 1.0 - color.m_values[1]), 1.0 - color.m_values[2]);
cmyk.c = 1.0 - (color.m_values[0] - cmyk.k);
cmyk.m = 1.0 - (color.m_values[1] - cmyk.k);
cmyk.y = 1.0 - (color.m_values[2] - cmyk.k);
}
else if (model == colorModelCMYK)
{
cmyk.c = color.m_values[0];
cmyk.m = color.m_values[1];
cmyk.y = color.m_values[2];
cmyk.k = color.m_values[3];
}
else if (model == colorModelLab)
{
ScColorTransform trans = doc ? doc->stdLabToCMYKTrans : ScCore->defaultLabToCMYKTrans;
double inC[3];
inC[0] = color.m_L_val;
inC[1] = color.m_a_val;
inC[2] = color.m_b_val;
quint16 outC[4];
trans.apply(inC, outC, 1);
cmyk.c = outC[0] / 65535.0;
cmyk.m = outC[1] / 65535.0;
cmyk.y = outC[2] / 65535.0;
cmyk.k = outC[3] / 65535.0;
}
}
 
void ScColorEngine::getShadeColorCMYK(const ScColor& color, const ScribusDoc* doc,
CMYKColor& cmyk, double level)
{
if (color.getColorModel() == colorModelRGB)
{
RGBColor rgb;
RGBColorF rgb;
getShadeColorRGB(color, doc, rgb, level);
ScColor tmpR(rgb.r, rgb.g, rgb.b);
getCMYKValues(tmpR, doc, cmyk);
283,10 → 472,10
}
else if (color.getColorModel() == colorModelCMYK)
{
cmyk.c = qRound(color.m_CR * level / 100.0);
cmyk.m = qRound(color.m_MG * level / 100.0);
cmyk.y = qRound(color.m_YB * level / 100.0);
cmyk.k = qRound(color.m_K * level / 100.0);
cmyk.c = qRound(color.m_values[0] * level / 100.0 * 255.0);
cmyk.m = qRound(color.m_values[1] * level / 100.0 * 255.0);
cmyk.y = qRound(color.m_values[2] * level / 100.0 * 255.0);
cmyk.k = qRound(color.m_values[3] * level / 100.0 * 255.0);
}
else if (color.getColorModel() == colorModelLab)
{
304,6 → 493,40
}
}
 
void ScColorEngine::getShadeColorCMYK(const ScColor& color, const ScribusDoc* doc,
CMYKColorF& cmyk, double level)
{
if (color.getColorModel() == colorModelRGB)
{
RGBColorF rgb;
getShadeColorRGB(color, doc, rgb, level);
ScColor tmpR;
tmpR.setRgbColorF(rgb.r, rgb.g, rgb.b);
getCMYKValues(tmpR, doc, cmyk);
}
else if (color.getColorModel() == colorModelCMYK)
{
cmyk.c = color.m_values[0] * level / 100.0;
cmyk.m = color.m_values[1] * level / 100.0;
cmyk.y = color.m_values[2] * level / 100.0;
cmyk.k = color.m_values[3] * level / 100.0;
}
else if (color.getColorModel() == colorModelLab)
{
ScColorTransform trans = doc ? doc->stdLabToCMYKTrans : ScCore->defaultLabToCMYKTrans;
double inC[3];
inC[0] = 100 - (100 - color.m_L_val) * (level / 100.0);
inC[1] = color.m_a_val * (level / 100.0);
inC[2] = color.m_b_val * (level / 100.0);
quint16 outC[4];
trans.apply(inC, outC, 1);
cmyk.c = outC[0] / 65535.0;
cmyk.m = outC[1] / 65535.0;
cmyk.y = outC[2] / 65535.0;
cmyk.k = outC[3] / 65535.0;
}
}
 
void ScColorEngine::getShadeColorRGB(const ScColor& color, const ScribusDoc* doc, RGBColor& rgb, double level)
{
if (color.getColorModel() == colorModelCMYK)
316,7 → 539,7
else if (color.getColorModel() == colorModelRGB)
{
int h, s, v, snew, vnew;
QColor tmpR(color.m_CR, color.m_MG, color.m_YB);
QColor tmpR = color.getRawRGBColor();
tmpR.getHsv(&h, &s, &v);
snew = qRound(s * level / 100.0);
vnew = 255 - qRound(((255 - v) * level / 100.0));
342,24 → 565,67
}
}
 
void ScColorEngine::getShadeColorRGB(const ScColor& color, const ScribusDoc* doc, RGBColorF& rgb, double level)
{
if (color.getColorModel() == colorModelCMYK)
{
CMYKColorF cmyk;
getShadeColorCMYK(color, doc, cmyk, level);
ScColor tmpC;
tmpC.setColorF(cmyk.c, cmyk.m, cmyk.y, cmyk.k);
getRGBValues(tmpC, doc, rgb);
}
else if (color.getColorModel() == colorModelRGB)
{
int h, s, v, snew, vnew;
QColor tmpR = color.getRawRGBColor();
tmpR.getHsv(&h, &s, &v);
snew = qRound(s * level / 100.0);
vnew = 255 - qRound(((255 - v) * level / 100.0));
RGBColor tmpRgb;
tmpR.setHsv(h, snew, vnew);
tmpR.getRgb(&tmpRgb.r, &tmpRgb.g, &tmpRgb.b);
rgb.r = tmpRgb.r / 255.0;
rgb.g = tmpRgb.g / 255.0;
rgb.b = tmpRgb.b / 255.0;
//We could also compute rgb shade using rgb directly
/*rgb.r = 1.0 - ((1.0 - color.m_values[0]) * level / 100);
rgb.g = 1.0 - ((1.0 - color.m_values[1]) * level / 100);
rgb.b = 1.0 - ((1.0 - color.m_values[2]) * level / 100);*/
}
else if (color.getColorModel() == colorModelLab)
{
ScColorTransform trans = doc ? doc->stdLabToRGBTrans : ScCore->defaultLabToRGBTrans;
double inC[3];
inC[0] = 100 - (100 - color.m_L_val) * (level / 100.0);
inC[1] = color.m_a_val * (level / 100.0);
inC[2] = color.m_b_val * (level / 100.0);
quint16 outC[3];
trans.apply(inC, outC, 1);
rgb.r = outC[0] / 65535.0;
rgb.g = outC[1] / 65535.0;
rgb.b = outC[2] / 65535.0;
}
}
 
QColor ScColorEngine::getDisplayColor(const ScColor& color, const ScribusDoc* doc)
{
QColor tmp;
if (color.getColorModel() == colorModelRGB)
{
RGBColor rgb;
rgb.r = color.m_CR;
rgb.g = color.m_MG;
rgb.b = color.m_YB;
RGBColorF rgb;
rgb.r = color.m_values[0];
rgb.g = color.m_values[1];
rgb.b = color.m_values[2];
tmp = getDisplayColor(rgb, doc, color.isSpotColor());
}
else if (color.getColorModel() == colorModelCMYK)
{
CMYKColor cmyk;
cmyk.c = color.m_CR;
cmyk.m = color.m_MG;
cmyk.y = color.m_YB;
cmyk.k = color.m_K;
CMYKColorF cmyk;
cmyk.c = color.m_values[0];
cmyk.m = color.m_values[1];
cmyk.y = color.m_values[2];
cmyk.k = color.m_values[3];
tmp = getDisplayColor(cmyk, doc, color.isSpotColor());
}
else if (color.getColorModel() == colorModelLab)
429,20 → 695,20
QColor tmp;
if (color.getColorModel() == colorModelRGB)
{
RGBColor rgb;
rgb.r = color.m_CR;
rgb.g = color.m_MG;
rgb.b = color.m_YB;
RGBColorF rgb;
rgb.r = color.m_values[0];
rgb.g = color.m_values[1];
rgb.b = color.m_values[2];
getShadeColorRGB(color, doc, rgb, level);
tmp = getDisplayColor(rgb, doc, color.isSpotColor());
}
else if (color.getColorModel() == colorModelCMYK)
{
CMYKColor cmyk;
cmyk.c = color.m_CR;
cmyk.m = color.m_MG;
cmyk.y = color.m_YB;
cmyk.k = color.m_K;
CMYKColorF cmyk;
cmyk.c = color.m_values[0];
cmyk.m = color.m_values[1];
cmyk.y = color.m_values[2];
cmyk.k = color.m_values[3];
getShadeColorCMYK(color, doc, cmyk, level);
tmp = getDisplayColor(cmyk, doc, color.isSpotColor());
}
465,7 → 731,7
QColor tmp;
bool doSoftProofing = doc ? doc->SoftProofing : false;
bool doGamutCheck = doc ? doc->Gamut : false;
if ( doSoftProofing && doGamutCheck )
if (doSoftProofing && doGamutCheck)
{
bool outOfGamutFlag = isOutOfGamut(color, doc);
if (outOfG != NULL)
485,21 → 751,21
if (color.getColorModel() == colorModelRGB)
{
// Match 133x behavior (RGB greys map to cmyk greys) until we are able to make rgb profiled output
if ( color.m_CR == color.m_MG && color.m_MG == color.m_YB )
if (color.m_values[0] == color.m_values[1] && color.m_values[1] == color.m_values[2])
gamutChkEnabled = false;
RGBColor rgb;
rgb.r = color.m_CR;
rgb.g = color.m_MG;
rgb.b = color.m_YB;
rgb.r = qRound(color.m_values[0] * 255.0);
rgb.g = qRound(color.m_values[1] * 255.0);
rgb.b = qRound(color.m_values[2] * 255.0);
tmp = getColorProof(rgb, doc, spot, gamutCheck & gamutChkEnabled);
}
else
{
CMYKColor cmyk;
cmyk.c = color.m_CR;
cmyk.m = color.m_MG;
cmyk.y = color.m_YB;
cmyk.k = color.m_K;
cmyk.c = qRound(color.m_values[0] * 255.0);
cmyk.m = qRound(color.m_values[1] * 255.0);
cmyk.y = qRound(color.m_values[2] * 255.0);
cmyk.k = qRound(color.m_values[3] * 255.0);
tmp = getColorProof(cmyk, doc, spot, gamutCheck & gamutChkEnabled);
}
return tmp;
508,9 → 774,9
QColor ScColorEngine::getShadeColor(const ScColor& color, const ScribusDoc* doc, double level)
{
RGBColor rgb;
rgb.r = color.m_CR;
rgb.g = color.m_MG;
rgb.b = color.m_YB;
rgb.r = qRound(color.m_values[0] * 255.0);
rgb.g = qRound(color.m_values[1] * 255.0);
rgb.b = qRound(color.m_values[2] * 255.0);
getShadeColorRGB(color, doc, rgb, level);
return QColor(rgb.r, rgb.g, rgb.b);
}
524,10 → 790,10
 
if (color.getColorModel() == colorModelRGB)
{
RGBColor rgb;
rgb.r = color.m_CR;
rgb.g = color.m_MG;
rgb.b = color.m_YB;
RGBColorF rgb;
rgb.r = color.m_values[0];
rgb.g = color.m_values[1];
rgb.b = color.m_values[2];
getShadeColorRGB(color, doc, rgb, level);
// Match 133x behavior for rgb grey until we are able to make rgb profiled output
// (RGB greys map to cmyk greys)
534,9 → 800,9
if ((cmsUse && softProof) && (rgb.r == rgb.g && rgb.g == rgb.b))
{
doGC = false;
CMYKColor cmyk;
CMYKColorF cmyk;
cmyk.c = cmyk.m = cmyk.y = 0;
cmyk.k = 255 - rgb.g;
cmyk.k = 1.0 - rgb.g;
tmp = getColorProof(cmyk, doc, color.isSpotColor(), doGC);
}
else
544,11 → 810,11
}
else if (color.getColorModel() == colorModelCMYK)
{
CMYKColor cmyk;
cmyk.c = color.m_CR;
cmyk.m = color.m_MG;
cmyk.y = color.m_YB;
cmyk.k = color.m_K;
CMYKColorF cmyk;
cmyk.c = color.m_values[0];
cmyk.m = color.m_values[1];
cmyk.y = color.m_values[2];
cmyk.k = color.m_values[3];
getShadeColorCMYK(color, doc, cmyk, level);
tmp = getColorProof(cmyk, doc, color.isSpotColor(), doGC);
}
612,6 → 878,42
return QColor(r, g, b);
}
 
QColor ScColorEngine::getColorProof(RGBColorF& rgb, const ScribusDoc* doc, bool spot, bool gamutCkeck)
{
unsigned short inC[4];
unsigned short outC[4];
int r = qRound(rgb.r * 255.0);
int g = qRound(rgb.g * 255.0);
int b = qRound(rgb.b * 255.0);
ScColorTransform transRGBMon = doc ? doc->stdTransRGBMon : ScCore->defaultRGBToScreenSolidTrans;
ScColorTransform transProof = doc ? doc->stdProof : ScCore->defaultRGBToScreenSolidTrans;
ScColorTransform transProofGC = doc ? doc->stdProofGC : ScCore->defaultRGBToScreenSolidTrans;
bool cmsUse = doc ? doc->HasCMS : false;
bool cmsTrans = (transRGBMon && transProof && transProofGC);
if (ScCore->haveCMS() && cmsTrans)
{
inC[0] = rgb.r * 65535.0;
inC[1] = rgb.g * 65535.0;
inC[2] = rgb.b * 65535.0;
if (cmsUse && !spot && doc->SoftProofing)
{
ScColorTransform xform = gamutCkeck ? transProofGC : transProof;
xform.apply(inC, outC, 1);
r = outC[0] / 257;
g = outC[1] / 257;
b = outC[2] / 257;
}
else
{
transRGBMon.apply(inC, outC, 1);
r = outC[0] / 257;
g = outC[1] / 257;
b = outC[2] / 257;
}
}
return QColor(r, g, b);
}
 
QColor ScColorEngine::getColorProof(CMYKColor& cmyk, const ScribusDoc* doc, bool spot, bool gamutCkeck)
{
int r = 0, g = 0, b = 0;
653,6 → 955,47
return QColor(r, g, b);
}
 
QColor ScColorEngine::getColorProof(CMYKColorF& cmyk, const ScribusDoc* doc, bool spot, bool gamutCkeck)
{
int r = 0, g = 0, b = 0;
unsigned short inC[4];
unsigned short outC[4];
ScColorTransform transCMYKMon = doc ? doc->stdTransCMYKMon : ScCore->defaultCMYKToRGBTrans;
ScColorTransform transProofCMYK = doc ? doc->stdProofCMYK : ScCore->defaultCMYKToRGBTrans;
ScColorTransform transProofCMYKGC = doc ? doc->stdProofCMYKGC : ScCore->defaultCMYKToRGBTrans;
bool cmsUse = doc ? doc->HasCMS : false;
bool cmsTrans = (transCMYKMon && transProofCMYK && transProofCMYKGC);
if (ScCore->haveCMS() && cmsTrans)
{
inC[0] = cmyk.c * 65535.0;
inC[1] = cmyk.m * 65535.0;
inC[2] = cmyk.y * 65535.0;
inC[3] = cmyk.k * 65535.0;
if (cmsUse && !spot && doc->SoftProofing)
{
ScColorTransform xform = gamutCkeck ? transProofCMYKGC : transProofCMYK;
xform.apply(inC, outC, 1);
r = outC[0] / 257;
g = outC[1] / 257;
b = outC[2] / 257;
}
else
{
transCMYKMon.apply(inC, outC, 1);
r = outC[0] / 257;
g = outC[1] / 257;
b = outC[2] / 257;
}
}
else
{
r = 255 - qMin(255, qRound((cmyk.c + cmyk.k) * 255.0));
g = 255 - qMin(255, qRound((cmyk.m + cmyk.k) * 255.0));
b = 255 - qMin(255, qRound((cmyk.y + cmyk.k) * 255.0));
}
return QColor(r, g, b);
}
 
QColor ScColorEngine::getDisplayColor(RGBColor& rgb, const ScribusDoc* doc, bool spot)
{
unsigned short inC[4];
674,6 → 1017,27
return QColor(r, g, b);
}
 
QColor ScColorEngine::getDisplayColor(RGBColorF& rgb, const ScribusDoc* doc, bool spot)
{
unsigned short inC[4];
unsigned short outC[4];
int r = rgb.r * 255.0;
int g = rgb.g * 255.0;
int b = rgb.b * 255.0;
ScColorTransform transRGBMon = doc ? doc->stdTransRGBMon : ScCore->defaultRGBToScreenSolidTrans;
if (ScCore->haveCMS() && transRGBMon)
{
inC[0] = rgb.r * 65535.0;
inC[1] = rgb.g * 65535.0;
inC[2] = rgb.b * 65535.0;
transRGBMon.apply(inC, outC, 1);
r = outC[0] / 257;
g = outC[1] / 257;
b = outC[2] / 257;
}
return QColor(r, g, b);
}
 
QColor ScColorEngine::getDisplayColor(CMYKColor& cmyk, const ScribusDoc* doc, bool spot)
{
int r = 0, g = 0, b = 0;
700,6 → 1064,32
return QColor(r, g, b);
}
 
QColor ScColorEngine::getDisplayColor(CMYKColorF& cmyk, const ScribusDoc* doc, bool spot)
{
int r = 0, g = 0, b = 0;
unsigned short inC[4];
unsigned short outC[4];
ScColorTransform transCMYKMon = doc ? doc->stdTransCMYKMon : ScCore->defaultCMYKToRGBTrans;
if (ScCore->haveCMS() && transCMYKMon)
{
inC[0] = cmyk.c * 65535.0;
inC[1] = cmyk.m * 65535.0;
inC[2] = cmyk.y * 65535.0;
inC[3] = cmyk.k * 65535.0;
transCMYKMon.apply(inC, outC, 1);
r = outC[0] / 257;
g = outC[1] / 257;
b = outC[2] / 257;
}
else
{
r = 255 - qMin(255, qRound((cmyk.c + cmyk.k) * 255.0));
g = 255 - qMin(255, qRound((cmyk.m + cmyk.k) * 255.0));
b = 255 - qMin(255, qRound((cmyk.y + cmyk.k) * 255.0));
}
return QColor(r, g, b);
}
 
bool ScColorEngine::isOutOfGamut(const ScColor& color, const ScribusDoc* doc)
{
bool outOfGamutFlag = false;
714,27 → 1104,27
ScColorTransform xformProof;
if (color.getColorModel() == colorModelRGB)
{
inC[0] = color.m_CR * 257;
inC[1] = color.m_MG * 257;
inC[2] = color.m_YB * 257;
inC[0] = qRound(color.m_values[0] * 65535.0);
inC[1] = qRound(color.m_values[1] * 65535.0);
inC[2] = qRound(color.m_values[2] * 65535.0);
xformProof = doc->stdProofGC;
if ((color.m_CR == 0) && (color.m_YB == 0) && (color.m_MG == 255))
if ((color.m_values[0] == 0) && (color.m_values[1] == 0) && (color.m_values[2] == 1.0))
alert = false;
if ((color.m_CR == color.m_MG && color.m_MG == color.m_YB))
if ((color.m_values[0] == color.m_values[1] && color.m_values[1] == color.m_values[2]))
alert = false;
}
else if (color.getColorModel() == colorModelCMYK)
{
inC[0] = color.m_CR * 257;
inC[1] = color.m_MG * 257;
inC[2] = color.m_YB * 257;
inC[3] = color.m_K * 257;
inC[0] = qRound(color.m_values[0] * 65535.0);
inC[1] = qRound(color.m_values[1] * 65535.0);
inC[2] = qRound(color.m_values[2] * 65535.0);
inC[3] = qRound(color.m_values[3] * 65535.0);
xformProof = doc->stdProofCMYKGC;
if ((color.m_MG == 0) && (color.m_K == 0) && (color.m_CR == 255) && (color.m_YB == 255))
if ((color.m_values[0] == 1.0) && (color.m_values[1] == 0) && (color.m_values[3] == 0) && (color.m_values[2] == 1.0))
alert = false;
if ((color.m_MG == 0) && (color.m_CR == 0) && (color.m_YB == 0))
if ((color.m_values[0] == 0.0) && (color.m_values[1] == 0) && (color.m_values[2] == 0))
alert = false;
if ((color.m_MG == color.m_CR) && (color.m_CR == color.m_YB) && (color.m_YB == color.m_K))
if ((color.m_values[0] == color.m_values[1]) && (color.m_values[0] == color.m_values[2]) && (color.m_values[2] == color.m_values[3]))
alert = false;
}
else if (color.getColorModel() == colorModelLab)
767,9 → 1157,9
CMYKColor cmyk;
getCMYKValues(color, doc, cmyk);
int k = qMin(qMin(cmyk.c, cmyk.m), cmyk.y);
color.m_CR = cmyk.c - k;
color.m_MG = cmyk.m - k;
color.m_YB = cmyk.y - k;
color.m_K = qMin((cmyk.k + k), 255);
color.m_values[0] = (cmyk.c - k) / 255.0;
color.m_values[1] = (cmyk.m - k) / 255.0;
color.m_values[2] = (cmyk.y - k) / 255.0;
color.m_values[3] = qMin((cmyk.k + k) / 255.0, 1.0);
}
}
/trunk/Scribus/scribus/sccolorengine.h
41,15 → 41,27
/** \brief get RGB values of a specified color */
static void getRGBValues(const ScColor& color, const ScribusDoc* doc, RGBColor& rgb);
 
/** \brief get RGB values of a specified color */
static void getRGBValues(const ScColor& color, const ScribusDoc* doc, RGBColorF& rgb);
 
/** \brief get CMYK values of a specified color */
static void getCMYKValues(const ScColor& color, const ScribusDoc* doc, CMYKColor& cmyk);
 
/** \brief get CMYK values of a specified color */
static void getCMYKValues(const ScColor& color, const ScribusDoc* doc, CMYKColorF& cmyk);
 
/** \brief get RGB values of a specified shade */
static void getShadeColorRGB(const ScColor& color, const ScribusDoc* doc, RGBColor&, double level);
 
/** \brief get RGB values of a specified shade */
static void getShadeColorRGB(const ScColor& color, const ScribusDoc* doc, RGBColorF&, double level);
/** \brief get CMYK values of a specified shade */
static void getShadeColorCMYK(const ScColor& color, const ScribusDoc* doc, CMYKColor& cmyk, double level);
 
/** \brief get CMYK values of a specified shade */
static void getShadeColorCMYK(const ScColor& color, const ScribusDoc* doc, CMYKColorF& cmyk, double level);
 
/** \brief Return a color converted to monitor color space. No soft-proofing is done. */
static QColor getDisplayColor(const ScColor& color, const ScribusDoc* doc);
 
77,18 → 89,34
* If color management is enabled, returned value use the monitor color space. */
static QColor getColorProof(RGBColor& rgb, const ScribusDoc* doc, bool spot, bool gamutCkeck);
 
/** \brief Return a proofed QColor from a rgb color.
* If color management is enabled, returned value use the monitor color space. */
static QColor getColorProof(RGBColorF& rgb, const ScribusDoc* doc, bool spot, bool gamutCkeck);
 
/** \brief Return a proofed QColor from a cmyk color.
* If color management is enabled, returned value use the monitor color space. */
static QColor getColorProof(CMYKColor& cmyk, const ScribusDoc* doc, bool spot, bool gamutCkeck);
 
/** \brief Return a proofed QColor from a cmyk color.
* If color management is enabled, returned value use the monitor color space. */
static QColor getColorProof(CMYKColorF& cmyk, const ScribusDoc* doc, bool spot, bool gamutCkeck);
 
/** \brief Return a QColor from a rgb color using doc rgb color space as input.
* If color management is enabled, returned value use the monitor rgb color space. */
static QColor getDisplayColor(RGBColor& rgb, const ScribusDoc* doc, bool spot);
 
/** \brief Return a QColor from a rgb color using doc rgb color space as input.
* If color management is enabled, returned value use the monitor rgb color space. */
static QColor getDisplayColor(RGBColorF& rgb, const ScribusDoc* doc, bool spot);
 
/** \brief Return a QColor from a cmyk color using doc cmyk color space as input.
* If color management is enabled, returned value use the monitor rgb color space. */
static QColor getDisplayColor(CMYKColor& cmyk, const ScribusDoc* doc, bool spot);
 
/** \brief Return a QColor from a cmyk color using doc cmyk color space as input.
* If color management is enabled, returned value use the monitor rgb color space. */
static QColor getDisplayColor(CMYKColorF& cmyk, const ScribusDoc* doc, bool spot);
 
/** \brief Check if a color is inside document output color space gamut. */
static bool isOutOfGamut(const ScColor& color, const ScribusDoc* doc);
 
/trunk/Scribus/scribus/sccolorshade.cpp
47,21 → 47,21
ScColor value;
if (color.getColorModel() == colorModelRGB)
{
RGBColor rgb;
RGBColorF rgb;
ScColorEngine::getShadeColorRGB(color, NULL, rgb, shade);
value.setColorRGB( rgb.r, rgb.g, rgb.b );
value.setRgbColorF(rgb.r, rgb.g, rgb.b);
}
else if (color.getColorModel() == colorModelCMYK)
{
CMYKColor cmyk;
CMYKColorF cmyk;
ScColorEngine::getShadeColorCMYK(color, NULL, cmyk, shade);
value.setColor( cmyk.c, cmyk.m, cmyk.y, cmyk.k );
value.setColorF(cmyk.c, cmyk.m, cmyk.y, cmyk.k);
}
else if (color.getColorModel() == colorModelLab)
{
double L, a, b;
color.getLab(&L, &a, &b);
value.setColor(L * (shade / 100.0), a, b);
value.setLabColor(L * (shade / 100.0), a, b);
}
return value;
}
/trunk/Scribus/scribus/scpainterex_ps2.cpp
450,26 → 450,26
m_clipBBox = m_pathBBox;
}
 
void ScPainterEx_Ps2::putColor( ScColorShade& colorShade, bool doFill )
void ScPainterEx_Ps2::putColor(ScColorShade& colorShade, bool doFill)
{
ColorMode colorMode = m_colorMode;
int r = 0, g = 0, b = 0, gray = 0;
int c = 0, m = 0, y = 0, k = 0;
if ( m_options.toGray )
double r = 0, g = 0, b = 0, gray = 0;
double c = 0, m = 0, y = 0, k = 0;
if (m_options.toGray)
{
RGBColor rgb;
RGBColorF rgb;
ScColorEngine::getShadeColorRGB(colorShade.color, m_options.document, rgb, colorShade.shade);
rgb.getValues(r, g, b);
gray = qRound(0.3 * r + 0.59 * g + 0.11 * b);
gray = 0.3 * r + 0.59 * g + 0.11 * b;
if ( doFill && m_fillRule )
m_stream << QString("%1 setgray eofill\n").arg(gray/255.0);
m_stream << QString("%1 setgray eofill\n").arg(gray);
else if ( doFill )
m_stream << QString("%1 setgray fill\n").arg(gray/255.0);
m_stream << QString("%1 setgray fill\n").arg(gray);
else
m_stream << QString("%1 setgray stroke\n").arg(gray/255.0);
m_stream << QString("%1 setgray stroke\n").arg(gray);
return;
}
else if ( m_options.hProfile && m_options.rgbToOutputColorTransform && m_options.cmykToOutputColorTransform)
else if (m_options.hProfile && m_options.rgbToOutputColorTransform && m_options.cmykToOutputColorTransform)
{
unsigned long colorIn[4];
unsigned long colorOut[4];
476,22 → 476,22
ScColorTransform cmsTranform = NULL;
if( colorShade.color.getColorModel() == colorModelRGB )
{
RGBColor rgb;
RGBColorF rgb;
ScColorEngine::getShadeColorRGB(colorShade.color, m_options.document, rgb, colorShade.shade);
colorIn[0] = rgb.r;
colorIn[1] = rgb.g;
colorIn[2] = rgb.b;
colorIn[0] = rgb.r * 65535.0;
colorIn[1] = rgb.g * 65535.0;
colorIn[2] = rgb.b * 65535.0;
colorMode = rgbMode;
cmsTranform = m_options.rgbToOutputColorTransform;
}
else
{
CMYKColor cmyk;
CMYKColorF cmyk;
ScColorEngine::getShadeColorCMYK(colorShade.color, m_options.document, cmyk, colorShade.shade);
colorIn[0] = cmyk.c;
colorIn[1] = cmyk.m;
colorIn[2] = cmyk.y;
colorIn[3] = cmyk.k;
colorIn[0] = cmyk.c * 65535.0;
colorIn[1] = cmyk.m * 65535.0;
colorIn[2] = cmyk.y * 65535.0;
colorIn[3] = cmyk.k * 65535.0;
colorMode = cmykMode;
cmsTranform = m_options.cmykToOutputColorTransform;
}
498,23 → 498,23
cmsTranform.apply(colorIn, colorOut, 1 );
if (m_options.hProfile.colorSpace() == ColorSpace_Rgb)
{
r = colorOut[0] / 257;
g = colorOut[1] / 257;
b = colorOut[2] / 257;
r = colorOut[0] / 65535.0;
g = colorOut[1] / 65535.0;
b = colorOut[2] / 65535.0;
colorMode = rgbMode;
}
else if (m_options.hProfile.colorSpace() == ColorSpace_Cmyk)
{
c = colorOut[0] / 257;
m = colorOut[1] / 257;
y = colorOut[2] / 257;
k = colorOut[3] / 257;
c = colorOut[0] / 65535.0;
m = colorOut[1] / 65535.0;
y = colorOut[2] / 65535.0;
k = colorOut[3] / 65535.0;
colorMode = cmykMode;
}
}
else if ( m_colorMode == rgbMode )
else if (m_colorMode == rgbMode)
{
RGBColor rgb;
RGBColorF rgb;
colorMode = rgbMode;
ScColorEngine::getShadeColorRGB(colorShade.color, m_options.document, rgb, colorShade.shade);
rgb.getValues(r, g, b);
521,7 → 521,7
}
else if ( m_colorMode == cmykMode )
{
CMYKColor cmyk;
CMYKColorF cmyk;
colorMode = cmykMode;
ScColorEngine::getShadeColorCMYK(colorShade.color, m_options.document, cmyk, colorShade.shade);
cmyk.getValues(c, m, y, k);
528,18 → 528,18
}
 
// Finally output to file
if ( colorMode == rgbMode )
if (colorMode == rgbMode)
{
if ( doFill && m_fillRule )
m_stream << QString("%1 %2 %3 setrgbcolor eofill\n").arg(r/255.0).arg(g/255.0).arg(b/255.0);
if (doFill && m_fillRule)
m_stream << QString("%1 %2 %3 setrgbcolor eofill\n").arg(r).arg(g).arg(b);
else if ( doFill )
m_stream << QString("%1 %2 %3 setrgbcolor fill\n").arg(r/255.0).arg(g/255.0).arg(b/255.0);
m_stream << QString("%1 %2 %3 setrgbcolor fill\n").arg(r).arg(g).arg(b);
else
m_stream << QString("%1 %2 %3 setrgbcolor stroke\n").arg(r/255.0).arg(g/255.0).arg(b/255.0);
m_stream << QString("%1 %2 %3 setrgbcolor stroke\n").arg(r).arg(g).arg(b);
}
else if ( colorMode == cmykMode )
{
QString colstr1 = QString("%1 %2 %3 %4 setcmykcolor").arg(c/255.0).arg(m/255.0).arg(y/255.0).arg(k/255.0);
QString colstr1 = QString("%1 %2 %3 %4 setcmykcolor").arg(c).arg(m).arg(y).arg(k);
if ( doFill && m_fillRule )
m_stream << colstr1 << " eofill\n";
else if ( doFill )
549,21 → 549,21
}
}
 
void ScPainterEx_Ps2::drawImage( ScImage *image, ScPainterExBase::ImageMode mode )
void ScPainterEx_Ps2::drawImage(ScImage *image, ScPainterExBase::ImageMode mode)
{
bool rgbMode = (mode == ScPainterExBase::rgbImages);
bool rgbPicture = rgbMode || (mode == ScPainterExBase::rawImages && image->imgInfo.colorspace == ColorSpaceRGB);
bool cmykPicture = (mode == ScPainterExBase::cmykImages || (mode == ScPainterExBase::rawImages && image->imgInfo.colorspace == ColorSpaceCMYK));
 
if( rgbPicture )
drawRGBImage_ps2( image );
else if( cmykPicture )
drawCMYKImage_ps2( image );
if (rgbPicture)
drawRGBImage_ps2(image);
else if (cmykPicture)
drawCMYKImage_ps2(image);
else
qDebug( "ScPainterEx_Ps2::drawImage() : unknown image type" );
qDebug("ScPainterEx_Ps2::drawImage() : unknown image type");
}
 
void ScPainterEx_Ps2::drawRGBImage_ps2( ScImage *image )
void ScPainterEx_Ps2::drawRGBImage_ps2(ScImage *image)
{
save();
QString sc("[%1 %2 %3 %4 %5 %6] concat\n");
985,8 → 985,8
 
void ScPainterEx_Ps2::drawLinearGradient_RGB( VGradientEx& gradient, const QRect& rect )
{
int r1, g1, b1;
int r2, g2, b2;
double r1, g1, b1;
double r2, g2, b2;
double cosa, sina;
double ramp1, ramp2;
double length, scale;
995,27 → 995,27
QList<VColorStopEx*> colorStops = gradient.colorStops();
VColorStopEx stop1( *colorStops[0] );
VColorStopEx stop2( *colorStops[0] );
RGBColor rgb;
RGBColorF rgb;
FPoint p1, p2;
 
if ( gradient.Stops() < 2 )
if (gradient.Stops() < 2)
return;
 
clipBoxWidth = rect.width();
clipBoxHeight = rect.height();
maxDim = qRound(sqrt( (double) (clipBoxWidth * clipBoxWidth + clipBoxHeight * clipBoxHeight) )) * 2;
if ( maxDim <= 0 ) return;
if (maxDim <= 0) return;
 
x1 = m_matrix.dx() + gradient.origin().x() * m_matrix.m11();
y1 = m_matrix.dy() + gradient.origin().y() * m_matrix.m22();
x2 = m_matrix.dx() + gradient.vector().x() * m_matrix.m11();
y2 = m_matrix.dy() + gradient.vector().y() * m_matrix.m22();
p1.setXY( x1, y1 );
p2.setXY( x2, y2 );
p1.setXY(x1, y1);
p2.setXY(x2, y2);
 
dx = ( p2.x() - p1.x() );
dy = ( p2.y() - p1.y() );
length = sqrt(( dx * dx + dy * dy ));
dx = p2.x() - p1.x();
dy = p2.y() - p1.y();
length = sqrt(dx * dx + dy * dy);
if ( length == 0.0 )
scale = 1.0;
else
1031,7 → 1031,7
rgb.getValues(r1, g1, b1);
m_stream << QString("%1 %2 %3 setrgbcolor fill\n").arg(r1/255.0).arg(g1/255.0).arg(b1/255.0);
 
for( uint index = 1; index < gradient.Stops(); index++)
for (uint index = 1; index < gradient.Stops(); index++)
{
stop2 = *colorStops[index];
ramp2 = stop2.rampPoint;
1042,12 → 1042,12
 
m_stream << QString("/x1 %1 def\n").arg(xMin);
m_stream << QString("/x2 %1 def\n").arg(xMax);
m_stream << QString("/r1 %1 def\n").arg(r1/255.0);
m_stream << QString("/g1 %1 def\n").arg(g1/255.0);
m_stream << QString("/b1 %1 def\n").arg(b1/255.0);
m_stream << QString("/r2 %1 def\n").arg(r2/255.0);
m_stream << QString("/g2 %1 def\n").arg(g2/255.0);
m_stream << QString("/b2 %1 def\n").arg(b2/255.0);
m_stream << QString("/r1 %1 def\n").arg(r1);
m_stream << QString("/g1 %1 def\n").arg(g1);
m_stream << QString("/b1 %1 def\n").arg(b1);
m_stream << QString("/r2 %1 def\n").arg(r2);
m_stream << QString("/g2 %1 def\n").arg(g2);
m_stream << QString("/b2 %1 def\n").arg(b2);
m_stream << QString("/maxd %1 def\n").arg(maxDim);
m_stream << QString("/mmaxd %1 def\n").arg(-maxDim/2.0);
m_stream << "r1 r2 sub abs 255 mul /dr exch def\n";
1082,10 → 1082,10
}
}
 
void ScPainterEx_Ps2::drawLinearGradient_CMYK( VGradientEx& gradient, const QRect& rect )
void ScPainterEx_Ps2::drawLinearGradient_CMYK(VGradientEx& gradient, const QRect& rect)
{
int c1, m1, j1, n1;
int c2, m2, j2, n2;
double c1, m1, j1, n1;
double c2, m2, j2, n2;
double cosa, sina;
double ramp1, ramp2;
double length, scale;
1094,7 → 1094,7
QList<VColorStopEx*> colorStops = gradient.colorStops();
VColorStopEx stop1( *colorStops[0] );
VColorStopEx stop2( *colorStops[0] );
CMYKColor cmyk;
CMYKColorF cmyk;
FPoint p1, p2;
 
if ( gradient.Stops() < 2 )
1129,7 → 1129,7
ScColorEngine::getShadeColorCMYK(stop1.color, m_options.document, cmyk, stop1.shade);
cmyk.getValues(c1, m1, j1, n1);
m_stream << QString("/DeviceCMYK setcolorspace\n");
m_stream << QString("%1 %2 %3 %4 setcolor fill\n").arg(c1/255.0).arg(m1/255.0).arg(j1/255.0).arg(n1/255.0);
m_stream << QString("%1 %2 %3 %4 setcolor fill\n").arg(c1).arg(m1).arg(j1).arg(n1);
 
for( uint index = 1; index < gradient.Stops(); index++)
{
1142,14 → 1142,14
 
m_stream << QString("/x1 %1 def\n").arg(xMin);
m_stream << QString("/x2 %1 def\n").arg(xMax);
m_stream << QString("/c1 %1 def\n").arg(c1/255.0);
m_stream << QString("/m1 %1 def\n").arg(m1/255.0);
m_stream << QString("/y1 %1 def\n").arg(j1/255.0);
m_stream << QString("/k1 %1 def\n").arg(n1/255.0);
m_stream << QString("/c2 %1 def\n").arg(c2/255.0);
m_stream << QString("/m2 %1 def\n").arg(m2/255.0);
m_stream << QString("/y2 %1 def\n").arg(j2/255.0);
m_stream << QString("/k2 %1 def\n").arg(n2/255.0);
m_stream << QString("/c1 %1 def\n").arg(c1);
m_stream << QString("/m1 %1 def\n").arg(m1);
m_stream << QString("/y1 %1 def\n").arg(j1);
m_stream << QString("/k1 %1 def\n").arg(n1);
m_stream << QString("/c2 %1 def\n").arg(c2);
m_stream << QString("/m2 %1 def\n").arg(m2);
m_stream << QString("/y2 %1 def\n").arg(j2);
m_stream << QString("/k2 %1 def\n").arg(n2);
m_stream << QString("/maxd %1 def\n").arg(maxDim);
m_stream << QString("/mmaxd %1 def\n").arg(-maxDim/2.0);
m_stream << "c1 c2 sub abs 255 mul /dc exch def\n";
1198,14 → 1198,14
 
void ScPainterEx_Ps2::drawCircularGradient_RGB( VGradientEx& gradient, const QRect& rect )
{
int r1, g1, b1;
int r2, g2, b2;
double r1, g1, b1;
double r2, g2, b2;
double ramp1, ramp2;
int clipBoxWidth, clipBoxHeight, maxDim;
QList<VColorStopEx*> colorStops = gradient.colorStops();
VColorStopEx stop1( *colorStops[gradient.Stops() - 1] );
VColorStopEx stop2( *colorStops[gradient.Stops() - 1] );
RGBColor rgb;
RGBColorF rgb;
 
clipBoxWidth = rect.width();
clipBoxHeight = rect.height();
1217,11 → 1217,11
FPoint pf( gradient.focalPoint().x(), gradient.focalPoint().y() );
FPoint pfz( gradient.focalPoint().x(), gradient.focalPoint().y() );
FPoint pv( gradient.vector().x(), gradient.vector().y() );
transformPoint( pc, pc );
transformPoint( pf, pf );
transformPoint( pv, pv );
transformPoint( pcz, pcz );
transformPoint( pfz, pfz );
transformPoint(pc, pc);
transformPoint(pf, pf);
transformPoint(pv, pv);
transformPoint(pcz, pcz);
transformPoint(pfz, pfz);
double cx = pcz.x();
double cy = pcz.y();
double rad = sqrt( pow(pv.x() -pc.x(), 2) + pow(pv.y() - pc.y(), 2) );
1245,12 → 1245,12
m_stream << QString("/rad2 %1 def\n").arg(radMin);
m_stream << QString("/circx %1 def\n").arg(cx);
m_stream << QString("/circy %1 def\n").arg(cy);
m_stream << QString("/r1 %1 def\n").arg(r1/255.0);
m_stream << QString("/g1 %1 def\n").arg(g1/255.0);
m_stream << QString("/b1 %1 def\n").arg(b1/255.0);
m_stream << QString("/r2 %1 def\n").arg(r2/255.0);
m_stream << QString("/g2 %1 def\n").arg(g2/255.0);
m_stream << QString("/b2 %1 def\n").arg(b2/255.0);
m_stream << QString("/r1 %1 def\n").arg(r1);
m_stream << QString("/g1 %1 def\n").arg(g1);
m_stream << QString("/b1 %1 def\n").arg(b1);
m_stream << QString("/r2 %1 def\n").arg(r2);
m_stream << QString("/g2 %1 def\n").arg(g2);
m_stream << QString("/b2 %1 def\n").arg(b2);
m_stream << "r1 r2 sub abs 255 mul /dr exch def\n";
m_stream << "g1 g2 sub abs 255 mul /dg exch def\n";
m_stream << "b1 b2 sub abs 255 mul /db exch def\n";
1280,19 → 1280,19
 
void ScPainterEx_Ps2::drawCircularGradient_CMYK( VGradientEx& gradient, const QRect& rect )
{
int c1, m1, y1, k1;
int c2, m2, y2, k2;
double c1, m1, y1, k1;
double c2, m2, y2, k2;
double ramp1, ramp2;
int clipBoxWidth, clipBoxHeight, maxDim;
QList<VColorStopEx*> colorStops = gradient.colorStops();
VColorStopEx stop1( *colorStops[gradient.Stops() - 1] );
VColorStopEx stop2( *colorStops[gradient.Stops() - 1] );
CMYKColor cmyk;
CMYKColorF cmyk;
 
clipBoxWidth = rect.width();
clipBoxHeight = rect.height();
maxDim = qRound(sqrt( (double) (clipBoxWidth * clipBoxWidth + clipBoxHeight * clipBoxHeight) )) * 2;
if ( maxDim <= 0 ) return;
if (maxDim <= 0) return;
 
FPoint pc( gradient.origin().x(), gradient.origin().y() );
FPoint pcz( gradient.origin().x(), gradient.origin().y() );
1299,11 → 1299,11
FPoint pf( gradient.focalPoint().x(), gradient.focalPoint().y() );
FPoint pfz( gradient.focalPoint().x(), gradient.focalPoint().y() );
FPoint pv( gradient.vector().x(), gradient.vector().y() );
transformPoint( pc, pc );
transformPoint( pf, pf );
transformPoint( pv, pv );
transformPoint( pcz, pcz );
transformPoint( pfz, pfz );
transformPoint(pc, pc);
transformPoint(pf, pf);
transformPoint(pv, pv);
transformPoint(pcz, pcz);
transformPoint(pfz, pfz);
double cx = pcz.x();
double cy = pcz.y();
double rad = sqrt( pow(pv.x() -pc.x(), 2) + pow(pv.y() - pc.y(), 2) );
1313,9 → 1313,9
cmyk.getValues(c2, m2, y2, k2);
m_stream << QString("/DeviceCMYK setcolorspace\n");
m_stream << QString("%0 %1 %2 %3 setcolor fill\n").arg(c2).arg(m2).arg(y2).arg(k2);
if ( gradient.Stops() < 2 ) return;
if (gradient.Stops() < 2) return;
 
for( int index = gradient.Stops() - 2; index >= 0; index--)
for (int index = gradient.Stops() - 2; index >= 0; index--)
{
stop1 = *colorStops[index];
ramp1 = stop1.rampPoint;
1328,14 → 1328,14
m_stream << QString("/rad2 %1 def\n").arg(radMin);
m_stream << QString("/circx %1 def\n").arg(cx);
m_stream << QString("/circy %1 def\n").arg(cy);
m_stream << QString("/c1 %1 def\n").arg(c1/255.0);
m_stream << QString("/m1 %1 def\n").arg(m1/255.0);
m_stream << QString("/y1 %1 def\n").arg(y1/255.0);
m_stream << QString("/k1 %1 def\n").arg(k1/255.0);
m_stream << QString("/c2 %1 def\n").arg(c2/255.0);
m_stream << QString("/m2 %1 def\n").arg(m2/255.0);
m_stream << QString("/y2 %1 def\n").arg(y2/255.0);
m_stream << QString("/k2 %1 def\n").arg(k2/255.0);
m_stream << QString("/c1 %1 def\n").arg(c1);
m_stream << QString("/m1 %1 def\n").arg(m1);
m_stream << QString("/y1 %1 def\n").arg(y1);
m_stream << QString("/k1 %1 def\n").arg(k1);
m_stream << QString("/c2 %1 def\n").arg(c2);
m_stream << QString("/m2 %1 def\n").arg(m2);
m_stream << QString("/y2 %1 def\n").arg(y2);
m_stream << QString("/k2 %1 def\n").arg(k2);
m_stream << "c1 c2 sub abs 255 mul /dc exch def\n";
m_stream << "m1 m2 sub abs 255 mul /dm exch def\n";
m_stream << "y1 y2 sub abs 255 mul /dy exch def\n";
/trunk/Scribus/scribus/scribusstructs.h
39,23 → 39,40
 
extern bool SCRIBUS_API compareDouble(double, double);
 
typedef struct
struct RGBColor
{
int r;
int g;
int b;
void getValues(int& vr, int& vg, int& vb) {vr = r; vg = g; vb = b;}
} RGBColor;
void getValues(int& vr, int& vg, int& vb) { vr = r; vg = g; vb = b; }
};
 
typedef struct
struct RGBColorF
{
double r;
double g;
double b;
void getValues(double& vr, double& vg, double& vb) { vr = r; vg = g; vb = b; }
};
 
struct CMYKColor
{
int c;
int m;
int y;
int k;
void getValues(int& vc, int& vm, int& vy, int& vk) {vc = c; vm = m; vy = y; vk = k;}
} CMYKColor;
void getValues(int& vc, int& vm, int& vy, int& vk) { vc = c; vm = m; vy = y; vk = k; }
};
 
struct CMYKColorF
{
double c;
double m;
double y;
double k;
void getValues(double& vc, double& vm, double& vy, double& vk) { vc = c; vm = m; vy = y; vk = k; }
};
 
struct CopyContentsBuffer
{
PageItem::ItemType sourceType;
/trunk/Scribus/scribus/ui/cmykfw.cpp
164,12 → 164,12
if (orig.getColorModel () == colorModelCMYK)
{
double ccd, cmd, cyd, ckd;
CMYKColor cmyk;
CMYKColorF cmyk;
ScColorEngine::getCMYKValues(orig, m_doc, cmyk);
ccd = cmyk.c / 2.55;
cmd = cmyk.m / 2.55;
cyd = cmyk.y / 2.55;
ckd = cmyk.k / 2.55;
ccd = cmyk.c * 100.0;
cmd = cmyk.m * 100.0;
cyd = cmyk.y * 100.0;
ckd = cmyk.k * 100.0;
CyanSp->setValue(ccd);
CyanSL->setValue(qRound(ccd * 1000));
MagentaSp->setValue(cmd);
178,7 → 178,7
YellowSL->setValue(qRound(cyd * 1000));
BlackSp->setValue(ckd);
BlackSL->setValue(qRound(ckd * 1000));
BlackComp = cmyk.k;
BlackComp = qRound(cmyk.k * 255.0);
}
int h, s, v;
ScColorEngine::getRGBColor(orig, m_doc).getHsv(&h, &s, &v);
841,18 → 841,18
 
void CMYKChoose::setColor()
{
int c, m, y;
int h, s, v;
int k = 0;
int h, s, v;
double c, m, y;
double k = 0;
double L, a, b;
ScColor tmp;
if (Farbe.getColorModel() == colorModelCMYK)
{
c = qRound(CyanSp->value() * 2.55);
m = qRound(MagentaSp->value() * 2.55);
y = qRound(YellowSp->value() * 2.55);
k = qRound(BlackSp->value() * 2.55);
tmp.setColor(c, m, y, k);
c = CyanSp->value() / 100.0;
m = MagentaSp->value() / 100.0;
y = YellowSp->value() / 100.0;
k = BlackSp->value() / 100.0;
tmp.setColorF(c, m, y, k);
Farbe = tmp;
if (dynamic)
{
861,7 → 861,7
YellowSL->setPalette(sliderPix(60));
BlackSL->setPalette(sliderBlack());
}
BlackComp = k;
BlackComp = qRound(k * 255.0);
ScColorEngine::getRGBColor(tmp, m_doc).getHsv(&h, &s, &v);
ColorMap->drawPalette(v);
ColorMap->setMark(h, s);
868,26 → 868,30
}
else if (Farbe.getColorModel() == colorModelRGB)
{
c = qRound(CyanSp->value());
m = qRound(MagentaSp->value());
y = qRound(YellowSp->value());
k = qRound(BlackSp->value());
int ic = qRound(CyanSp->value());
int im = qRound(MagentaSp->value());
int iy = qRound(YellowSp->value());
int ik = qRound(BlackSp->value());
if (Wsave)
{
ic = ic / 51 * 51;
im = im / 51 * 51;
iy = iy / 51 * 51;
blockSignals(true);
c = c / 51 * 51;
m = m / 51 * 51;
y = y / 51 * 51;
CyanSp->setValue(c);
MagentaSp->setValue(m);
YellowSp->setValue(y);
CyanSL->setValue(c * 1000.0);
MagentaSL->setValue(m * 1000.0);
YellowSL->setValue(y * 1000.0);
CyanSp->setValue(ic);
MagentaSp->setValue(im);
YellowSp->setValue(iy);
CyanSL->setValue(ic * 1000.0);
MagentaSL->setValue(im * 1000.0);
YellowSL->setValue(iy * 1000.0);
blockSignals(false);
}
tmp.setColorRGB(c, m, y);
QColor tmp2 = QColor(c, m, y);
c = ic / 255.0;
m = im / 255.0;
y = iy / 255.0;
k = ik / 255.0;
tmp.setRgbColorF(c, m, y);
QColor tmp2 = ScColorEngine::getRGBColor(tmp, m_doc);
tmp2.getHsv(&h, &s, &v);
BlackComp = 255 - v;
Farbe = tmp;
897,7 → 901,7
MagentaSL->setPalette(sliderPix(120));
YellowSL->setPalette(sliderPix(240));
}
BlackComp = k;
BlackComp = qRound(k * 255.0);
ScColorEngine::getRGBColor(tmp, m_doc).getHsv(&h, &s, &v);
ColorMap->drawPalette(v);
ColorMap->setMark(h, s);
921,7 → 925,7
a = MagentaSp->value();
b = YellowSp->value();
}
tmp.setColor(L, a, b);
tmp.setLabColor(L, a, b);
Farbe = tmp;
if (dynamic)
{
952,19 → 956,22
}
else
{
QColor tm = QColor::fromHsv(qMax(qMin(359,h),0), qMax(qMin(255,255-s),0), 255-BlackComp, QColor::Hsv);
int r, g, b;
int ih = qMax(0, qMin(h, 359));
int is = qMax(0, qMin(255 - s, 255));
int iv = 255 - BlackComp;
QColor tm = QColor::fromHsv(ih, is, iv);
tm.getRgb(&r, &g, &b);
tmp.fromQColor(tm);
if (Farbe.getColorModel() == colorModelCMYK)
{
CMYKColor cmyk;
CMYKColorF cmyk;
ScColorEngine::getCMYKValues(tmp, m_doc, cmyk);
tmp.setColor(cmyk.c, cmyk.m, cmyk.y, cmyk.k);
tmp.setColorF(cmyk.c, cmyk.m, cmyk.y, cmyk.k);
}
}
imageN.fill( ScColorEngine::getDisplayColor(tmp, m_doc) );
if ( ScColorEngine::isOutOfGamut(tmp, m_doc) )
if (ScColorEngine::isOutOfGamut(tmp, m_doc))
paintAlert(alertIcon, imageN, 2, 2, false);
NewC->setPixmap( imageN );
Farbe = tmp;
1025,18 → 1032,18
 
if (Farbe.getColorModel() == colorModelCMYK)
{
CMYKColor cmyk;
int cc, cm, cy, ck;
CMYKColorF cmyk;
double cc, cm, cy, ck;
ScColorEngine::getCMYKValues(Farbe, m_doc, cmyk);
cmyk.getValues(cc, cm, cy, ck);
CyanSp->setValue(cc / 2.55);
CyanSL->setValue(qRound(cc / 2.55) * 1000.0);
MagentaSp->setValue(cm / 2.55);
MagentaSL->setValue(qRound(cm / 2.55) * 1000.0);
YellowSp->setValue(cy / 2.55);
YellowSL->setValue(qRound(cy / 2.55) * 1000.0);
BlackSp->setValue(ck / 2.55);
BlackSL->setValue(qRound(ck / 2.55) * 1000.0);
CyanSp->setValue(cc * 100.0);
CyanSL->setValue(qRound(cc * 100.0 * 1000.0));
MagentaSp->setValue(cm * 100.0);
MagentaSL->setValue(qRound(cm * 100.0 * 1000.0));
YellowSp->setValue(cy * 100.0);
YellowSL->setValue(qRound(cy * 100.0 * 1000.0));
BlackSp->setValue(ck * 100.0);
BlackSL->setValue(qRound(ck * 100.0 * 1000.0));
if (dynamic)
{
CyanSL->setPalette(sliderPix(180));
/trunk/Scribus/scribus/ui/colorlistmodel.cpp
58,9 → 58,9
}
else if (color.getColorModel() == colorModelCMYK)
{
int c, m, y, k;
double c, m, y, k;
color.getCMYK(&c, &m, &y, &k);
return tr("C: %1% M: %2% Y: %3% K: %4%").arg(qRound(c / 2.55)).arg(qRound(m / 2.55)).arg(qRound(y / 2.55)).arg(qRound(k / 2.55));
return tr("C: %1% M: %2% Y: %3% K: %4%").arg(c * 100, 0, 'f', 2).arg(m * 100, 0, 'f', 2).arg(y * 100, 0, 'f', 2).arg(k * 100, 0, 'f', 2);
}
else if (color.getColorModel() == colorModelLab)
{
/trunk/Scribus/scribus/ui/colorsandfills.cpp
1443,9 → 1443,9
}
else if (color.getColorModel() == colorModelCMYK)
{
int c, m, y, k;
double c, m, y, k;
color.getCMYK(&c, &m, &y, &k);
tooltip = tr("C: %1% M: %2% Y: %3% K: %4%").arg(qRound(c / 2.55)).arg(qRound(m / 2.55)).arg(qRound(y / 2.55)).arg(qRound(k / 2.55));
return tr("C: %1% M: %2% Y: %3% K: %4%").arg(c * 100, 0, 'f', 2).arg(m * 100, 0, 'f', 2).arg(y * 100, 0, 'f', 2).arg(k * 100, 0, 'f', 2);
}
else if (color.getColorModel() == colorModelLab)
{
1737,7 → 1737,7
Rc = qRound(r * 255);
Gc = qRound(g * 255);
Bc = qRound(b * 255);
lf.setColorRGB(Rc, Gc, Bc);
lf.setRgbColor(Rc, Gc, Bc);
for (ColorList::Iterator it = m_colorList.begin(); it != m_colorList.end(); ++it)
{
if (it.value().getColorModel() == colorModelRGB)
1784,10 → 1784,43
if (dc.tagName()=="COLOR")
{
ScColor lf = ScColor();
if (dc.hasAttribute("CMYK"))
if (dc.hasAttribute("SPACE"))
{
QString space = dc.attribute("SPACE");
if (space == "CMYK")
{
double c = dc.attribute("C", "0").toDouble() / 100.0;
double m = dc.attribute("M", "0").toDouble() / 100.0;
double y = dc.attribute("Y", "0").toDouble() / 100.0;
double k = dc.attribute("K", "0").toDouble() / 100.0;
lf.setCmykColorF(c, m, y, k);
}
else if (space == "RGB")
{
double r = dc.attribute("R", "0").toDouble() / 255.0;
double g = dc.attribute("G", "0").toDouble() / 255.0;
double b = dc.attribute("B", "0").toDouble() / 255.0;
lf.setRgbColorF(r, g, b);
}
else if (space == "Lab")
{
double L = dc.attribute("L", "0").toDouble();
double a = dc.attribute("A", "0").toDouble();
double b = dc.attribute("B", "0").toDouble();
lf.setLabColor(L, a, b);
}
}
else if (dc.hasAttribute("CMYK"))
lf.setNamedColor(dc.attribute("CMYK"));
else if (dc.hasAttribute("RGB"))
lf.fromQColor(QColor(dc.attribute("RGB")));
else
lf.fromQColor(QColor(dc.attribute("RGB")));
{
double L = dc.attribute("L", "0").toDouble();
double a = dc.attribute("A", "0").toDouble();
double b = dc.attribute("B", "0").toDouble();
lf.setLabColor(L, a, b);
}
if (dc.hasAttribute("Spot"))
lf.setSpotColor(static_cast<bool>(dc.attribute("Spot").toInt()));
else
/trunk/Scribus/scribus/util_color.cpp
828,7 → 828,7
bool validColor = false;
if (colType == 0) // RBG
{
lf.setColorRGB(componentR, componentG, componentB);
lf.setRgbColor(componentR, componentG, componentB);
validColor = true;
}
else if (colType == 2) // CMYK
896,7 → 896,7
}
if (!colorName.isEmpty())
{
lf.setColorRGB(r, g, b);
lf.setRgbColor(r, g, b);
lf.setSpotColor(false);
lf.setRegistrationColor(false);
EditColors.tryAddColor(colorName, lf);
943,7 → 943,7
bool validColor = false;
if (colType == 0) // RBG
{
lf.setColorRGB(componentR >> 8, componentG >> 8, componentB >> 8);
lf.setRgbColor(componentR >> 8, componentG >> 8, componentB >> 8);
validColor = true;
}
else if (colType == 1) // HSB
953,7 → 953,7
sc = componentG >> 8;
bc = componentB >> 8;
HSVTORGB(hc, sc, bc);
lf.setColorRGB(hc, sc, bc);
lf.setRgbColor(hc, sc, bc);
validColor = true;
}
else if (colType == 2) // CMYK
989,7 → 989,7
bool validColor = false;
if (colType == 0) // RBG
{
lf.setColorRGB(componentR >> 8, componentG >> 8, componentB >> 8);
lf.setRgbColor(componentR >> 8, componentG >> 8, componentB >> 8);
validColor = true;
}
else if (colType == 1) // HSB
999,7 → 999,7
sc = componentG >> 8;
bc = componentB >> 8;
HSVTORGB(hc, sc, bc);
lf.setColorRGB(hc, sc, bc);
lf.setRgbColor(hc, sc, bc);
validColor = true;
}
else if (colType == 2) // CMYK
1065,7 → 1065,7
float r, g, b;
ts >> r >> g >> b;
ts >> spotMode;
lf.setColorRGB(qRound(255 * r), qRound(255 * g), qRound(255 * b));
lf.setRgbColorF(r, g, b);
lf.setSpotColor(spotMode == 1);
lf.setRegistrationColor(false);
if (Cname.isEmpty())
1080,7 → 1080,7
float c, m, y, k;
ts >> c >> m >> y >> k;
ts >> spotMode;
lf.setColor(qRound(255 * c), qRound(255 * m), qRound(255 * y), qRound(255 * k));
lf.setColorF(c, m, y, k);
lf.setSpotColor(spotMode == 1);
lf.setRegistrationColor(false);
if (Cname.isEmpty())
1095,7 → 1095,7
float g;
ts >> g;
ts >> spotMode;
lf.setColor(0, 0, 0, qRound(255 * g));
lf.setColorF(0, 0, 0, g);
lf.setSpotColor(spotMode == 1);
lf.setRegistrationColor(false);
if (Cname.isEmpty())
1110,7 → 1110,7
float L, a, b;
ts >> L >> a >> b;
ts >> spotMode;
lf.setColor(L * 100.0, a, b);
lf.setLabColor(L * 100.0, a, b);
lf.setSpotColor(spotMode == 1);
lf.setRegistrationColor(false);
if (Cname.isEmpty())
1162,7 → 1162,7
Cname = pg.attribute("name", "");
if (!Cname.isEmpty())
{
lf.setColor(qRound(255 * c), qRound(255 * m), qRound(255 * y), qRound(255 * k));
lf.setColorF(c, m, y, k);
lf.setSpotColor(false);
lf.setRegistrationColor(false);
EditColors.tryAddColor(Cname, lf);
1177,7 → 1177,7
Cname = pg.attribute("name", "");
if (!Cname.isEmpty())
{
lf.setColorRGB(qRound(255 * r), qRound(255 * g), qRound(255 * b));
lf.setRgbColorF(r, g, b);
lf.setSpotColor(false);
lf.setRegistrationColor(false);
EditColors.tryAddColor(Cname, lf);
1237,7 → 1237,7
CoE >> inC[0];
CoE >> inC[1];
CoE >> inC[2];
tmp.setColor(inC[0], inC[1], inC[2]);
tmp.setLabColor(inC[0], inC[1], inC[2]);
tmp.setSpotColor(isSpot);
}
else if (spp.attribute("model") == "CMYK")
1244,7 → 1244,7
{
double c, m, y, k;
CoE >> c >> m >> y >> k;
tmp.setColor(qRound(255 * c), qRound(255 * m), qRound(255 * y), qRound(255 * k));
tmp.setColorF(c, m, y, k);
tmp.setSpotColor(isSpot);
}
else if (spp.attribute("model") == "RGB")
1251,7 → 1251,7
{
double r, g, b;
CoE >> r >> g >> b;
tmp.setColorRGB(qRound(255 * r), qRound(255 * g), qRound(255 * b));
tmp.setRgbColorF(r, g, b);
tmp.setSpotColor(false);
}
}
1295,12 → 1295,38
QString nameMask = "%1";
nameMask = elem.attribute("mask", "%1");
QDomNode PAGE = elem.firstChild();
while(!PAGE.isNull())
while (!PAGE.isNull())
{
QDomElement pg = PAGE.toElement();
if(pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None)
if (pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None)
{
if (pg.hasAttribute("CMYK"))
if (pg.hasAttribute("SPACE"))
{
QString space = pg.attribute("SPACE");
if (space == "CMYK")
{
double c = pg.attribute("C", "0").toDouble() / 100.0;
double m = pg.attribute("M", "0").toDouble() / 100.0;
double y = pg.attribute("Y", "0").toDouble() / 100.0;
double k = pg.attribute("K", "0").toDouble() / 100.0;
lf.setCmykColorF(c, m, y, k);
}
else if (space == "RGB")
{
double r = pg.attribute("R", "0").toDouble() / 255.0;
double g = pg.attribute("G", "0").toDouble() / 255.0;
double b = pg.attribute("B", "0").toDouble() / 255.0;
lf.setRgbColorF(r, g, b);
}
else if (space == "Lab")
{
double L = pg.attribute("L", "0").toDouble();
double a = pg.attribute("A", "0").toDouble();
double b = pg.attribute("B", "0").toDouble();
lf.setLabColor(L, a, b);
}
}
else if (pg.hasAttribute("CMYK"))
lf.setNamedColor(pg.attribute("CMYK"));
else if (pg.hasAttribute("RGB"))
lf.fromQColor(QColor(pg.attribute("RGB")));
1309,7 → 1335,7
double L = pg.attribute("L", "0").toDouble();
double a = pg.attribute("A", "0").toDouble();
double b = pg.attribute("B", "0").toDouble();
lf.setColor(L, a, b);
lf.setLabColor(L, a, b);
}
if (pg.hasAttribute("Spot"))
lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt()));
1390,7 → 1416,7
kVal = colVal.text().toInt();
colNode = colNode.nextSibling();
}
lf.setColor(qRound(2.55 * cVal), qRound(2.55 * mVal), qRound(2.55 * yVal), qRound(2.55 * kVal));
lf.setColorF(cVal / 100.0, mVal / 100.0, yVal / 100.0, kVal / 100.0);
lf.setSpotColor(false);
lf.setRegistrationColor(false);
if (!nam.isEmpty())
1410,7 → 1436,7
yVal = colVal.text().toInt();
colNode = colNode.nextSibling();
}
lf.setColorRGB(cVal, mVal, yVal);
lf.setRgbColor(cVal, mVal, yVal);
lf.setSpotColor(false);
lf.setRegistrationColor(false);
if (!nam.isEmpty())
1449,7 → 1475,7
else
{
Cname = CoE.readAll().trimmed();
tmp.setColorRGB(Rval, Gval, Bval);
tmp.setRgbColor(Rval, Gval, Bval);
}
if (Cname == "Untitled")
Cname = "";