In https://github.com/LibreDWG/libredwg/issues/346 is discussed issue:
```
1206,1207c1206
<             "index": 256,
<             "rgb": "c3000007"
---
>             "rgb": "c0000000"
```

There is the conversion of fill_color (CMC) defined by (AC1015):
```
rowstyles[rcount1].fill_color.index: 256 [CMC.BS 63]
rowstyles[rcount1].fill_color.rgb: 0xc3000007 [CMC.BL 421]
fill_color.method: 0xc3 Truecolor
rowstyles[rcount1].fill_color.flag: 0x0 [CMC.RC]
```
to JSON, where is:
```
          "fill_color": {
            "index": 256,
            "rgb": "c3000007"
          },
```
This means that rgb color doesn't exist in index table → index=256
See:
```
bit_read_CMC()
{
...
color->index = dwg_find_color_index (color->rgb);
...
}
```
and
```
EXPORT BITCODE_BS
dwg_find_color_index (BITCODE_BL rgb)
{       
  Dwg_RGB_Palette pal;
  rgb &= 0x00ffffff;
  pal.r = (rgb >> 16) & 0xFF;
  pal.g = (rgb >> 8) & 0xFF; 
  pal.b = rgb & 0xFF;
  // linear search is good enough for 256. the palette is unsorted.
  for (BITCODE_BS i = 0; i < 256; i++)
    {     
      if (memcmp (&pal, &rgb_palette[i], 3) == 0)
        return i;
    }   
  return 256;
}
```

When I am converting this JSON back to DWG, result will be:
```
rowstyles[rcount1].text_color.flag: 0x0 [CMC.RC]
rowstyles[rcount1].fill_color.index: 0 [CMC.BS 63]
rowstyles[rcount1].fill_color.rgb: 0xc0000000 [CMC.BL 421]
fill_color.method: 0xc0 ByLayer
rowstyles[rcount1].fill_color.flag: 0x0 [CMC.RC]
```
The problem with this is, that was called:
```
      if (dat->from_version >= R_2004)
        bit_downconvert_CMC (dat, color);
```
in bit_write_CMC().
DWG to JSON (and back) and CMC issue
This is a GitHub Issue
repo:libredwg
owner:LibreDWG
Title : DWG to JSON (and back) and CMC issue
Issue date:

--- start body ---
In https://github.com/LibreDWG/libredwg/issues/346 is discussed issue:
```
1206,1207c1206
<             "index": 256,
<             "rgb": "c3000007"
---
>             "rgb": "c0000000"
```

There is the conversion of fill_color (CMC) defined by (AC1015):
```
rowstyles[rcount1].fill_color.index: 256 [CMC.BS 63]
rowstyles[rcount1].fill_color.rgb: 0xc3000007 [CMC.BL 421]
fill_color.method: 0xc3 Truecolor
rowstyles[rcount1].fill_color.flag: 0x0 [CMC.RC]
```
to JSON, where is:
```
          "fill_color": {
            "index": 256,
            "rgb": "c3000007"
          },
```
This means that rgb color doesn't exist in index table → index=256
See:
```
bit_read_CMC()
{
...
color->index = dwg_find_color_index (color->rgb);
...
}
```
and
```
EXPORT BITCODE_BS
dwg_find_color_index (BITCODE_BL rgb)
{       
  Dwg_RGB_Palette pal;
  rgb &= 0x00ffffff;
  pal.r = (rgb >> 16) & 0xFF;
  pal.g = (rgb >> 8) & 0xFF; 
  pal.b = rgb & 0xFF;
  // linear search is good enough for 256. the palette is unsorted.
  for (BITCODE_BS i = 0; i < 256; i++)
    {     
      if (memcmp (&pal, &rgb_palette[i], 3) == 0)
        return i;
    }   
  return 256;
}
```

When I am converting this JSON back to DWG, result will be:
```
rowstyles[rcount1].text_color.flag: 0x0 [CMC.RC]
rowstyles[rcount1].fill_color.index: 0 [CMC.BS 63]
rowstyles[rcount1].fill_color.rgb: 0xc0000000 [CMC.BL 421]
fill_color.method: 0xc0 ByLayer
rowstyles[rcount1].fill_color.flag: 0x0 [CMC.RC]
```
The problem with this is, that was called:
```
      if (dat->from_version >= R_2004)
        bit_downconvert_CMC (dat, color);
```
in bit_write_CMC().
--- end body ---
