]> git.lyx.org Git - features.git/commitdiff
just massage the input format
authorLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 18 Apr 2002 17:48:55 +0000 (17:48 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 18 Apr 2002 17:48:55 +0000 (17:48 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4028 a592a061-630c-0410-9148-cb99ea01b6c8

src/graphics/ChangeLog
src/graphics/GraphicsImageXPM.C

index bc4c5cfcb99b61b595c7301347c031710bf68aa8..3a6188d528b8e7a35d0973379029ed4fdbe55685 100644 (file)
@@ -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>
 
        * GraphicsImageXPM.C (Data::reset): Fix the loading of xpm files by
@@ -57,7 +62,7 @@
        path to graphics file.
 
        * GraphicsParams.[Ch] (c-tor): now passed filepath.
-       
+
 2002-03-21  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * most files: ws cleanup
index 453bbb0b15301230507628e16242313be2eb490c..23f0c3b69cf31113ba1d8a67b4dd57e6452ae775 100644 (file)
@@ -516,6 +516,7 @@ void GImageXPM::Data::resetData(int w, int h, unsigned int * d)
        data_.reset(d);
 }
 
+
 unsigned int * GImageXPM::Data::initialisedData(int w, int h) const
 {
        size_t const data_size = w * h;
@@ -558,52 +559,27 @@ string const convertTo7chars(string const & input)
                // Can't deal with it.
                return input;
 
-       int nbytes;
-       double factor;
+       string format(input);
+
        switch (size) {
        case 13: // #rrrrggggbbbb
-           nbytes = 4;
-           factor = 1.0 / 256.0;
-           break;
-
+               format.erase(3, 2);
+               format.erase(5, 2);
+               format.erase(7, 2);
+               break;
        case 10: // #rrrgggbbb
-           nbytes = 3;
-           factor = 1.0 / 16.0;
-           break;
-
-       case 4:  // #rgb
-           nbytes = 1;
-           factor = 16.0;
-           break;
+               format.erase(3, 1);
+               format.erase(5, 1);
+               format.erase(7, 1);
+               break;
+       case 4: // #rgb
+               format.insert(2, 1, '0');
+               format.insert(4, 1, '0');
+               format.append(1, '0');
+               break;
        }
 
-       int r, g, b;
-       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();
+       return format;
 }