|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectus.zuercher.gpx2map.image.netpbm.WritablePpmImage
public class WritablePpmImage
WritablePpmImage is a write-only representation of a PPM image. It writes only the binary version of the PPM format, with optional gzip compression.
Field Summary | |
---|---|
private int |
bytesPerPixelPerColor
Image bytes per pixel color. |
private boolean |
gzip
Compression flag. |
private StringBuffer |
header
Header buffer typically copied from another image. |
private int |
height
Image height. |
private static String |
MAGIC
PPM magic token. |
private int |
maxVal
Image maximum pixel color value. |
private static String |
NL
PPM header line separator. |
private OutputStream |
output
Output stream. |
private File |
ppmImageFile
PPM file location. |
private int |
rastersWritten
Count of rastersWritten (compared to height). |
private int |
width
Image width. |
Constructor Summary | |
---|---|
WritablePpmImage(File ppmImageFile,
int width,
int height,
int maxVal,
boolean gzip)
Constructs a new WritablePpmImage with the given header information. |
|
WritablePpmImage(File ppmImageFile,
PpmImage headerSource,
boolean gzip)
Constructs a new WritablePpmImage, copying the image header from a PpmImage. |
Method Summary | |
---|---|
void |
close()
Closes the image file. |
private void |
writeHeader()
Writes the PPM header. |
void |
writeRaster(int[][] raster)
Write a raster line to the image file. |
void |
writeRaster(int[][] raster,
int offset)
Write a raster line to the image file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final String MAGIC
private static final String NL
private final File ppmImageFile
private final StringBuffer header
private final boolean gzip
private final int width
private final int height
private final int maxVal
private final int bytesPerPixelPerColor
private OutputStream output
private int rastersWritten
Constructor Detail |
---|
public WritablePpmImage(File ppmImageFile, PpmImage headerSource, boolean gzip) throws IOException
ppmImageFile
- output file locationheaderSource
- source of header informationgzip
- compression flag
IOException
- if the header source's header data cannot be readpublic WritablePpmImage(File ppmImageFile, int width, int height, int maxVal, boolean gzip)
ppmImageFile
- output file locationwidth
- image width in pixelsheight
- image height in pixelsmaxVal
- maximum pixel color value (255 or 65535)gzip
- compression flagMethod Detail |
---|
public void writeRaster(int[][] raster) throws IOException
raster
- an array of pixel data of size int[width][3].
IOException
- if there's an error writing to the file
IllegalArgumentException
- if more than height raster are
written, or if the given raster line
has the wrong widthpublic void writeRaster(int[][] raster, int offset) throws IOException
raster
- an array of pixel data of size int[][3].offset
- offset into raster array
IOException
- if there's an error writing to the file
IllegalArgumentException
- if more than height raster are
written, or if the raster does not
contain enough data to write a full
width raster line (e.g. raster.length -
offset < width)public void close() throws IOException
IOException
- if there's an error flushing or closing the file
IllegalStateException
- if height
rasters have not been
writtenprivate void writeHeader() throws IOException
IOException
- if there's an error writing to the file.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |