You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I guess the write function is bugged if you have exactly 255 zero to write, and then the next state the 256th character is a 1 (or vice versa, i.e. if you switch state after exactly 255 count).
The fix is easy: in the else of the "if c==state", add another test before dumping, the test should be: "if ctr > 0:", otherwise you will write a state with zero count, and actually may shift the whole data.
The whole code becomes:
for c in voxels_flat:
if c==state:
ctr += 1
# if ctr hits max, dump
if ctr==255:
fp.write(chr(state))
fp.write(chr(ctr))
ctr = 0
else:
# if switch state, dump
if ctr > 0:
fp.write(chr(state))
fp.write(chr(ctr))
state = c
ctr = 1
The text was updated successfully, but these errors were encountered:
I guess the write function is bugged if you have exactly 255 zero to write, and then the next state the 256th character is a 1 (or vice versa, i.e. if you switch state after exactly 255 count).
The fix is easy: in the else of the "if c==state", add another test before dumping, the test should be: "if ctr > 0:", otherwise you will write a state with zero count, and actually may shift the whole data.
The whole code becomes:
The text was updated successfully, but these errors were encountered: