Angus Leeming <[EMAIL PROTECTED]> writes: | On Thursday 18 April 2002 2:37 pm, Lars Gullik Bjønnes wrote: >> | Feel free to patch. >> >> rrrr is a 2 byte integer so just loose the less important ones >> 8 >> rrr is a 1.5 byte integer >> 4 (does this format even exist?) >> r is a 0.5 byte integer << 4 (does this format exist?) > | xforms tests for them, so why not GraphicsImageXPM. > >> with rr then just do nothing. > | and the patch is where exactly? Ahhh. You must have applied it already?
how about this one? Index: GraphicsImageXPM.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/graphics/GraphicsImageXPM.C,v retrieving revision 1.10 diff -u -p -r1.10 GraphicsImageXPM.C --- GraphicsImageXPM.C 17 Apr 2002 16:08:31 -0000 1.10 +++ GraphicsImageXPM.C 18 Apr 2002 13:55:32 -0000 @@ -558,52 +558,28 @@ string const convertTo7chars(string cons // Can't deal with it. return input; - int nbytes; - double factor; - switch (size) { - case 13: // #rrrrggggbbbb - nbytes = 4; - factor = 1.0 / 256.0; - break; - - case 10: // #rrrgggbbb - nbytes = 3; - factor = 1.0 / 16.0; - break; + string format(input); - case 4: // #rgb - nbytes = 1; - factor = 16.0; - break; + switch (size) { + case 13: + format.erase(3, 2); + format.erase(5, 2); + format.erase(7, 2); + break; + case 10: + format.erase(3, 1); + format.erase(5, 1); + format.erase(7, 1); + break; + case 4: + 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; } -- Lgb