@@ -333,23 +333,24 @@ public virtual int GetHeight() {
333
333
334
334
/// <summary>Sets the height of the barcode.</summary>
335
335
/// <remarks>
336
- /// 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.
337
- /// The allowed dimensions are (height, width):<p>
336
+ /// Sets the height of the barcode. If the height is zero it will be calculated.
337
+ /// This height doesn't include the whitespace border, if any.
338
+ /// The allowed dimensions are (width, height):<p>
338
339
/// 10, 10<br />
339
340
/// 12, 12<br />
340
- /// 8, 18 <br />
341
+ /// 18, 8 <br />
341
342
/// 14, 14<br />
342
- /// 8, 32 <br />
343
+ /// 32, 8 <br />
343
344
/// 16, 16<br />
344
- /// 12, 26 <br />
345
+ /// 26, 12 <br />
345
346
/// 18, 18<br />
346
347
/// 20, 20<br />
347
- /// 12, 36 <br />
348
+ /// 36, 12 <br />
348
349
/// 22, 22<br />
349
- /// 16, 36 <br />
350
+ /// 36, 16 <br />
350
351
/// 24, 24<br />
351
352
/// 26, 26<br />
352
- /// 16, 48 <br />
353
+ /// 48, 16 <br />
353
354
/// 32, 32<br />
354
355
/// 36, 36<br />
355
356
/// 40, 40<br />
@@ -383,23 +384,24 @@ public virtual int GetWidth() {
383
384
384
385
/// <summary>Sets the width of the barcode.</summary>
385
386
/// <remarks>
386
- /// 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.
387
- /// The allowed dimensions are (height, width):<p>
387
+ /// Sets the width of the barcode. If the width is zero it will be calculated.
388
+ /// This width doesn't include the whitespace border, if any.
389
+ /// The allowed dimensions are (width, height):<p>
388
390
/// 10, 10<br />
389
391
/// 12, 12<br />
390
- /// 8, 18 <br />
392
+ /// 18, 8 <br />
391
393
/// 14, 14<br />
392
- /// 8, 32 <br />
394
+ /// 32, 8 <br />
393
395
/// 16, 16<br />
394
- /// 12, 26 <br />
396
+ /// 26, 12 <br />
395
397
/// 18, 18<br />
396
398
/// 20, 20<br />
397
- /// 12, 36 <br />
399
+ /// 36, 12 <br />
398
400
/// 22, 22<br />
399
- /// 16, 36 <br />
401
+ /// 36, 16 <br />
400
402
/// 24, 24<br />
401
403
/// 26, 26<br />
402
- /// 16, 48 <br />
404
+ /// 48, 16 <br />
403
405
/// 32, 32<br />
404
406
/// 36, 36<br />
405
407
/// 40, 40<br />
@@ -1117,7 +1119,7 @@ private int C40OrTextEncodation(byte[] text, int textOffset, int textLength, byt
1117
1119
dataOffsetNew = requiredCapacityForASCII ;
1118
1120
}
1119
1121
}
1120
- addLatch = unlatch < 0 ? true : ( dataOffset - requiredCapacityForASCII != unlatch ) ;
1122
+ addLatch = ( unlatch < 0 ) || ( ( dataOffset - requiredCapacityForASCII ) != unlatch ) ;
1121
1123
if ( requiredCapacityForC40orText % 3 == 0 && requiredCapacityForC40orText / 3 * 2 + ( addLatch ? 2 : 0 ) < requiredCapacityForASCII
1122
1124
) {
1123
1125
usingASCII = false ;
@@ -1138,17 +1140,15 @@ private int C40OrTextEncodation(byte[] text, int textOffset, int textLength, byt
1138
1140
usingASCII = true ;
1139
1141
}
1140
1142
}
1143
+ if ( dataOffset < 0 ) {
1144
+ return - 1 ;
1145
+ }
1141
1146
if ( usingASCII ) {
1142
1147
return AsciiEncodation ( text , textOffset , 1 , data , dataOffset , dataLength , prevEnc == mode ? 1 : - 1 , DM_ASCII
1143
1148
, origDataOffset ) ;
1144
1149
}
1145
1150
if ( addLatch ) {
1146
- if ( c40 ) {
1147
- data [ dataOffset + ptrOut ++ ] = LATCH_C40 ;
1148
- }
1149
- else {
1150
- data [ dataOffset + ptrOut ++ ] = LATCH_TEXT ;
1151
- }
1151
+ data [ dataOffset + ptrOut ++ ] = c40 ? LATCH_C40 : LATCH_TEXT ;
1152
1152
}
1153
1153
int [ ] enc = new int [ textLength * 4 + 10 ] ;
1154
1154
encPtr = 0 ;
0 commit comments