rasdaman API
image.h
Go to the documentation of this file.
1 /*
2 * This file is part of rasdaman community.
3 *
4 * Rasdaman community is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * Rasdaman community is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18 rasdaman GmbH.
19 *
20 * For more information please see <http://www.rasdaman.org>
21 * or contact Peter Baumann via <baumann@rasdaman.com>.
22 */
23 
24 #ifndef __RASNITF_IMAGE_H
25 #define __RASNITF_IMAGE_H
26 
27 #include <fstream>
28 #include <iostream>
29 
30 namespace RasNITF
31 {
32 
34 {
35 
36 public:
37 
38  char irepbandnn[2];
39  char isubcatnn[6];
40  char ifcnn[1];
41  char imfltnn[3];
42  char nlutsnn[1];
43  char nelutnn[5];
44  int numluts;
46  char* lutdnnm;
47 
48  image_band();
49  ~image_band();
50 
51 };
52 
53 class image
54 {
55 
56  /*********************************
57  * image header fields
58  ********************************/
59 
60  char m_im[2];
61  char m_iid1[10];
62  char m_idatim[14];
63  char m_tgtid[17];
64  char m_iid2[80];
65  char m_isclas[1];
66  char m_isclsy[2];
67  char m_iscode[11];
68  char m_isctlh[2];
69  char m_isrel[20];
70  char m_isdctp[2];
71  char m_isdcdt[8];
72  char m_isdcxm[4];
73  char m_isdg[1];
74  char m_isdgdt[8];
75  char m_iscltx[43];
76  char m_iscatp[1];
77  char m_iscaut[40];
78  char m_iscrsn[1];
79  char m_issrdt[8];
80  char m_isctln[15];
81  char m_encryp[1];
82  char m_isorce[42];
83  char m_nrows[8];
84  char m_ncols[8];
85  char m_pvtype[3];
86  char m_irep[8];
87  char m_icat[8];
88  char m_abpp[2];
89  char m_pjust[1];
90  char m_icords[1];
91  char m_igeolo[60];
92  char m_nicom[1];
93  char* m_icom;
94  char m_ic[2];
95  char m_comrat[4];
96  char m_nbands[1];
97  char m_xbands[5];
98  image_band* m_bands;
99  char m_isync[1];
100  char m_imode[1];
101  char m_nbpr[4];
102  char m_nbpc[4];
103  char m_nppbh[4];
104  char m_nppbv[4];
105  char m_nbpp[2];
106  char m_idlvl[3];
107  char m_ialvl[3];
108  char m_iloc[10];
109  char m_imag[4];
110  char m_udidl[5];
111  char m_udofl[3];
112  char* m_udid;
113  char m_ixshdl[5];
114  char m_ixsofl[3];
115  char* m_ixshd;
116 
117  /*****************************
118  * image data mask table
119  ****************************/
120 
121  /*
122  long imdataoff;
123  unsigned short bmrlnth;
124  unsigned short tmrlnth;
125  unsigned short tpxcdlnth;
126  long tpxcd;
127  char* BMRnBNDm;
128  char* TMRnBNDm;
129  */
130 
131  /*****************************
132  * raw image data
133  *****************************/
134 
135  char* m_data;
136 
137  /*****************************
138  * additional variables
139  *****************************/
140 
141 // bool compressed;
142  int n_nicom;
143  int n_nbands;
144  int n_xbands;
145  int numbands;
146  int n_udidl;
147  int n_ixshdl;
148  long header_length;
149  long data_length;
150  char texthl[6];
151  char textdl[10];
152  int n_nbpr;
153  int n_nbpc;
154  int n_nppbh;
155  int n_nppbv;
156 
157  /*****************************
158  * variables for data reordering
159  * populated by compute_data_reordering_variables()
160  *****************************/
161 
162  int n_nrows;
163  int n_ncols;
164  int px_comp_size;
165  int px_size;
166  int numblocks;
167 
168  long block_size_bytes;
169  long block_size_pixels;
170  long block_row_size; //bytes
171  long block_band_size; //bytes
172  long block_band_size_px;
173  long image_band_size;
174 
175 
176  int copy_block_data(char* writeto, int hor_block_index, int ver_block_index );
177 
178  // functions for data reordering
179 
180  void compute_data_reordering_variables();
181 
182  int blpxseq2pxseq(char* src, char* dest);
183  int pxseq2blpxseq(char*, char*);
184 
185  int imode_1band2ps();
186  int imode_b2ps();
187  int imode_r2ps();
188  int imode_p2ps();
189  int imode_s2ps();
190 
191  int imode_ps21band(char*);
192  int imode_ps2b(char*);
193  int imode_ps2r(char*);
194  int imode_ps2p(char*);
195  int imode_ps2s(char*);
196 
197 
198 public:
199 
200  image();
201  ~image();
202 
203  int read_file(std::istream&, long, long, bool read_image_data);
204  int write_file(std::ofstream& fs);
205 
206  std::string get_li() const;
207  std::string get_lish() const;
208  long get_size() const;
209  int get_width() const;
210  int get_height() const;
211 
212  int to_pixel_sequential();
213  int to_block_pixel_sequential(char* src);
214 
215  std::string get_irep() const;
216  std::string get_pvtype() const;
217 
218  int get_nbpp_bytes() const;
219 
220 // char* get_data_ptr();
221 
222 
223 };
224 
225 }
226 
227 #endif
228 
229 
std::string get_li() const
char imfltnn[3]
Definition: image.h:41
Definition: image.h:53
std::string get_pvtype() const
char isubcatnn[6]
Definition: image.h:39
char * lutdnnm
Definition: image.h:46
int get_width() const
std::string get_lish() const
int get_nbpp_bytes() const
int get_height() const
int to_block_pixel_sequential(char *src)
Definition: image.h:33
int write_file(std::ofstream &fs)
int read_file(std::istream &, long, long, bool read_image_data)
char nlutsnn[1]
Definition: image.h:42
long get_size() const
char nelutnn[5]
Definition: image.h:43
char ifcnn[1]
Definition: image.h:40
int to_pixel_sequential()
std::string get_irep() const
int numlutentries
Definition: image.h:45
int numluts
Definition: image.h:44
char irepbandnn[2]
Definition: image.h:38