1 package nom.tam.image.tile.operation;
2
3 /*
4 * #%L
5 * nom.tam FITS library
6 * %%
7 * Copyright (C) 1996 - 2024 nom-tam-fits
8 * %%
9 * This is free and unencumbered software released into the public domain.
10 *
11 * Anyone is free to copy, modify, publish, use, compile, sell, or
12 * distribute this software, either in source code form or as a compiled
13 * binary, for any purpose, commercial or non-commercial, and by any
14 * means.
15 *
16 * In jurisdictions that recognize copyright laws, the author or authors
17 * of this software dedicate any and all copyright interest in the
18 * software to the public domain. We make this dedication for the benefit
19 * of the public at large and to the detriment of our heirs and
20 * successors. We intend this dedication to be an overt act of
21 * relinquishment in perpetuity of all present and future rights to this
22 * software under copyright law.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
27 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
28 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
29 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
30 * OTHER DEALINGS IN THE SOFTWARE.
31 * #L%
32 */
33
34 import java.nio.Buffer;
35 import java.nio.ByteBuffer;
36
37 import nom.tam.fits.compression.algorithm.api.ICompressOption;
38 import nom.tam.fits.compression.algorithm.api.ICompressorControl;
39 import nom.tam.util.type.ElementType;
40
41 /**
42 * 2D image tile compression interface. FITS tiles are always 2-dimentional, but really images of any dimensions may be
43 * covered with such tiles.
44 *
45 * @see TileArea
46 * @see nom.tam.image.ImageTiler
47 */
48 public interface ITiledImageOperation {
49 /**
50 * Retuers the tile compression options to use for tile compressing or uncompressing images.
51 *
52 * @return the tile compression options
53 */
54 ICompressOption compressOptions();
55
56 /**
57 * Returns the element type of the image (and hence tile).
58 *
59 * @return the FITS element type used in this tile.
60 */
61 ElementType<Buffer> getBaseType();
62
63 /**
64 * Returns a buffer containing the entire tile compressed image.
65 *
66 * @return a buffer containing the tile compresed image in serialized form.
67 */
68 ByteBuffer getCompressedWholeArea();
69
70 /**
71 * Returns the class that can perform the tile compression or decompression with the desired tile compression
72 * algorithm and options. Some image tiles may not be possible to compress with the chosen algorithm, and FITS then
73 * allows alternative compression of these using GZIP instead (see {@link #getGzipCompressorControl()}
74 *
75 * @return the class that can perform the desired tile compression.
76 *
77 * @see #getGzipCompressorControl()
78 * @see #compressOptions()
79 */
80 ICompressorControl getCompressorControl();
81
82 /**
83 * Return the class that can GZIP compress tiles that cannot be compressed otherwise. GZIP compression is failsafe
84 * and is therefore a standard fallback option when compressing tiles. It may also be the desired first choice
85 * method also.
86 *
87 * @return the class that can perform the fail-safe tile compression using GZIP.
88 *
89 * @see #getCompressorControl()
90 */
91 ICompressorControl getGzipCompressorControl();
92
93 /**
94 * Returns the actual with of the image which is to be tile (de)compressed.
95 *
96 * @return The width of the full image in pixels.
97 */
98 int getImageWidth();
99
100 /**
101 * Returns the operation that handles the parallel processing of specific tiles. Each tile can be processed by a
102 * dedicated thread, with many tiles processing in parallel at the same time.
103 *
104 * @param i the sequential (flattened) index of the specific tile
105 *
106 * @return the operation instance that handles the parallel processing of that particular tiles.
107 */
108 ITileOperation getTileOperation(int i);
109 }