@@ -402,24 +402,25 @@ public int getHeight() {
402
402
}
403
403
404
404
/**
405
- * Sets the height of the barcode. If the height is zero it will be calculated. This height doesn't include the whitespace border, if any.
405
+ * Sets the height of the barcode. If the height is zero it will be calculated.
406
+ * This height doesn't include the whitespace border, if any.
406
407
*
407
- * The allowed dimensions are (height, width ):<p>
408
+ * The allowed dimensions are (width, height ):<p>
408
409
* 10, 10<br>
409
410
* 12, 12<br>
410
- * 8, 18 <br>
411
+ * 18, 8 <br>
411
412
* 14, 14<br>
412
- * 8, 32 <br>
413
+ * 32, 8 <br>
413
414
* 16, 16<br>
414
- * 12, 26 <br>
415
+ * 26, 12 <br>
415
416
* 18, 18<br>
416
417
* 20, 20<br>
417
- * 12, 36 <br>
418
+ * 36, 12 <br>
418
419
* 22, 22<br>
419
- * 16, 36 <br>
420
+ * 36, 16 <br>
420
421
* 24, 24<br>
421
422
* 26, 26<br>
422
- * 16, 48 <br>
423
+ * 48, 16 <br>
423
424
* 32, 32<br>
424
425
* 36, 36<br>
425
426
* 40, 40<br>
@@ -453,24 +454,25 @@ public int getWidth() {
453
454
}
454
455
455
456
/**
456
- * Sets the width of the barcode. If the width is zero it will be calculated. This width doesn't include the whitespace border, if any.
457
+ * Sets the width of the barcode. If the width is zero it will be calculated.
458
+ * This width doesn't include the whitespace border, if any.
457
459
*
458
- * The allowed dimensions are (height, width ):<p>
460
+ * The allowed dimensions are (width, height ):<p>
459
461
* 10, 10<br>
460
462
* 12, 12<br>
461
- * 8, 18 <br>
463
+ * 18, 8 <br>
462
464
* 14, 14<br>
463
- * 8, 32 <br>
465
+ * 32, 8 <br>
464
466
* 16, 16<br>
465
- * 12, 26 <br>
467
+ * 26, 12 <br>
466
468
* 18, 18<br>
467
469
* 20, 20<br>
468
- * 12, 36 <br>
470
+ * 36, 12 <br>
469
471
* 22, 22<br>
470
- * 16, 36 <br>
472
+ * 36, 16 <br>
471
473
* 24, 24<br>
472
474
* 26, 26<br>
473
- * 16, 48 <br>
475
+ * 48, 16 <br>
474
476
* 32, 32<br>
475
477
* 36, 36<br>
476
478
* 40, 40<br>
@@ -1072,7 +1074,7 @@ private int C40OrTextEncodation(byte[] text, int textOffset, int textLength, byt
1072
1074
if (j == 1 )
1073
1075
dataOffsetNew = requiredCapacityForASCII ;
1074
1076
}
1075
- addLatch = unlatch < 0 ? true : ( dataOffset - requiredCapacityForASCII != unlatch );
1077
+ addLatch = ( unlatch < 0 ) || (( dataOffset - requiredCapacityForASCII ) != unlatch );
1076
1078
if (requiredCapacityForC40orText % 3 == 0 &&
1077
1079
requiredCapacityForC40orText / 3 * 2 + (addLatch ? 2 : 0 ) < requiredCapacityForASCII ) {
1078
1080
usingASCII = false ;
@@ -1086,15 +1088,17 @@ private int C40OrTextEncodation(byte[] text, int textOffset, int textLength, byt
1086
1088
i --;
1087
1089
}
1088
1090
}
1089
- } else if (symbolIndex != -1 )
1091
+ } else if (symbolIndex != -1 ) {
1090
1092
usingASCII = true ;
1091
- if (usingASCII )
1093
+ }
1094
+ if (dataOffset < 0 ) {
1095
+ return -1 ;
1096
+ }
1097
+ if (usingASCII ) {
1092
1098
return asciiEncodation (text , textOffset , 1 , data , dataOffset , dataLength , prevEnc == mode ? 1 : -1 , DM_ASCII , origDataOffset );
1099
+ }
1093
1100
if (addLatch ) {
1094
- if (c40 )
1095
- data [dataOffset + ptrOut ++] = LATCH_C40 ;
1096
- else
1097
- data [dataOffset + ptrOut ++] = LATCH_TEXT ;
1101
+ data [dataOffset + ptrOut ++] = c40 ? LATCH_C40 : LATCH_TEXT ;
1098
1102
}
1099
1103
int [] enc = new int [textLength * 4 + 10 ];
1100
1104
encPtr = 0 ;
@@ -1396,5 +1400,4 @@ else if (eci < 16383) {
1396
1400
}
1397
1401
return -1 ;
1398
1402
}
1399
-
1400
1403
}
0 commit comments