Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
language: java
jdk:
- oraclejdk8
- oraclejdk9
- openjdk7
- openjdk8
- oraclejdk11
- openjdk11
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -172,7 +172,7 @@
</execution>
</executions>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
<doclint>none</doclint>
<linksource>true</linksource>
<protected>true</protected>
<links>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public static void main(String[] args) {
*
* <p>An instance of <code>IndexColorModel</code> will be created for
* instances of <code>MultiPixelPackedSampleModel</code>. The colormap
* will be a grayscale ramp with <code>1&nbsp;<<&nbsp;numberOfBits</code>
* will be a grayscale ramp with <code>1&nbsp;&lt;&lt;&nbsp;numberOfBits</code>
* entries ranging from zero to at most 255.</p>
*
* @return An instance of <code>ColorModel</code> that is suitable for
Expand Down Expand Up @@ -1057,8 +1057,8 @@ public static long getBandSize(SampleModel sm) {
/**
* Tests whether the color indices represent a gray-scale image with
* the indicated number of bits over the color component range [0,255].
* The grayscale mapping may be inverted, i.e., 0 -> 255 and
* mapSize -> 0.
* The grayscale mapping may be inverted, i.e., 0 -&gt; 255 and
* mapSize -&gt; 0.
*
* @param icm The gray-to-color mapping.
* @return Whether the <code>IndexColorModel</code> maps index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public class TIFFImageWriter extends ImageWriter {
* relative to a given tile grid layout specified by its X offset
* and tile width.
*
* <p> If <code>tileWidth < 0</code>, the results of this method
* <p> If <code>tileWidth &lt; 0</code>, the results of this method
* are undefined. If <code>tileWidth == 0</code>, an
* <code>ArithmeticException</code> will be thrown.
*
Expand All @@ -259,7 +259,7 @@ public static int XToTileX(int x, int tileGridXOffset, int tileWidth) {
* relative to a given tile grid layout specified by its Y offset
* and tile height.
*
* <p> If <code>tileHeight < 0</code>, the results of this method
* <p> If <code>tileHeight &lt; 0</code>, the results of this method
* are undefined. If <code>tileHeight == 0</code>, an
* <code>ArithmeticException</code> will be thrown.
*
Expand Down Expand Up @@ -1717,7 +1717,8 @@ private int writeTile(Rectangle tileRect, TIFFCompressor compressor)
SampleModel sm = image.getSampleModel();

// Read only data from the active rectangle.
Raster raster = image.getData(activeRect);
Raster raster = image instanceof BufferedImage ? ((BufferedImage) image).getRaster()
: image.getData(activeRect);

// If padding is required, create a larger Raster and fill
// it from the active rectangle.
Expand Down Expand Up @@ -1780,14 +1781,11 @@ private int writeTile(Rectangle tileRect, TIFFCompressor compressor)
return compressor.encode(buf, 0,
width, height, sampleSize,
(tileRect.width + 7)/8);
} else if(bitDepth == 8 &&
sm.getDataType() == DataBuffer.TYPE_BYTE) {
} else if(bitDepth == DataBuffer.getDataTypeSize(sm.getDataType())) {

ComponentSampleModel csm =
(ComponentSampleModel)raster.getSampleModel();

byte[] buf =
((DataBufferByte)raster.getDataBuffer()).getData();

int off =
csm.getOffset(minX -
raster.getSampleModelTranslateX(),
Expand All @@ -1798,7 +1796,7 @@ private int writeTile(Rectangle tileRect, TIFFCompressor compressor)
System.out.println("Optimized component case");
}

return compressor.encode(buf, off,
return compressor.encode(raster.getDataBuffer(), off,
width, height, sampleSize,
csm.getScanlineStride());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@
* <p><table border=1>
* <caption><b>Compression Types</b></caption>
* <tr><th>Type String</th> <th>Description</th> <th>Image Types</th></tr>
* <tr><td>BI_RGB</td> <td>Uncompressed RLE</td> <td><= 8-bits/sample</td></tr>
* <tr><td>BI_RLE8</td> <td>8-bit Run Length Encoding</td> <td><= 8-bits/sample</td></tr>
* <tr><td>BI_RLE4</td> <td>4-bit Run Length Encoding</td> <td><= 4-bits/sample</td></tr>
* <tr><td>BI_RGB</td> <td>Uncompressed RLE</td> <td>&lt;= 8-bits/sample</td></tr>
* <tr><td>BI_RLE8</td> <td>8-bit Run Length Encoding</td> <td>&lt;= 8-bits/sample</td></tr>
* <tr><td>BI_RLE4</td> <td>4-bit Run Length Encoding</td> <td>&lt;= 4-bits/sample</td></tr>
* <tr><td>BI_BITFIELDS</td> <td>Packed data</td> <td> 16 or 32 bits/sample</td></tr>
* <tr><td>BI_JPEG</td> <td>JPEG encoded</td> <td>grayscale or RGB image</td></tr>
* </table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class GeoTIFFTagSet extends TIFFTagSet {
*/
public static final int TAG_MODEL_TRANSFORMATION = 34264;

/** A tag used to store raster->model tiepoint pairs. */
/** A tag used to store raster-&gt;model tiepoint pairs. */
public static final int TAG_MODEL_TIE_POINT = 33922;

/** A tag used to store the <i>GeoKey</i> directory. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public TIFFColorConverter() {}
* @throws NullPointerException if <code>result</code> is
* <code>null</code>.
* @throws ArrayIndexOutOfBoundsException if
* <code>result.length&nbsp;<&nbsp;3</code>.
* <code>result.length&nbsp;&lt;&nbsp;3</code>.
*/
public abstract void fromRGB(float r, float g, float b, float[] result);

Expand All @@ -83,7 +83,7 @@ public TIFFColorConverter() {}
* @throws NullPointerException if <code>rgb</code> is
* <code>null</code>.
* @throws ArrayIndexOutOfBoundsException if
* <code>rgb.length&nbsp;<&nbsp;3</code>.
* <code>rgb.length&nbsp;&lt;&nbsp;3</code>.
*/
public abstract void toRGB(float x0, float x1, float x2, float[] rgb);
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
import javax.imageio.ImageWriter;
import javax.imageio.metadata.IIOMetadata;
import javax.imageio.stream.ImageOutputStream;
import java.awt.image.*;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;

import com.github.jaiimageio.impl.plugins.tiff.TIFFImageWriter;

Expand Down Expand Up @@ -278,7 +283,83 @@ public abstract int encode(byte[] b, int off,
int width, int height,
int[] bitsPerSample,
int scanlineStride) throws IOException;


/**
* Encodes the supplied image data, writing to the currently set
* <code>ImageOutputStream</code>.
*
* @param dataBuffer an DataBuffer with pixels
* @param off the starting offset of the data to be written in the
* array <code>b</code>.
* @param width the width of the rectangle of pixels to be written.
* @param height the height of the rectangle of pixels to be written.
* @param bitsPerSample an array of <code>int</code>s indicting
* the number of bits used to represent each image sample within
* a pixel.
* @param scanlineStride the number of bytes separating each
* row of the input data.
*
* @return the number of bytes written.
*
* @throws IOException if the supplied data cannot be encoded by
* this <code>TIFFCompressor</code>, or if any I/O error occurs
* during writing.
*/
private byte[] currentTile = null;
public int encode(DataBuffer dataBuffer, int off,
int width, int height,
int[] bitsPerSample,
int scanlineStride) throws IOException {
final int dataType = dataBuffer.getDataType();
if (dataType == DataBuffer.TYPE_BYTE) {
return encode(((DataBufferByte) dataBuffer).getData(), off, width, height, bitsPerSample, scanlineStride);
}
final int dataTypeSize = DataBuffer.getDataTypeSize(dataType) / Byte.SIZE;
int tileSize = width * height * dataTypeSize;
if (currentTile == null || currentTile.length < tileSize)
currentTile = new byte[tileSize];
final ByteBuffer buffer = ByteBuffer.wrap(currentTile).order(stream.getByteOrder());
switch (dataType) {
case DataBuffer.TYPE_USHORT: {
ShortBuffer sb = buffer.asShortBuffer();
short[] shorts = ((DataBufferUShort) dataBuffer).getData();
for (int i = 0; i < height; i++) {
sb.put(shorts, off, width);
off += scanlineStride;
}
break;
}
case DataBuffer.TYPE_SHORT: {
ShortBuffer sb = buffer.asShortBuffer();
short[] shorts = ((DataBufferShort) dataBuffer).getData();
for (int i = 0; i < height; i++) {
sb.put(shorts, off, width);
off += scanlineStride;
}
break;
}
case DataBuffer.TYPE_INT: {
IntBuffer ib = buffer.asIntBuffer();
int[] ints = ((DataBufferInt) dataBuffer).getData();
for (int i = 0; i < height; i++) {
ib.put(ints, off, width);
off += scanlineStride;
}
break;
}
case DataBuffer.TYPE_FLOAT: {
FloatBuffer fb = buffer.asFloatBuffer();
float[] floats = ((DataBufferFloat) dataBuffer).getData();
for (int i = 0; i < height; i++) {
fb.put(floats, off, width);
off += scanlineStride;
}
break;
}
}
return encode(currentTile, 0, width, height, bitsPerSample, width * dataTypeSize);
}

/**
* Allows any resources held by this object to be released. The
* result of calling any other method (other than
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public abstract class TIFFDecompressor {
* <p> The pixels in the source region to be copied are
* those with X coordinates of the form <code>activeSrcMinX +
* k*subsampleX</code>, where <code>k</code> is an integer such
* that <code>0 <= k < dstWidth</code>.
* that <code>0 &lt;= k &lt; dstWidth</code>.
*/
protected int activeSrcMinX;

Expand All @@ -388,7 +388,7 @@ public abstract class TIFFDecompressor {
* <p> The pixels in the source region to be copied are
* those with Y coordinates of the form <code>activeSrcMinY +
* k*subsampleY</code>, where <code>k</code> is an integer such
* that <code>0 <= k < dstHeight</code>.
* that <code>0 &lt;= k &lt; dstHeight</code>.
*/
protected int activeSrcMinY;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public int getNumber() {
* would return a value of:
*
* <pre>
* (1 << TIFFTag.TIFF_SHORT) | (1 << TIFFTag.TIFF_LONG)
* (1 &lt;&lt; TIFFTag.TIFF_SHORT) | (1 &lt;&lt; TIFFTag.TIFF_LONG)
* </pre>
*
* @return an <code>int</code> containing a bitmask encoding the
Expand Down
Loading