@@ -383,8 +383,8 @@ class TiffImage {
383
383
throw ImageException ('Unsupported Compression Type: $compression ' );
384
384
}
385
385
386
- for (var y = 0 , py = outY; y < tileHeight && py < height ; ++ y, ++ py) {
387
- for (var x = 0 , px = outX; x < tileWidth && px < width ; ++ x, ++ px) {
386
+ for (var y = 0 , py = outY; y < tileHeight; ++ y, ++ py) {
387
+ for (var x = 0 , px = outX; x < tileWidth; ++ x, ++ px) {
388
388
if (samplesPerPixel == 1 ) {
389
389
if (sampleFormat == TiffFormat .float) {
390
390
num sample = 0 ;
@@ -395,7 +395,9 @@ class TiffImage {
395
395
} else if (bitsPerSample == 16 ) {
396
396
sample = Float16 .float16ToDouble (byteData.readUint16 ());
397
397
}
398
- image.setPixelR (px, py, sample);
398
+ if (px < width && py < height) {
399
+ image.setPixelR (px, py, sample);
400
+ }
399
401
} else {
400
402
var sample = 0 ;
401
403
if (bitsPerSample == 8 ) {
@@ -417,7 +419,9 @@ class TiffImage {
417
419
sample = mx - sample;
418
420
}
419
421
420
- image.setPixelR (px, py, sample);
422
+ if (px < width && py < height) {
423
+ image.setPixelR (px, py, sample);
424
+ }
421
425
}
422
426
} else if (samplesPerPixel == 2 ) {
423
427
var gray = 0 ;
@@ -445,7 +449,9 @@ class TiffImage {
445
449
: byteData.readUint32 ();
446
450
}
447
451
448
- image.setPixelRgb (px, py, gray, alpha, 0 );
452
+ if (px < width && py < height) {
453
+ image.setPixelRgb (px, py, gray, alpha, 0 );
454
+ }
449
455
} else if (samplesPerPixel == 3 ) {
450
456
if (sampleFormat == TiffFormat .float) {
451
457
var r = 0.0 ;
@@ -464,7 +470,9 @@ class TiffImage {
464
470
g = Float16 .float16ToDouble (byteData.readUint16 ());
465
471
b = Float16 .float16ToDouble (byteData.readUint16 ());
466
472
}
467
- image.setPixelRgb (px, py, r, g, b);
473
+ if (px < width && py < height) {
474
+ image.setPixelRgb (px, py, r, g, b);
475
+ }
468
476
} else {
469
477
var r = 0 ;
470
478
var g = 0 ;
@@ -501,7 +509,9 @@ class TiffImage {
501
509
: byteData.readUint32 ();
502
510
}
503
511
504
- image.setPixelRgb (px, py, r, g, b);
512
+ if (px < width && py < height) {
513
+ image.setPixelRgb (px, py, r, g, b);
514
+ }
505
515
}
506
516
} else if (samplesPerPixel >= 4 ) {
507
517
if (sampleFormat == TiffFormat .float) {
@@ -525,7 +535,9 @@ class TiffImage {
525
535
b = Float16 .float16ToDouble (byteData.readUint16 ());
526
536
a = Float16 .float16ToDouble (byteData.readUint16 ());
527
537
}
528
- image.setPixelRgba (px, py, r, g, b, a);
538
+ if (px < width && py < height) {
539
+ image.setPixelRgba (px, py, r, g, b, a);
540
+ }
529
541
} else {
530
542
var r = 0 ;
531
543
var g = 0 ;
@@ -580,7 +592,9 @@ class TiffImage {
580
592
a = image.maxChannelValue as int ;
581
593
}
582
594
583
- image.setPixelRgba (px, py, r, g, b, a);
595
+ if (px < width && py < height) {
596
+ image.setPixelRgba (px, py, r, g, b, a);
597
+ }
584
598
}
585
599
}
586
600
}
0 commit comments