[EMAIL PROTECTED] schrieb:
Author: rgheck
Date: Wed Jun 6 21:33:57 2007
New Revision: 18692
URL: http://www.lyx.org/trac/changeset/18692
Log:
Fix bug 3823: Division needs not to return an integer.
Also added some comments about a different possible fix.
Two things:
- Why do we divide by 255 and not by 256?
- There are two more places where a floating point division may be useful.
Please have a look at the attached patch.
Comments? Ok?
Michael
Index: LaTeXFeatures.cpp
===================================================================
--- LaTeXFeatures.cpp (Revision 18800)
+++ LaTeXFeatures.cpp (Arbeitskopie)
@@ -491,7 +491,7 @@
// shadecolor for shaded
if (mustProvide("framed") && mustProvide("color")) {
RGBColor c = RGBColor(lcolor.getX11Name(Color::shadedbg));
- //255.0 to force conversion to double
+ //256.0 to force conversion to double
//NOTE As Jürgen Spitzmüller pointed out, an alternative would be
//to use the xcolor package instead, and then we can do
// \define{shadcolor}{RGB}...
@@ -499,7 +499,7 @@
//in InsetNote::validate().
int const stmSize = packages.precision(2);
packages << "\\definecolor{shadecolor}{rgb}{"
- << c.r/255.0 << ',' << c.g/255.0 << ',' << c.b/255.0 << "}\n";
+ << c.r / 256.0 << ',' << c.g / 256.0 << ',' << c.b / 256.0 << "}\n";
packages.precision(stmSize);
}
@@ -664,11 +664,11 @@
if (mustProvide("ct-xcolor-soul")) {
RGBColor cadd = RGBColor(lcolor.getX11Name(Color::addedtext));
macros << "\\providecolor{lyxadded}{rgb}{"
- << cadd.r/255 << ',' << cadd.g/255 << ',' << cadd.b/255 << "}\n";
+ << cadd.r / 256.0 << ',' << cadd.g / 256.0 << ',' << cadd.b / 256.0 << "}\n";
RGBColor cdel = RGBColor(lcolor.getX11Name(Color::deletedtext));
macros << "\\providecolor{lyxdeleted}{rgb}{"
- << cdel.r/255 << ',' << cdel.g/255 << ',' << cdel.b/255 << "}\n";
+ << cdel.r / 256.0 << ',' << cdel.g / 256.0 << ',' << cdel.b / 256.0 << "}\n";
macros << "\\newcommand{\\lyxadded}[3]{{\\color{lyxadded}#3}}\n"
<< "\\newcommand{\\lyxdeleted}[3]{{\\color{lyxdeleted}\\st{#3}}}\n";
Index: Color.cpp
===================================================================
--- Color.cpp (Revision 18800)
+++ Color.cpp (Arbeitskopie)
@@ -162,9 +162,9 @@
}
}
- r = static_cast<int>(::floor((rd * 255.0) + 0.5));
- g = static_cast<int>(::floor((gd * 255.0) + 0.5));
- b = static_cast<int>(::floor((bd * 255.0) + 0.5));
+ r = static_cast<int>(::floor((rd * 256.0) + 0.5));
+ g = static_cast<int>(::floor((gd * 256.0) + 0.5));
+ b = static_cast<int>(::floor((bd * 256.0) + 0.5));
}
@@ -176,9 +176,9 @@
HSVColor::HSVColor(RGBColor const & rgb)
{
- double const r = rgb.r / 255.0;
- double const g = rgb.g / 255.0;
- double const b = rgb.b / 255.0;
+ double const r = rgb.r / 256.0;
+ double const g = rgb.g / 256.0;
+ double const b = rgb.b / 256.0;
double const maxval = max(max(r, g), b);
double const minval = min(min(r, g), b);