Skip to content

Commit bbc14f4

Browse files
committed
Row boundary on decode
1 parent 53fc42d commit bbc14f4

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

src/ImageSharp/Formats/Pbm/BinaryDecoder.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ private static void ProcessBlackAndWhite<TPixel>(Configuration configuration, Bu
152152
{
153153
int width = pixels.Width;
154154
int height = pixels.Height;
155-
int startBit = 0;
156155
MemoryAllocator allocator = configuration.MemoryAllocator;
157156
using IMemoryOwner<L8> row = allocator.Allocate<L8>(width);
158157
Span<L8> rowSpan = row.GetSpan();
@@ -162,23 +161,11 @@ private static void ProcessBlackAndWhite<TPixel>(Configuration configuration, Bu
162161
for (int x = 0; x < width;)
163162
{
164163
int raw = stream.ReadByte();
165-
int bit = startBit;
166-
startBit = 0;
167-
for (; bit < 8; bit++)
164+
for (int bit = 0; bit < 8; bit++)
168165
{
169166
bool bitValue = (raw & (0x80 >> bit)) != 0;
170167
rowSpan[x] = bitValue ? black : white;
171168
x++;
172-
if (x == width)
173-
{
174-
startBit = (bit + 1) & 7; // Round off to below 8.
175-
if (startBit != 0)
176-
{
177-
stream.Seek(-1, System.IO.SeekOrigin.Current);
178-
}
179-
180-
break;
181-
}
182169
}
183170
}
184171

0 commit comments

Comments
 (0)