Can now display displayed portrait and displayed signature or usual mark
git-svn-id: svn+ssh://localhost/home/henryk/svn/cyberflex-shell/trunk@236 f711b948-2313-0410-aaa9-d29f33439f0b
This commit is contained in:
parent
da589e2c77
commit
38bc6d9efc
|
@ -466,7 +466,7 @@ class FAC:
|
|||
for index, face in enumerate(self.faces):
|
||||
face.store(basename="%s_%02i" % (basename, index))
|
||||
|
||||
def get_data(self):
|
||||
def get_images(self):
|
||||
return [face.get_data() for face in self.faces]
|
||||
|
||||
# Note: Probably all of the code in this class is wrong. I'm just guessing from examples and parts of specifications I didn't fully read --Henryk
|
||||
|
@ -945,6 +945,12 @@ class Passport(object):
|
|||
def parse_DG2(self, contents):
|
||||
self.dg2_cbeff = CBEFF.from_data(contents)
|
||||
|
||||
def parse_DG5(self, contents):
|
||||
self.dg5_tlv = TLV_utils.unpack(contents)
|
||||
|
||||
def parse_DG7(self, contents):
|
||||
self.dg7_tlv = TLV_utils.unpack(contents)
|
||||
|
||||
def calculate_check_digit(data, digit=None, field=None):
|
||||
"""Calculate a check digit. If digit is not None then it will be compared to the calculated
|
||||
check digit and a PassportParseError will be raised on a mismatch. Optional argument field
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import gtk,gtk.glade,gobject
|
||||
import os, time
|
||||
import os, time, TLV_utils
|
||||
|
||||
class Converter:
|
||||
SUPPORTS = ["jp2"]
|
||||
|
@ -31,6 +31,8 @@ class PassportGUI:
|
|||
"on_exit_clicked": self.exit_clicked,
|
||||
"on_main_delete_event": self.exit_clicked,
|
||||
"on_main_destroy": gtk.main_quit,
|
||||
"on_next_image_clicked": self.next_image,
|
||||
"on_prev_image_clicked": self.prev_image,
|
||||
}
|
||||
self.main_window_xml.signal_autoconnect(signals)
|
||||
|
||||
|
@ -102,7 +104,15 @@ class PassportGUI:
|
|||
data = []
|
||||
if hasattr(passport, "dg2_cbeff") and passport.dg2_cbeff is not None:
|
||||
for biometric in passport.dg2_cbeff.biometrics:
|
||||
data = data + [(a,b,"Encoded Face") for (a,b) in biometric.get_data()]
|
||||
data = data + [(a,b,"Encoded Face") for (a,b) in biometric.get_images()]
|
||||
|
||||
for dg, tag, type in ( ("dg5", 0x5F40, "Displayed Portrait"), ("dg7", 0x5F43, "Displayed Signature or Usual Mark") ):
|
||||
if hasattr(passport, "%s_tlv" % dg):
|
||||
structure = getattr(passport, "%s_tlv" % dg)
|
||||
if structure is not None:
|
||||
hits = TLV_utils.tlv_find_tag(structure, tag)
|
||||
for t,l,v in hits:
|
||||
data.append( ("jpg",v,type) )
|
||||
|
||||
self._set_images(data)
|
||||
|
||||
|
@ -121,14 +131,17 @@ class PassportGUI:
|
|||
|
||||
self.update_image_shown()
|
||||
|
||||
def update_image_shown(self):
|
||||
def update_image_shown(self, add=0):
|
||||
self.now_showing = self.now_showing + add
|
||||
|
||||
if self.now_showing >= len(self.images):
|
||||
self.now_showing = len(self.images)-1
|
||||
if self.now_showing < 0:
|
||||
self.now_showing = 0
|
||||
|
||||
if len(self.images) > 0:
|
||||
pixbuf, description = self.images[self.now_showing]
|
||||
else:
|
||||
self.now_showing = 0
|
||||
pixbuf, description = None, "No image loaded"
|
||||
|
||||
label = self.main_window_xml.get_widget("image_label")
|
||||
|
@ -142,3 +155,12 @@ class PassportGUI:
|
|||
|
||||
if pixbuf is not None:
|
||||
self.main_window_xml.get_widget("image").set_from_pixbuf(pixbuf)
|
||||
|
||||
self.main_window_xml.get_widget("prev_image").set_property("sensitive", self.now_showing > 0)
|
||||
self.main_window_xml.get_widget("next_image").set_property("sensitive", self.now_showing < len(self.images)-1)
|
||||
|
||||
def next_image(self, widget):
|
||||
self.update_image_shown(+1)
|
||||
|
||||
def prev_image(self, widget):
|
||||
self.update_image_shown(-1)
|
||||
|
|
|
@ -322,12 +322,13 @@ Optional Data</property>
|
|||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="button1">
|
||||
<widget class="GtkButton" id="prev_image">
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_prev_image_clicked" last_modification_time="Sat, 09 Jun 2007 06:37:03 GMT"/>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImage" id="image4">
|
||||
|
@ -352,12 +353,13 @@ Optional Data</property>
|
|||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="button2">
|
||||
<widget class="GtkButton" id="next_image">
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_next_image_clicked" last_modification_time="Sat, 09 Jun 2007 06:36:52 GMT"/>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImage" id="image3">
|
||||
|
|
Loading…
Reference in New Issue