"Fossies" - the Fresh Open Source Software Archive

Member "photofilmstrip-3.7.0/photofilmstrip/core/Picture.py" (12 Nov 2018, 4836 Bytes) of package /linux/privat/photofilmstrip-3.7.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "Picture.py" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 3.5.1_vs_3.7.0.

    1 # -*- coding: utf-8 -*-
    2 #
    3 # PhotoFilmStrip - Creates movies out of your pictures.
    4 #
    5 # Copyright (C) 2008 Jens Goepfert
    6 #
    7 
    8 import logging
    9 
   10 from photofilmstrip.lib.common.ObserverPattern import Observable
   11 
   12 
   13 class Picture(Observable):
   14 
   15     EFFECT_NONE = 0
   16     EFFECT_BLACK_WHITE = 1
   17     EFFECT_SEPIA = 2
   18 
   19     TRANS_NONE = 0
   20     TRANS_FADE = 1
   21     TRANS_ROLL = 2
   22 
   23     MOVE_LINEAR = 0
   24     MOVE_ACCEL = 1
   25     MOVE_DELAYED = 2
   26 
   27     def __init__(self, filename):
   28         Observable.__init__(self)
   29         self._filename = filename
   30         self._startRect = (0, 0, 1280, 720)
   31         self._targetRect = (0, 0, 1280, 720)
   32         self._isDummy = False
   33 
   34         self._duration = 7.0
   35         self._movement = Picture.MOVE_ACCEL
   36         self._rotation = 0
   37         self._comment = u""
   38         self._effect = Picture.EFFECT_NONE
   39         self._width = -1
   40         self._height = -1
   41 
   42         self._trans = Picture.TRANS_FADE
   43         self._transDur = 1.0
   44 
   45     def Copy(self):
   46         clone = Picture(self._filename)
   47         clone.SetStartRect(self._startRect[:])
   48         clone.SetTargetRect(self._targetRect[:])
   49         clone.SetDummy(self._isDummy)
   50         clone.SetDuration(self._duration)
   51         clone.SetRotation(self._rotation)
   52         clone.SetComment(self._comment)
   53         clone.SetEffect(self._effect)
   54         clone.SetWidth(self._width)
   55         clone.SetHeight(self._height)
   56         clone.SetTransition(self._trans)
   57         clone.SetTransitionDuration(self._transDur)
   58         return clone
   59 
   60     def GetFilename(self):
   61         return self._filename
   62 
   63     def SetStartRect(self, rect):
   64         if rect == self._startRect or self._isDummy:
   65             return
   66         self._startRect = rect
   67         self.Notify("start")
   68 
   69     def GetStartRect(self):
   70         return self._startRect
   71 
   72     def SetTargetRect(self, rect):
   73         if rect == self._targetRect or self._isDummy:
   74             return
   75         self._targetRect = rect
   76         self.Notify("target")
   77 
   78     def GetTargetRect(self):
   79         return self._targetRect
   80 
   81     def SetDummy(self, isDummy):
   82         self._isDummy = isDummy
   83 
   84     def IsDummy(self):
   85         return self._isDummy
   86 
   87     def SetDuration(self, duration):
   88         if duration == self._duration:
   89             return
   90         self._duration = duration
   91         self.Notify("duration")
   92 
   93     def GetDuration(self):
   94         return self._duration
   95 
   96     def SetMovement(self, movement):
   97         if movement == self._movement:
   98             return
   99         self._movement = movement
  100         self.Notify("movement")
  101 
  102     def GetMovement(self):
  103         return self._movement
  104 
  105     def SetComment(self, comment):
  106         if comment == self._comment:
  107             return
  108         self._comment = comment
  109         self.Notify('comment')
  110 
  111     def GetComment(self):
  112         return self._comment
  113 
  114     def SetEffect(self, effect):
  115         if effect == self._effect:
  116             return
  117         self._effect = effect
  118         self.Notify('effect')
  119         self.Notify("bitmap")
  120 
  121     def GetEffect(self):
  122         return self._effect
  123 
  124     def SetRotation(self, rotation):
  125         for __ in range(abs(rotation)):
  126             self.__Rotate(rotation > 0)
  127         self.Notify("rotation")
  128 
  129     def GetRotation(self):
  130         return self._rotation
  131 
  132     def SetWidth(self, width):
  133         self._width = width
  134 
  135     def GetWidth(self):
  136         if self._width == -1:
  137             logging.debug("width not set yet!")
  138         return self._width
  139 
  140     def SetHeight(self, height):
  141         self._height = height
  142 
  143     def GetHeight(self):
  144         if self._height == -1:
  145             logging.debug("height not set yet!")
  146         return self._height
  147 
  148     def SetTransition(self, transition):
  149         if transition == self._trans:
  150             return
  151         self._trans = transition
  152         self.Notify('transition')
  153         self.Notify('duration')  # if set to no transition
  154 
  155     def GetTransition(self):
  156         return self._trans
  157 
  158     def SetTransitionDuration(self, transDur):
  159         if transDur == self._transDur:
  160             return
  161         self._transDur = transDur
  162         self.Notify('duration')
  163 
  164     def GetTransitionDuration(self, rawValue=False):
  165         if not rawValue and self._trans == Picture.TRANS_NONE:
  166             return 0.0
  167         return self._transDur
  168 
  169     def __Rotate(self, clockwise=True):
  170         if clockwise:
  171             self._rotation += 1
  172         else:
  173             self._rotation -= 1
  174         if self._rotation > 3:
  175             self._rotation = 0
  176         if self._rotation < -3:
  177             self._rotation = 0
  178 
  179         self._width, self._height = self._height, self._width
  180 
  181     def Rotate(self, clockwise=True):
  182         self.__Rotate(clockwise)
  183         self.Notify("bitmap")
  184 
  185     def GetKey(self):
  186         key = "%s:%s:%s" % (self.GetFilename(),
  187                             self.GetRotation(),
  188                             self.GetEffect())
  189         return key