Beispiel #1
0
 def __init__(self, handle, start=0, byteSkip=0):
     self.error = Error()
     self.handle = handle  #must set this so it doesn't get ref-counted away
     SegmentSource.__init__(
         self,
         nitropy.nitf_SegmentFileSource_construct(handle.ref, start,
                                                  byteSkip, self.error))
Beispiel #2
0
 def __init__(self):
     if PluginRegistry.__instance:
         self = PluginRegistry.__instance
     else:
         PluginRegistry.__instance = self
         PluginRegistry.__instance.error = Error()
         PluginRegistry.__instance.ref = nitropy.nitf_PluginRegistry_getInstance(PluginRegistry.__instance.error)
Beispiel #3
0
 def __init__(self, handle, start=0, nbpp=1, pixelskip=0):
     self.error = Error()
     self.handle = handle  #must set this so it doesn't get ref-counted away
     BandSource.__init__(
         self,
         nitropy.nitf_FileSource_construct(handle.ref, start, nbpp,
                                           pixelskip, self.error))
Beispiel #4
0
 def __init__(self, ref=None, version=NITF_VER_21):
     self.error = Error()
     if ref is not None:
         self.ref = ref
     else:
         self.ref = nitropy.nitf_Record_construct(version, self.error)
     self.header = FileHeader(self.ref.header)
Beispiel #5
0
 def _get_listof(self, type):
     type = type.lower()
     if type == 'image' or type == 'images':
         type = 'Image'
     elif type == 'graphic' or type == 'graphics':
         type = 'Graphic'
     elif type == 'text' or type == 'texts':
         type = 'Text'
     elif type == 'label' or type == 'labels':
         type = 'Label'
     elif type == 'dataextension' or type == 'dataextensions' \
         or type == 'de' or type == 'des':
         type = 'DE'
     elif type == 'reservedextension' or type == 'reservedextensions' \
         or type == 're' or type == 'res':
         type = 'RE'
     else:
         return None
     arr = []
     error = Error()
     num = eval('nitropy.py_Record_getNum%ss(self.ref)' % type)
     for i in range(num):
         arr.append(
             eval('%sSegment( \
             nitropy.py_Record_get%s(self.ref, i, error))' % (type, type)))
     #could use frozenset to be immutable list...
     return tuple(arr)
Beispiel #6
0
 def __init__(self):
     self.error = Error()
     self.ref = nitropy.nitf_Writer_construct(self.error)
     if not self.ref:
         raise Exception('Unable to create Writer')
     self._imageWriters, self._graphicWriters = [], []
     self.io = None
Beispiel #7
0
 def __init__(self, data, size=-1, start=0, nbpp=1, pixelskip=0):
     self.error = Error()
     if size == -1:
         size = len(data)
     BandSource.__init__(
         self,
         nitropy.nitf_MemorySource_construct(data, size, start, nbpp,
                                             pixelskip, self.error))
Beispiel #8
0
 def __init__(self, rowSkip = 1, colSkip = 1):
     """
     Default row and column skips are 1, meaning no downsampling
     """
     self.rowSkip = rowSkip
     self.colSkip = colSkip
     self.error = Error()
     DownSampler.__init__(self, nitropy.nitf_MaxDownSample_construct(rowSkip, colSkip, self.error))
Beispiel #9
0
 def __init__(self, filename, accessFlags=ACCESS_READONLY, createFlags=OPEN_EXISTING):
     self.filename = filename
     self.error = Error()
     self.ref = nitropy.py_IOHandle_create(
         filename, accessFlags, createFlags, self.error)
     if self.ref < 0:
         raise Exception, 'Unable to open IOHandle at location %s' % filename
     self.open = True
Beispiel #10
0
 def __init__(self, data, size=-1, start=0, byteSkip=0):
     self.error = Error()
     if size == -1:
         size = len(data)
     SegmentSource.__init__(
         self,
         nitropy.nitf_SegmentMemorySource_construct(data, size, start,
                                                    byteSkip, self.error))
Beispiel #11
0
 def __init__(self, ref):
     """
     Create either a new TRE or refer to an existing underlying TRE
     The ref parameter is checked
     """
     self.error = Error()
     if not ref or isinstance(ref, str):
         tag = ref
         ref = nitropy.nitf_TRE_construct(tag, None, self.error)
         if not ref:
             raise Exception('Unable to create TRE with tag \'%s\'' % tag)
     self.ref = ref
Beispiel #12
0
 def __init__(self, ref, field_list=None):
     self.ref = ref
     self.error = Error()
     self.fieldMap = {}
     
     #set up the map of fields
     for func in dir(ref):
         name = str(func)
         obj = ref.__getattribute__(name)
         
         #check if it is a Field
         if isinstance(obj, nitropy.nitf_Field):
             self.fieldMap[name.lower()] = 'self.ref.%s' % name
     
     if field_list:
         for field in field_list:
             self.fieldMap[field['id'].lower()] = 'self.ref.%s' % field['name']
Beispiel #13
0
 def getComponentInfo(self, type, index):
     error = Error()
     return ComponentInfo(
         nitropy.py_FileHeader_getComponentInfo(self.ref, index,
                                                str(type).lower(), error))
Beispiel #14
0
 def intValue(self):
     error = Error()
     return nitropy.py_Field_getInt(self.ref, error)
Beispiel #15
0
 def setString(self, data):
     error = Error()
     retval = nitropy.nitf_Field_setString(self.ref, str(data), error)
Beispiel #16
0
 def getString(self):
     error = Error()
     return nitropy.py_Field_getString(self.ref, error)
Beispiel #17
0
 def __init__(self, ref):
     self.ref = ref
     self.error = Error()
     self.subheader = None
Beispiel #18
0
 def __init__(self):
     self.error = Error()
     self.ref = nitropy.nitf_Reader_construct(self.error)
     self.io, self.record = None, None
Beispiel #19
0
 def __init__(self, ref):
     self.ref = ref
     self.error = Error()
Beispiel #20
0
 def __init__(self, ref, nbpp):
     self.ref = ref
     self.error = Error()
     self.nbpp = nbpp
Beispiel #21
0
 def loadDir(dirname):
     """ Loads any plugins in the given directory """
     error = Error()
     if not nitropy.nitf_PluginRegistry_loadDir(dirname, error):
         raise Exception('Unable to load the directory: %s (error=%s)' %
                         (dirname, error.message))
Beispiel #22
0
 def __init__(self, ref):
     self.ref = ref
     if not hasattr(self, 'error'):
         self.error = Error()
Beispiel #23
0
 def __init__(self):
     self.error = Error()
     self.ref = nitropy.nitf_ImageSource_construct(self.error)
     self._attached = []