mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
just massage the input format
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4028 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
83c2be0da4
commit
6277647f63
@ -1,3 +1,8 @@
|
|||||||
|
2002-04-18 Lars Gullik Bjønnes <larsbj@birdstep.com>
|
||||||
|
|
||||||
|
* GraphicsImageXPM.C (convertTo7chars): drop all conversions and
|
||||||
|
only work on the string.
|
||||||
|
|
||||||
2002-04-17 Angus Leeming <a.leeming@ic.ac.uk>
|
2002-04-17 Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
|
|
||||||
* GraphicsImageXPM.C (Data::reset): Fix the loading of xpm files by
|
* GraphicsImageXPM.C (Data::reset): Fix the loading of xpm files by
|
||||||
@ -57,7 +62,7 @@
|
|||||||
path to graphics file.
|
path to graphics file.
|
||||||
|
|
||||||
* GraphicsParams.[Ch] (c-tor): now passed filepath.
|
* GraphicsParams.[Ch] (c-tor): now passed filepath.
|
||||||
|
|
||||||
2002-03-21 Lars Gullik Bjønnes <larsbj@birdstep.com>
|
2002-03-21 Lars Gullik Bjønnes <larsbj@birdstep.com>
|
||||||
|
|
||||||
* most files: ws cleanup
|
* most files: ws cleanup
|
||||||
|
@ -516,6 +516,7 @@ void GImageXPM::Data::resetData(int w, int h, unsigned int * d)
|
|||||||
data_.reset(d);
|
data_.reset(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned int * GImageXPM::Data::initialisedData(int w, int h) const
|
unsigned int * GImageXPM::Data::initialisedData(int w, int h) const
|
||||||
{
|
{
|
||||||
size_t const data_size = w * h;
|
size_t const data_size = w * h;
|
||||||
@ -558,52 +559,27 @@ string const convertTo7chars(string const & input)
|
|||||||
// Can't deal with it.
|
// Can't deal with it.
|
||||||
return input;
|
return input;
|
||||||
|
|
||||||
int nbytes;
|
string format(input);
|
||||||
double factor;
|
|
||||||
switch (size) {
|
switch (size) {
|
||||||
case 13: // #rrrrggggbbbb
|
case 13: // #rrrrggggbbbb
|
||||||
nbytes = 4;
|
format.erase(3, 2);
|
||||||
factor = 1.0 / 256.0;
|
format.erase(5, 2);
|
||||||
break;
|
format.erase(7, 2);
|
||||||
|
break;
|
||||||
case 10: // #rrrgggbbb
|
case 10: // #rrrgggbbb
|
||||||
nbytes = 3;
|
format.erase(3, 1);
|
||||||
factor = 1.0 / 16.0;
|
format.erase(5, 1);
|
||||||
break;
|
format.erase(7, 1);
|
||||||
|
break;
|
||||||
case 4: // #rgb
|
case 4: // #rgb
|
||||||
nbytes = 1;
|
format.insert(2, 1, '0');
|
||||||
factor = 16.0;
|
format.insert(4, 1, '0');
|
||||||
break;
|
format.append(1, '0');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int r, g, b;
|
return format;
|
||||||
int const pos1 = 1;
|
|
||||||
int const pos2 = pos1 + nbytes;
|
|
||||||
int const pos3 = pos2 + nbytes;
|
|
||||||
|
|
||||||
stringstream ss;
|
|
||||||
ss << input.substr(pos1, nbytes) << ' '
|
|
||||||
<< input.substr(pos2, nbytes) << ' '
|
|
||||||
<< input.substr(pos3, nbytes);
|
|
||||||
ss >> std::hex >> r >> g >> b;
|
|
||||||
if (ss.fail())
|
|
||||||
// Oh, you're on your own.
|
|
||||||
return input;
|
|
||||||
|
|
||||||
// The existing r,g,b values are multiplied by these factors
|
|
||||||
// to end up with values in the range 0 <= c <= 255
|
|
||||||
r = int(factor * double(r));
|
|
||||||
g = int(factor * double(g));
|
|
||||||
b = int(factor * double(b));
|
|
||||||
|
|
||||||
ostringstream oss;
|
|
||||||
oss << '#' << std::hex << std::setfill('0')
|
|
||||||
<< std::setw(2) << r
|
|
||||||
<< std::setw(2) << g
|
|
||||||
<< std::setw(2) << b;
|
|
||||||
|
|
||||||
return oss.str().c_str();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user