-
Notifications
You must be signed in to change notification settings - Fork 254
Expand file tree
/
Copy pathIFormatWriter.java
More file actions
266 lines (225 loc) · 10 KB
/
IFormatWriter.java
File metadata and controls
266 lines (225 loc) · 10 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
/*
* #%L
* Top-level reader and writer APIs
* %%
* Copyright (C) 2005 - 2017 Open Microscopy Environment:
* - Board of Regents of the University of Wisconsin-Madison
* - Glencoe Software, Inc.
* - University of Dundee
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package loci.formats;
import java.awt.image.ColorModel;
import java.io.IOException;
import java.util.List;
import loci.common.Region;
import loci.formats.codec.CodecOptions;
import loci.formats.meta.MetadataRetrieve;
/**
* Interface for all biological file format writers.
*/
public interface IFormatWriter extends IFormatHandler, IPyramidHandler {
/**
* Saves the given image to the current series in the current file.
*
* @param no the plane index within the series.
* @param buf the byte array that represents the image.
* @throws FormatException if one of the parameters is invalid.
* @throws IOException if there was a problem writing to the file.
*/
void saveBytes(int no, byte[] buf) throws FormatException, IOException;
/**
* Saves the given image tile to the current series in the current file.
*
* @param no the plane index within the series.
* @param buf the byte array that represents the image tile.
* @param x the X coordinate of the upper-left corner of the image tile.
* @param y the Y coordinate of the upper-left corner of the image tile.
* @param w the width (in pixels) of the image tile.
* @param h the height (in pixels) of the image tile.
* @throws FormatException if one of the parameters is invalid.
* @throws IOException if there was a problem writing to the file.
*/
void saveBytes(int no, byte[] buf, int x, int y, int w, int h)
throws FormatException, IOException;
/**
* Saves the given image tile to the current series in the current file.
*
* @param no the plane index within the series.
* @param buf the byte array that represents the image tile.
* @param tile the Region representing the image tile to be read.
* @throws FormatException if one of the parameters is invalid.
* @throws IOException if there was a problem writing to the file.
*/
void saveBytes(int no, byte[] buf, Region tile)
throws FormatException, IOException;
/**
* Saves the given chunk to the current series in the current file.
*
* @param buf the byte array that represents the image chunk.
* @param shape the size of the chunk for every dimension.
* @param offsets the offset of the chunk for every dimension.
* @throws FormatException if one of the parameters is invalid.
* @throws IOException if there was a problem writing to the file.
*/
void saveBytes(byte[] buf, int[] shape, int[] offsets) throws FormatException, IOException;
/**
* Saves the given image plane to the current series in the current file.
*
* @param no the plane index within the series.
* @param plane the image plane.
* @throws FormatException if one of the parameters is invalid.
* @throws IOException if there was a problem writing to the file.
*/
void savePlane(int no, Object plane) throws FormatException, IOException;
/**
* Saves the given image plane to the current series in the current file.
*
* @param no the plane index within the series.
* @param plane the image plane.
* @param x the X coordinate of the upper-left corner of the image tile.
* @param y the Y coordinate of the upper-left corner of the image tile.
* @param w the width (in pixels) of the image tile.
* @param h the height (in pixels) of the image tile.
* @throws FormatException if one of the parameters is invalid.
* @throws IOException if there was a problem writing to the file.
*/
void savePlane(int no, Object plane, int x, int y, int w, int h)
throws FormatException, IOException;
/**
* Saves the given image plane to the current series in the current file.
*
* @param no the plane index within the series.
* @param plane the image plane.
* @param tile the Region representing the image tile to be read.
* @throws FormatException if one of the parameters is invalid.
* @throws IOException if there was a problem writing to the file.
*/
void savePlane(int no, Object plane, Region tile)
throws FormatException, IOException;
/**
* Sets the current series.
*
* @param series the series index, starting from 0.
* @throws FormatException if the specified series is invalid.
*/
void setSeries(int series) throws FormatException;
/** Returns the current series. */
int getSeries();
/** Sets whether or not the channels in an image are interleaved. */
void setInterleaved(boolean interleaved);
/** Sets the number of valid bits per pixel. */
void setValidBitsPerPixel(int bits);
/** Gets whether or not the channels in an image are interleaved. */
boolean isInterleaved();
/** Reports whether the writer can save multiple images to a single file. */
boolean canDoStacks();
/**
* Sets the metadata retrieval object from
* which to retrieve standardized metadata.
*/
void setMetadataRetrieve(MetadataRetrieve r);
/**
* Retrieves the current metadata retrieval object for this writer. You can
* be assured that this method will <b>never</b> return a <code>null</code>
* metadata retrieval object.
* @return A metadata retrieval object.
*/
MetadataRetrieve getMetadataRetrieve();
/** Sets the color model. */
void setColorModel(ColorModel cm);
/** Gets the color model. */
ColorModel getColorModel();
/** Sets the frames per second to use when writing. */
void setFramesPerSecond(int rate);
/** Gets the frames per second to use when writing. */
int getFramesPerSecond();
/** Gets the available compression types. */
String[] getCompressionTypes();
/** Gets the supported pixel types. */
int[] getPixelTypes();
/** Gets the supported pixel types for the given codec. */
int[] getPixelTypes(String codec);
/** Checks if the given pixel type is supported. */
boolean isSupportedType(int type);
/** Sets the current compression type. */
void setCompression(String compress) throws FormatException;
/**
* Sets the codec options.
* @param options The options to set.
*/
void setCodecOptions(CodecOptions options) ;
/** Gets the current compression type. */
String getCompression();
/** Switch the output file for the current dataset. */
void changeOutputFile(String id) throws FormatException, IOException;
/**
* Sets whether or not we know that planes will be written sequentially.
* If planes are written sequentially and this flag is set, then performance
* will be slightly improved.
*/
void setWriteSequentially(boolean sequential);
/**
* Retrieves the current tile width
* Defaults to 0 if not supported
* @return The current tile width being used
* @throws FormatException Image metadata including Pixels Size X must be set prior to calling getTileSizeX()
*/
int getTileSizeX() throws FormatException;
/**
* Will attempt to set the tile width to the desired value and return the actual value which will be used
* @param tileSize The tile width you wish to use. Setting to 0 will disable tiling
* @return The tile width which will actually be used, this may differ from the value requested.
* If the requested value is not supported the writer will return and use the closest appropriate value.
* @throws FormatException Tile size must be greater than or equal to 0 and less than the image width
*/
int setTileSizeX(int tileSize) throws FormatException;
/**
* Retrieves the current tile height
* Defaults to 0 if not supported
* @return The current tile height being used
* @throws FormatException Image metadata including Pixels Size Y must be set prior to calling getTileSizeY()
*/
int getTileSizeY() throws FormatException;
/**
* Will attempt to set the tile height to the desired value and return the actual value which will be used
* @param tileSize The tile height you wish to use. Setting to 0 will disable tiling
* @return The tile height which will actually be used, this may differ from the value requested.
* If the requested value is not supported the writer will return and use the closest appropriate value.
* @throws FormatException Tile size must be greater than or equal to 0 and less than the image height
*/
int setTileSizeY(int tileSize) throws FormatException;
/**
* Specify a list of resolution objects for the current series.
* If resolutions are specified using this method, then any resolution
* data supplied via the MetadataRetrieve will be ignored.
*/
void setResolutions(List<Resolution> resolutions);
/**
* Get a list of resolution objects for the current series.
*/
List<Resolution> getResolutions();
int[] setChunkSize(int[] chunkSize) throws FormatException;
int[] getChunkSize() throws FormatException;
}