diff --git a/src/drw_entities.cpp b/src/drw_entities.cpp index 05469ad..a012874 100644 --- a/src/drw_entities.cpp +++ b/src/drw_entities.cpp @@ -97,6 +97,9 @@ bool DRW_Entity::parseCode(int code, dxfReader *reader){ case 430: colorName = reader->getString(); break; + case 440: + transparency = reader->getInt32(); + break; case 67: space = static_cast(reader->getInt32()); break; @@ -316,7 +319,7 @@ bool DRW_Entity::parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer* strBu DRW_DBG(", haveNextLinks (forced): "); DRW_DBG(haveNextLinks); DRW_DBG("\n"); } //ENC color - color = buf->getEnColor(version); //BS or CMC //ok for R14 or negate + color = buf->getEnColor( version, color24, transparency ); //BS or CMC //OK for R14 or negate ltypeScale = buf->getBitDouble(); //BD DRW_DBG(" entity color: "); DRW_DBG(color); DRW_DBG(" ltScale: "); DRW_DBG(ltypeScale); DRW_DBG("\n"); @@ -2961,7 +2964,7 @@ bool DRW_Viewport::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){ DRW_DBG("Brightness: "); DRW_DBG(buf->getBitDouble()); DRW_DBG("\n"); DRW_DBG("Contrast: "); DRW_DBG(buf->getBitDouble()); DRW_DBG("\n"); // DRW_DBG("Ambient Cmc or Enc: "); DRW_DBG(buf->getCmColor(version)); DRW_DBG("\n"); - DRW_DBG("Ambient (Cmc or Enc?), Enc: "); DRW_DBG(buf->getEnColor(version)); DRW_DBG("\n"); + DRW_DBG("Ambient (Cmc or Enc?), Enc: "); DRW_DBG(buf->getEnColor(version, color24, transparency)); DRW_DBG("\n"); } ret = DRW_Entity::parseDwgEntHandle(version, buf); diff --git a/src/intern/dwgbuffer.cpp b/src/intern/dwgbuffer.cpp index ad12d5f..7f2bb7e 100644 --- a/src/intern/dwgbuffer.cpp +++ b/src/intern/dwgbuffer.cpp @@ -787,36 +787,32 @@ duint32 dwgBuffer::getCmColor(DRW::Version v) { * For R2004+, can be CMC or ENC * RGB value, first 4bits 0xC0 => ByLayer, 0xC1 => ByBlock, 0xC2 => RGB, 0xC3 => last 4 are ACIS */ -duint32 dwgBuffer::getEnColor(DRW::Version v) { +duint32 dwgBuffer::getEnColor(DRW::Version v, int &rgb, int &transparency ) { if (v < DRW::AC1018) //2000- return getSBitShort(); - duint32 rgb = 0; - duint32 cb = 0; + rgb = -1; + transparency = 0; duint16 idx = getBitShort(); DRW_DBG("idx reads COLOR: "); DRW_DBGH(idx); duint16 flags = idx>>8; idx = idx & 0x1FF; //RLZ: warning this is correct? - DRW_DBG("\nflag COLOR: "); DRW_DBGH(flags); - DRW_DBG(", index COLOR: "); DRW_DBGH(idx); -// if (flags & 0x80) { -// rgb = getBitLong(); -// DRW_DBG("\nRGB COLOR: "); DRW_DBGH(rgb); -// } - if (flags & 0x20) { - cb = getBitLong(); - DRW_DBG("\nTransparency COLOR: "); DRW_DBGH(cb); - } - if (flags & 0x40) - DRW_DBG("\nacdbColor COLOR are present"); - else { - if (flags & 0x80) { - rgb = getBitLong(); - DRW_DBG("\nRGB COLOR: "); DRW_DBGH(rgb); - } + DRW_DBG( "flag COLOR:" ); DRW_DBGH( flags ); DRW_DBG( ", index COLOR:" ); DRW_DBGH( idx ); DRW_DBG( "\n" ); + if ( flags & 0x80 ) + { + // complex color (rgb) + rgb = getBitLong() & 0xffffff; + + DRW_DBG( "RGB COLOR:" ); DRW_DBGH( rgb ); DRW_DBG( "\n" ); + if ( flags & 0x40 ) + { + DRW_DBG( "acdbColor COLOR are present\n" ); + } } -/* if (flags & 0x80) - return getBitLong();*/ + if (flags & 0x20) { + transparency = getBitLong(); + DRW_DBG( "Transparency COLOR:" ); DRW_DBGH( transparency ); DRW_DBG( "\n" ); + } return idx; //default return ByLayer } diff --git a/src/intern/dwgbuffer.h b/src/intern/dwgbuffer.h index 9627644..163d67e 100644 --- a/src/intern/dwgbuffer.h +++ b/src/intern/dwgbuffer.h @@ -125,7 +125,7 @@ class dwgBuffer { double getThickness(bool b_R2000_style);//BT //3DD duint32 getCmColor(DRW::Version v); //CMC - duint32 getEnColor(DRW::Version v); //ENC + duint32 getEnColor( DRW::Version v, int &rgb, int &transparency ); //ENC //TC duint16 getBERawShort16(); //RS big-endian order