![]() |
【转帖】problem with colorindex in a ctb file
problem with colorindex in a ctb file
problem with colorindex in a ctb file we have incorrect value return by odcmentitycolor::colorindex after loading a ctb file. here the code but i can't upload the ctb file with the problem. i test it in odamfcapp. code: void badcolorinplotstyletable() { try { lpctstr lpcszpathnamectb = "c:\\test.ctb"; odgicontextfordbdatabaseptr odgicontextfordbdatabaseptr = odgicontextfordbdatabase::createobject(); odstreambufptr pfilebuf; if(theapp.accessfile(lpcszpathnamectb, oda::kfileread)) { pfilebuf = theapp.createfile(lpcszpathnamectb); } if (!pfilebuf.isnull()) { odgicontextfordbdatabaseptr->loadplotstyletable(pfilebuf); } odcmentitycolor odcmentitycolor; odpsplotstyledata odpsplotstyledata; oduint8 nred = 0, ngreen = 0, nblue = 0; int ncolorindex = 0; int iindex; bool bcolor; iindex = 1; odgicontextfordbdatabaseptr->plotstyle(iindex, odpsplotstyledata); odcmentitycolor = odpsplotstyledata.color(); bcolor = odcmentitycolor.isbycolor(); nred = odcmentitycolor.red(); ngreen = odcmentitycolor.green(); nblue = odcmentitycolor.blue(); ncolorindex = odcmentitycolor.colorindex(); assert(ncolorindex == 95); iindex = 2; odgicontextfordbdatabaseptr->plotstyle(iindex, odpsplotstyledata); odcmentitycolor = odpsplotstyledata.color(); bcolor = odcmentitycolor.isbycolor(); nred = odcmentitycolor.red(); ngreen = odcmentitycolor.green(); nblue = odcmentitycolor.blue(); assert(nred == 78); assert(ngreen == 188); assert(nblue == 83); ncolorindex = odcmentitycolor.colorindex(); } catch(...) { } } ... // register dwgdirect odinitialize(this); #ifndef _toolkit_in_dll_ odrx_init_static_module_map(); #endif badcolorinplotstyletable(); commandmacro::rxinit(); ... what is the solution ? first, you can draw (in autocad) simple dwg file using issued .ctb plotstyle file. then try to render it in odamfcapp. if odamfcapp draws colors correctly - you probably are doing something wrong (and the sample of correct way is odamfcapp :-) ). if odamfcapp draws colors incorrectly, you can rename issued .ctb file to .zip or .dwg and attach it to forum. sincerely yours, george udov here the ctb file. odamfcapp draws colors correctly, with this ctb file, but when we load it we have incorrect value return by odcmentitycolor.colorindex(). in my sample at index = 1 colorindex must be 95 or it return 97. index = 2 must return a true color with red = 78, green = 188 and blue = 83 but the value return by occmentitycolor is red = 82, green = 165 and blue = 82. i just want to know if there is something wrong with our code ? attached files (4.2 kb, 6 views) quote: originally posted by froggy in my sample at index = 1 colorindex must be 95 or it return 97. why color index must be 95? as i understand color 1 is "by color", so you can look up color index in device palette (if you need it); you shouldn't use member colorindex() here since it'll return color index in palette that is used for saving to pre-r15 file (this palette doesn't depend on background color, but palette that is used for rendering must depend on background color). quote: originally posted by froggy index = 2 must return a true color with red = 78, green = 188 and blue = 83 but the value return by occmentitycolor is red = 82, green = 165 and blue = 82. i reproduced this behaviour. thank you for information - we'll think about it. probably autocad in some cases (e. g. if two neighbour colors are close) post-processes information that is in .ctb file in some manner. we're return exactly that is saved in .ctb. sincerely yours, george udov thanks udov for your quick reply ! quote: why color index must be 95? it must be 95 because it's the color index we have selected with autodesk hardcopy plot style table editor when we have created this ctb file. not at all, froggy. in autodesk plotstyle editor (exploring file that you attached) for index=1 i see true color (63,127,63), not color index. dd returns same result. sincerely yours, george udov george, you are right ! there is a misunderstanding. we have created this ctb with autodesk plotstyle editor of autocad 2002 and the values we have selected were different with the values return by occmentitycolor, but if we open the same file with plotstyle editor of autocad 2005 the color values are the same as those returned by occmentitycolor (except for index 2 of my sample). now i know that the problem doesn't come from odcmentitycolor, maybe it comes from what autodesk save in the ctb. thank you, george, for answering my questions !! |
所有的时间均为北京时间。 现在的时间是 05:46 AM. |