summaryrefslogtreecommitdiffstats
path: root/conversion/nitf.h
blob: 892eb14b45f30e3be1d423603990cdf8c5a5de67 (plain)
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
/*
* This file is part of rasdaman community.
*
* Rasdaman community is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Rasdaman community is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with rasdaman community.  If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
rasdaman GmbH.
*
* For more information please see <http://www.rasdaman.org>
* or contact Peter Baumann via <baumann@rasdaman.com>.
*/

/**
  * This is the definition of the NITF class, an agregation of the Classes Header,
  * Image, Graphic and Text
  */

#ifndef __RASNITF_NITF_H
#define __RASNITF_NITF_H

#include<string>
#include<vector>
#include<iostream>
#include<fstream>


namespace RasNITF{

class image;
class graphic;
class text;
class des;
class res;

class nitf {

    char m_fhdr[9];
    char m_clevel[2];	
    char m_stype[4];	
    char m_ostaid[10];
    char m_fdt[14];
    char m_ftitle[80];
    char m_fsclas[1]; 
    char m_fsclsy[2];
    char m_fscode[11];
    char m_fsctlh[2];
    char m_fsrel[20];
    char m_fsdctp[2];
    char m_fsdcdt[8];	
    char m_fsdcxm[4];
    char m_fsdg[1];
    char m_fsdgdt[8];	
    char m_fscltx[43];
    char m_fscatp[1];
    char m_fscaut[40];
    char m_fscrsn[1];
    char m_fssrdt[8];	
    char m_fsctln[15];
    char m_fscop[5];	
    char m_fscpys[5];	
    char m_encryp[1];	
    char m_fbkgc[3];	
    char m_oname[24];
    char m_ophone[18];

    char m_fl[12];
    char m_hl[6]; 
    char m_numi[3];       
    char* m_li;           // image sizes data 
    char m_nums[3];      
    char* m_ls;           // graphic sizes data
    char m_numx[3]; 
    char m_numt[3];       
    char* m_lt;           // text sizes data 
    char m_numdes[3]; 
    char* m_ld;           // des sizes data
    char m_numres[3];    
    char* m_lr;           // res sizes data
    char m_udhdl[5];	
    char m_udhofl[3];	
    char* m_udhd; 	
    char m_xhdl[5];	
    char m_xhdlofl[3];
    char* m_xhd;	

    // DATA
    
    //std::ifstream hNITF; 

    long n_fl;        
    long n_hl;	      

    int n_numi;
    std::vector<long> n_lish;
    std::vector<long> n_li;
    image *m_images; 	

    int n_nums;
    std::vector<long> n_lssh;
    std::vector<long> n_ls;
    graphic *m_graphics; 

    int n_numt;		   
    std::vector<long> n_ltsh;
    std::vector<long> n_lt;	
    text *m_texts; 	

    int n_numdes;
    std::vector<long> n_ldsh;
    std::vector<long> n_ld;
    des	*m_des;

    int n_numres;
    std::vector<long> n_lrsh; 
    std::vector<long> n_lr;
    res *m_res;

    int n_udhdl;
    int n_xhdl;

    bool isEmpty;

public:
    
    nitf();		
    ~nitf();

    int read_file(std::string filename);      
    int read_headers_from(char* file_data, long file_length);
    int read(std::istream &hNITF, bool read_image_data);

    int write_file(std::string filename);		

    void image_to_pixel_sequential(int index);	

    void stats() const;
    void empty();
    bool checkempty();

    long get_image_size(int index = 0) const;
    int get_image_width(int index = 0) const;
    int get_image_height(int index = 0) const;
    int get_image_pixel_type(int index = 0) const;
    long get_image_offset(int index = 0) const; 

    bool isRGB(int image_index);
    bool isGRAY(int image_index);
    bool isBOOL(int image_index);

};

}

#endif