Skip to content

Commit

Permalink
Merge pull request #20 from ngageoint/develop
Browse files Browse the repository at this point in the history
release 2.0.0
  • Loading branch information
bosborn authored Nov 20, 2017
2 parents 42c9052 + ed304e7 commit 79ab1c2
Show file tree
Hide file tree
Showing 13 changed files with 939 additions and 305 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
/target/

# IntelliJ
.idea
*.iml
12 changes: 9 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ Adheres to [Semantic Versioning](http://semver.org/).

---

## 1.0.4 (TBD)

* TBD
## [2.0.0](https://github.com/ngageoint/geopackage-tiff-java/releases/tag/2.0.0) (11-20-2017)

* Rasters modified to use buffers in place of arrays
* Deflate compression support
* Additional Rasters constructor options
* Handle missing samples per pixel with default value of 1
* Public access to tiff tags
* String Entry Value getter and setter
* maven-gpg-plugin version 1.6

## [1.0.3](https://github.com/ngageoint/geopackage-tiff-java/releases/tag/1.0.3) (06-27-2017)

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ TIFFImage tiffImage = TiffReader.readTiff(input);
List<FileDirectory> directories = tiffImage.getFileDirectories();
FileDirectory directory = directories.get(0);
Rasters rasters = directory.readRasters();

```

#### Write ####
Expand Down Expand Up @@ -76,12 +76,12 @@ TiffWriter.writeTiff(file, tiffImage);

### Installation ###

Pull from the [Maven Central Repository](http://search.maven.org/#artifactdetails|mil.nga|tiff|1.0.3|jar) (JAR, POM, Source, Javadoc)
Pull from the [Maven Central Repository](http://search.maven.org/#artifactdetails|mil.nga|tiff|2.0.0|jar) (JAR, POM, Source, Javadoc)

<dependency>
<groupId>mil.nga</groupId>
<artifactId>tiff</artifactId>
<version>1.0.3</version>
<version>2.0.0</version>
</dependency>

### Build ###
Expand Down
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>mil.nga</groupId>
<artifactId>tiff</artifactId>
<version>1.0.4</version>
<version>2.0.0</version>
<packaging>jar</packaging>
<name>Tagged Image File Format</name>
<url>https://github.com/ngageoint/geopackage-tiff-java</url>
Expand Down Expand Up @@ -84,6 +84,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
Expand Down
110 changes: 110 additions & 0 deletions src/main/java/mil/nga/tiff/FieldType.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package mil.nga.tiff;

import mil.nga.tiff.util.TiffConstants;
import mil.nga.tiff.util.TiffException;

/**
* Field Types
*
Expand Down Expand Up @@ -104,6 +107,16 @@ public int getBytes() {
return bytes;
}

/**
* Get the number of bits per value
*
* @return number of bits
* @since 2.0.0
*/
public int getBits() {
return bytes * 8;
}

/**
* Get the field type
*
Expand All @@ -115,4 +128,101 @@ public static FieldType getFieldType(int fieldType) {
return FieldType.values()[fieldType - 1];
}

/**
* Get the field type of the sample format and bits per sample
*
* @param sampleFormat
* sample format
* @param bitsPerSample
* bits per sample
* @return field type
* @since 2.0.0
*/
public static FieldType getFieldType(int sampleFormat, int bitsPerSample) {

FieldType fieldType = null;

switch (sampleFormat) {
case TiffConstants.SAMPLE_FORMAT_UNSIGNED_INT:
switch (bitsPerSample) {
case 8:
fieldType = FieldType.BYTE;
break;
case 16:
fieldType = FieldType.SHORT;
break;
case 32:
fieldType = FieldType.LONG;
break;
}
break;
case TiffConstants.SAMPLE_FORMAT_SIGNED_INT:
switch (bitsPerSample) {
case 8:
fieldType = FieldType.SBYTE;
break;
case 16:
fieldType = FieldType.SSHORT;
break;
case 32:
fieldType = FieldType.SLONG;
break;
}
break;
case TiffConstants.SAMPLE_FORMAT_FLOAT:
switch (bitsPerSample) {
case 32:
fieldType = FieldType.FLOAT;
break;
case 64:
fieldType = FieldType.DOUBLE;
break;
}
break;
}

if (fieldType == null) {
throw new TiffException(
"Unsupported field type for sample format: " + sampleFormat
+ ", bits per sample: " + bitsPerSample);
}

return fieldType;
}

/**
* Get the sample format of the field type
*
* @param fieldType
* field type
* @return sample format
* @since 2.0.0
*/
public static int getSampleFormat(FieldType fieldType) {

int sampleFormat;

switch (fieldType) {
case BYTE:
case SHORT:
case LONG:
sampleFormat = TiffConstants.SAMPLE_FORMAT_UNSIGNED_INT;
break;
case SBYTE:
case SSHORT:
case SLONG:
sampleFormat = TiffConstants.SAMPLE_FORMAT_SIGNED_INT;
break;
case FLOAT:
case DOUBLE:
sampleFormat = TiffConstants.SAMPLE_FORMAT_FLOAT;
break;
default:
throw new TiffException(
"Unsupported sample format for field type: " + fieldType);
}

return sampleFormat;
}

}
Loading

0 comments on commit 79ab1c2

Please sign in to comment.