Open jupeu opened 2 years ago
I got the exact same error with many CGM files. Below is the code from cgm_const file from where exception is thrown.
def create_color_table(sz):
mx = 1
bs = 0
while mx < sz: # >> line 423
mx = mx * 2
bs = bs + 1
cb = bs / 3
tb = bs % 3
mc = (1 << (cb + tb)) - 1.0
table = mx * [(0.0, 0.0, 0.0)]
for i in range(mx):
j = i + mx - 1
j = j % mx
red, grn, blu = 0, 0, 0
for k in range(cb):
red = (red << 1) + j % 2
j = j >> 1
grn = (grn << 1) + j % 2
j = j >> 1
blu = (blu << 1) + j % 2
j = j >> 1
tint = j
red = (red << tb) + tint
grn = (grn << tb) + tint
blu = (blu << tb) + tint
table[i] = (red / mc, grn / mc, blu / mc) # >> line 445
return table
When sz is 1, mc gets calculated to be 0. CGM files I use have " maxcolrindex 1;" command. The one @jupeu attached also has it. I guess this can be fixed easily by changing the while loop's condition at line #423 to a "<=" comparison so mc is set to 1 in the erroneous case.
UniConvertor 2.0rc5 build 20210831 fails to convert the attached .CGM file:
The file uc2.log contents:
EW02Y.zip