This commit is contained in:
Ryan Oldenburg 2022-05-16 18:18:30 -05:00
parent 34fa05da97
commit 50090a8800

View file

@ -757,7 +757,7 @@ proc checkReset(state: var DecoderState) =
state.fillBitBuffer() state.fillBitBuffer()
if state.buffer[state.pos] == 0xFF.char: if state.buffer[state.pos] == 0xFF.char:
if state.buffer[state.pos+1] in {0xD0.char .. 0xD7.char}: if state.buffer[state.pos + 1] in {0xD0.char .. 0xD7.char}:
state.pos += 2 state.pos += 2
else: else:
failInvalid("did not get expected reset marker") failInvalid("did not get expected reset marker")
@ -892,15 +892,12 @@ proc buildImage(state: var DecoderState): Image =
cb.unsafe[x, y], cb.unsafe[x, y],
cr.unsafe[x, y], cr.unsafe[x, y],
) )
elif state.components.len == 1: elif state.components.len == 1:
let let
cy = state.components[0].channel cy = state.components[0].channel
for y in 0 ..< state.imageHeight: for y in 0 ..< state.imageHeight:
for x in 0 ..< state.imageWidth: for x in 0 ..< state.imageWidth:
result.unsafe[x, y] = grayScaleToRgbx( result.unsafe[x, y] = grayScaleToRgbx(cy.unsafe[x, y])
cy.unsafe[x, y],
)
else: else:
failInvalid() failInvalid()