Skip to content

Commit c9471a2

Browse files
committed
Fix COSPredictorDecode
1 parent a6e0f19 commit c9471a2

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/main/java/org/verapdf/cos/filters/COSPredictorDecode.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,21 +173,21 @@ public int read(byte[] buffer, int size) throws IOException {
173173
break;
174174
case 13: // Avg
175175
for (int i = 0; i < lineLength; i++) {
176-
byte value = currentLine[i];
177-
byte left = i - bytesPerChar >= 0 ?
178-
currentLine[i - bytesPerChar] : 0;
179-
byte up = previousLine[i];
176+
int value = currentLine[i] & 0xFF;
177+
int left = i - bytesPerChar >= 0 ?
178+
currentLine[i - bytesPerChar] & 0xFF : 0;
179+
int up = previousLine[i] & 0xFF;
180180
currentLine[i] = (byte) (value + (left + up) / 2);
181181
}
182182
break;
183183
case 14: // Paeth
184184
for (int i = 0; i < lineLength; i++) {
185-
byte value = currentLine[i];
186-
byte left = i - bytesPerChar >= 0 ?
187-
currentLine[i - bytesPerChar] : 0;
188-
byte up = previousLine[i];
189-
byte upLeft = i - bytesPerChar >= 0 ?
190-
previousLine[i - bytesPerChar] : 0;
185+
int value = currentLine[i] & 0xFF;
186+
int left = i - bytesPerChar >= 0 ?
187+
currentLine[i - bytesPerChar] & 0xFF : 0;
188+
int up = previousLine[i] & 0xFF;
189+
int upLeft = i - bytesPerChar >= 0 ?
190+
previousLine[i - bytesPerChar] & 0xFF : 0;
191191
int res = left + up - upLeft;
192192
int leftDiff = Math.abs(res - left);
193193
int upDiff = Math.abs(res - up);

0 commit comments

Comments
 (0)