last tile is not 0 if videos are exactly a multiple of large_tile_w

This commit is contained in:
j 2012-06-15 15:33:51 +02:00
parent d761d93f8c
commit fed701b0c8

View file

@ -304,7 +304,7 @@ class Timelines():
self.frame_center = int(frame_size[0] / 2) self.frame_center = int(frame_size[0] / 2)
self.large_tile_n = int(math.ceil(self.frame_n / self.large_tile_w)) self.large_tile_n = int(math.ceil(self.frame_n / self.large_tile_w))
self.large_tile_last_w = self.frame_n % self.large_tile_w self.large_tile_last_w = self.frame_n % self.large_tile_w or self.large_tile_w
if self.render_small_tiles: if self.render_small_tiles:
self.small_tile_n = int(math.ceil(self.duration / self.small_tile_w)) self.small_tile_n = int(math.ceil(self.duration / self.small_tile_w))
self.small_tile_last_w =int(math.ceil(self.duration % self.small_tile_w)) self.small_tile_last_w =int(math.ceil(self.duration % self.small_tile_w))
@ -413,6 +413,7 @@ class Timelines():
self._render_keyframes() self._render_keyframes()
self.cut_frames.append(frame_image) self.cut_frames.append(frame_image)
if self.is_last_frame: if self.is_last_frame:
if not self.cuts or self.cuts[-1] != self.frame_n:
self.cuts.append(self.frame_n) self.cuts.append(self.frame_n)
self._render_keyframes() self._render_keyframes()
@ -439,8 +440,9 @@ class Timelines():
wide = 1 if mode == 'keyframes' else self.wide wide = 1 if mode == 'keyframes' else self.wide
frame_ratio = self.frame_ratio * wide frame_ratio = self.frame_ratio * wide
cut_images = int(math.ceil(cut_width / (frame_ratio * self.large_tile_h))) cut_images = int(math.ceil(cut_width / (frame_ratio * self.large_tile_h)))
if cut_width == cut_images == 0: if cut_images == 0:
print 'ERROR division by zerro', cut_width, cut_images print 'ERROR division by zerro', cut_width, cut_images
index = -1
image_widths = self._divide(cut_width, cut_images) image_widths = self._divide(cut_width, cut_images)
image_i = self.cuts[-2] image_i = self.cuts[-2]
large_keyframes_tile_i = self.large_keyframes_tile_i large_keyframes_tile_i = self.large_keyframes_tile_i
@ -473,8 +475,9 @@ class Timelines():
self.large_tile_image[mode] = Image.new('RGB', (w, self.large_tile_h)) self.large_tile_image[mode] = Image.new('RGB', (w, self.large_tile_h))
self.large_tile_image[mode].paste(frame_image, (offset, 0)) self.large_tile_image[mode].paste(frame_image, (offset, 0))
image_i += image_w image_i += image_w
if self.is_last_frame: if self.is_last_frame and index > -1:
self._save_tile(mode, index) self._save_tile(mode, index)
self.large_keyframes_tile_i = large_keyframes_tile_i self.large_keyframes_tile_i = large_keyframes_tile_i
self.cut_frames = [] self.cut_frames = []
self.log and self.profiler.unset_task() self.log and self.profiler.unset_task()