You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ch...@apache.org on 2017/05/24 18:41:10 UTC
[22/50] [abbrv] commons-imaging git commit: Use try with resources.
Use try with resources.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/imaging/trunk@1775928 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-imaging/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-imaging/commit/20515734
Tree: http://git-wip-us.apache.org/repos/asf/commons-imaging/tree/20515734
Diff: http://git-wip-us.apache.org/repos/asf/commons-imaging/diff/20515734
Branch: refs/heads/master
Commit: 20515734fb4a2567afc6fc8a8a39257e69b4aab8
Parents: 3ec9067
Author: Gary D. Gregory <gg...@apache.org>
Authored: Fri Dec 23 23:23:07 2016 +0000
Committer: Gary D. Gregory <gg...@apache.org>
Committed: Fri Dec 23 23:23:07 2016 +0000
----------------------------------------------------------------------
.../tiff/datareaders/DataReaderTiled.java | 48 ++++++++++----------
1 file changed, 24 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/20515734/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java b/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java
index 9864e06..91ca4c5 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java
@@ -115,40 +115,40 @@ public final class DataReaderTiled extends ImageDataReader {
// End of May 2012 changes
- final BitInputStream bis = new BitInputStream(new ByteArrayInputStream(bytes), byteOrder);
+ try (final BitInputStream bis = new BitInputStream(new ByteArrayInputStream(bytes), byteOrder)) {
- final int pixelsPerTile = tileWidth * tileLength;
+ final int pixelsPerTile = tileWidth * tileLength;
- int tileX = 0;
- int tileY = 0;
+ int tileX = 0;
+ int tileY = 0;
- int[] samples = new int[bitsPerSampleLength];
- resetPredictor();
- for (int i = 0; i < pixelsPerTile; i++) {
+ int[] samples = new int[bitsPerSampleLength];
+ resetPredictor();
+ for (int i = 0; i < pixelsPerTile; i++) {
- final int x = tileX + startX;
- final int y = tileY + startY;
+ final int x = tileX + startX;
+ final int y = tileY + startY;
- getSamplesAsBytes(bis, samples);
+ getSamplesAsBytes(bis, samples);
- if ((x < xLimit) && (y < yLimit)) {
- samples = applyPredictor(samples);
- photometricInterpreter.interpretPixel(imageBuilder, samples, x,
- y);
- }
+ if ((x < xLimit) && (y < yLimit)) {
+ samples = applyPredictor(samples);
+ photometricInterpreter.interpretPixel(imageBuilder, samples, x, y);
+ }
- tileX++;
+ tileX++;
- if (tileX >= tileWidth) {
- tileX = 0;
- resetPredictor();
- tileY++;
- bis.flushCache();
- if (tileY >= tileLength) {
- break;
+ if (tileX >= tileWidth) {
+ tileX = 0;
+ resetPredictor();
+ tileY++;
+ bis.flushCache();
+ if (tileY >= tileLength) {
+ break;
+ }
}
- }
+ }
}
}