Add cache_images option
This commit is contained in:
parent
cd30da3426
commit
420754ed32
|
@ -14,6 +14,7 @@ framerate = 16
|
|||
vflip = false
|
||||
hflip = false
|
||||
export_options = 'scale=1920:-1,crop=1920:1080:0:102'
|
||||
cache_images = false
|
||||
[CAMERA]
|
||||
# Nikon D40x
|
||||
capturemode = 3 # use IR remote
|
||||
|
|
30
main_c.py
30
main_c.py
|
@ -90,6 +90,7 @@ project_settings_defaults = {
|
|||
'vflip' : False,
|
||||
'hflip' : False,
|
||||
'export_options' : 'scale=1920:-1,crop=1920:1080:0:102',
|
||||
'cache_images' : False,
|
||||
}
|
||||
|
||||
# Camera Settings (Nikon D40x)
|
||||
|
@ -128,6 +129,7 @@ class KISStopmo(tk.Tk):
|
|||
self.fullscreen_bool = project_settings['fullscreen_bool']
|
||||
self.screen_w, self.screen_h = project_settings['screen_w'], project_settings['screen_h']
|
||||
self.framerate = project_settings['framerate']
|
||||
self.playback = False
|
||||
|
||||
# ~ self.photo = None
|
||||
self.end_thread = False
|
||||
|
@ -195,20 +197,19 @@ class KISStopmo(tk.Tk):
|
|||
|
||||
self.splashscreen = self.generate_splashscreen()
|
||||
|
||||
image = self.update_image()
|
||||
if image:
|
||||
self.image = None
|
||||
self.update_image()
|
||||
if self.image:
|
||||
if self.onion_skin:
|
||||
if self.img_index:
|
||||
photo = self.apply_onionskin(image, self.onionskin_alpha_default, self.onionskin_fx)
|
||||
photo = self.apply_onionskin(self.image, self.onionskin_alpha_default, self.onionskin_fx)
|
||||
else:
|
||||
photo = ImageTk.PhotoImage(image)
|
||||
|
||||
photo = ImageTk.PhotoImage(self.image)
|
||||
self.label.configure(image=photo)
|
||||
self.label.image = photo
|
||||
|
||||
if project_settings['trigger_mode'] == 'event':
|
||||
root.after(1000, self.trigger_bg_loop)
|
||||
# ~ root.after(1000, self.wait_for_capture)
|
||||
|
||||
# Key binding
|
||||
root.bind("<Escape>", lambda event: root.attributes("-fullscreen", False))
|
||||
|
@ -219,7 +220,7 @@ class KISStopmo(tk.Tk):
|
|||
root.bind("<N>", self.preview_animation)
|
||||
root.bind("<E>", self.trigger_export_animation)
|
||||
root.bind("<d>", self.remove_frame)
|
||||
# ~ root.bind("<a>", self.print_imglist)
|
||||
root.bind("<a>", self.print_imglist)
|
||||
|
||||
if project_settings['trigger_mode'] != 'event':
|
||||
root.bind("<n>", self.capture_image)
|
||||
|
@ -432,10 +433,13 @@ class KISStopmo(tk.Tk):
|
|||
image = image.transpose(Image.Transpose.FLIP_TOP_BOTTOM)
|
||||
if hflip:
|
||||
image = image.transpose(Image.Transpose.FLIP_LEFT_RIGHT)
|
||||
if project_settings['cache_images']:
|
||||
# TODO : Do not cache image to preserve memory
|
||||
self.img_list[filetuple[0]] = image
|
||||
except FileNotFoundError:
|
||||
return False
|
||||
else:
|
||||
if project_settings['cache_images']:
|
||||
image = filetuple[-1]
|
||||
return image
|
||||
|
||||
|
@ -471,7 +475,7 @@ class KISStopmo(tk.Tk):
|
|||
|
||||
|
||||
def update_image(self, event=None, index=None):
|
||||
# TODO : check event mode stille works
|
||||
# TODO : check event mode still works
|
||||
if event is not None:
|
||||
self.img_index = self.check_range(self.img_index+1)
|
||||
if index is None:
|
||||
|
@ -493,7 +497,10 @@ class KISStopmo(tk.Tk):
|
|||
photo = self.apply_onionskin(new_image, project_settings['onionskin_alpha_default'], project_settings['onionskin_fx'])
|
||||
self.label.configure(image=photo)
|
||||
self.label.image = photo
|
||||
return new_image
|
||||
# ~ return new_image
|
||||
self.image = new_image
|
||||
# ~ new_image.close()
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
@ -514,11 +521,16 @@ class KISStopmo(tk.Tk):
|
|||
self.onion_skin = False
|
||||
onion_skin_was_on = True
|
||||
# playback
|
||||
# TODO : Use async function for playback
|
||||
# ~ self.playback = not self.playback
|
||||
for img in self.img_list:
|
||||
# ~ self.update_image(None, self.img_list.index(img))
|
||||
# ~ if self.playback:
|
||||
self.update_image(None, list(self.img_list.keys()).index(img))
|
||||
root.update_idletasks()
|
||||
time.sleep(1/self.framerate)
|
||||
# ~ else:
|
||||
# ~ break
|
||||
# ~ self.update_image(None, self.img_index)
|
||||
self.display_last_frame()
|
||||
# restore OS state
|
||||
|
|
Loading…
Reference in New Issue