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 * Returns 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 * Ensure that per-tile compression parameters exists, and contain reasonable data for every tile.
58 *
59 * @since 1.23
60 */
61 void ensureColumnParameters();
62
63 /**
64 * Returns the element type of the image (and hence tile).
65 *
66 * @return the FITS element type used in this tile.
67 */
68 ElementType<Buffer> getBaseType();
69
70 /**
71 * Returns a buffer containing the entire tile compressed image.
72 *
73 * @return a buffer containing the tile compresed image in serialized form.
74 */
75 ByteBuffer getCompressedWholeArea();
76
77 /**
78 * Returns the class that can perform the tile compression or decompression with the desired tile compression
79 * algorithm and options. Some image tiles may not be possible to compress with the chosen algorithm, and FITS then
80 * allows alternative compression of these using GZIP instead (see {@link #getGzipCompressorControl()}
81 *
82 * @return the class that can perform the desired tile compression.
83 *
84 * @see #getGzipCompressorControl()
85 * @see #compressOptions()
86 */
87 ICompressorControl getCompressorControl();
88
89 /**
90 * Return the class that can GZIP compress tiles that cannot be compressed otherwise. GZIP compression is failsafe
91 * and is therefore a standard fallback option when compressing tiles. It may also be the desired first choice
92 * method also.
93 *
94 * @return the class that can perform the fail-safe tile compression using GZIP.
95 *
96 * @see #getCompressorControl()
97 */
98 ICompressorControl getGzipCompressorControl();
99
100 /**
101 * Returns the actual with of the image which is to be tile (de)compressed.
102 *
103 * @return The width of the full image in pixels.
104 */
105 int getImageWidth();
106
107 /**
108 * Returns the operation that handles the parallel processing of specific tiles. Each tile can be processed by a
109 * dedicated thread, with many tiles processing in parallel at the same time.
110 *
111 * @param i the sequential (flattened) index of the specific tile
112 *
113 * @return the operation instance that handles the parallel processing of that particular tiles.
114 */
115 ITileOperation getTileOperation(int i);
116 }