Update of /cvsroot/freevo/freevo/src/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1136
Modified Files:
imagelib.py
Log Message:
load thumbnails in the background
Index: imagelib.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/gui/imagelib.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** imagelib.py 10 Apr 2005 18:00:19 -0000 1.12
--- imagelib.py 1 May 2005 17:39:40 -0000 1.13
***************
*** 51,57 ****
log = logging.getLogger('gui')
- # internal imagecache
- _item_imagecache = util.objectcache.ObjectCache(30, desc='item_image')
-
def _resize(image, width=None, height=None):
"""
--- 51,54 ----
***************
*** 82,92 ****
! def load(url, size=None, cache=False, vfs_save=False):
"""
Load a bitmap and return the image object.
If width and height are given, the image is scaled to that. Setting
only width or height will keep aspect ratio.
- If vfs_save is true, the so scaled bitmap will be stored in the vfs for
- future use.
"""
if size == None:
--- 79,87 ----
! def load(url, size=None, cache=False):
"""
Load a bitmap and return the image object.
If width and height are given, the image is scaled to that. Setting
only width or height will keep aspect ratio.
"""
if size == None:
***************
*** 124,147 ****
return s
- if vfs_save and (width == None or height == None):
- vfs_save = False
-
# not in cache, load it
filename = os.path.abspath(url)
- if vfs_save:
- vfs_save = vfs.getoverlay('%s.raw-%sx%s' % (filename, width, height))
- try:
- if os.stat(vfs_save)[stat.ST_MTIME] > \
- os.stat(filename)[stat.ST_MTIME]:
- f = open(vfs_save, 'r')
- image = mevas.imagelib.new((width, height), f.read(), 'RGBA')
- f.close()
- if cache:
- cache[key] = image
- return image
- except:
- pass
-
if not os.path.isfile(filename):
filename = os.path.join(config.IMAGE_DIR, url[8:])
--- 119,125 ----
***************
*** 167,175 ****
image = _resize(image, width, height)
- if vfs_save:
- f = vfs.open(vfs_save, 'w')
- f.write(image.get_raw_data('RGBA'))
- f.close()
-
if cache:
cache[key] = image
--- 145,148 ----
***************
*** 178,189 ****
! def item_image(item, size, icon_dir, force=False, cache=True, bg=False):
"""
Return the image for an item. This function uses internal caches and
can also return a mimetype image if no image is found and force is True
"""
- if cache == True:
- cache = _item_imagecache
-
width, height = size
try:
--- 151,160 ----
! def item_image(item, size, icon_dir, force=False, cache=True, bg=False,
callback=None):
"""
Return the image for an item. This function uses internal caches and
can also return a mimetype image if no image is found and force is True
+ Return: image object, cache key, forced
"""
width, height = size
try:
***************
*** 207,214 ****
image = cache[key]
!
if image:
! return image
!
image = None
imagefile = None
--- 178,187 ----
image = cache[key]
!
if image:
! return image, key, False
! else:
! key = ''
!
image = None
imagefile = None
***************
*** 217,234 ****
try:
# load the thumbnail
! image = util.thumbnail.load(item.image, bg)
except:
# maybe image is something else (like already an image object)
image = load(item.image)
!
if image:
if item['rotation']:
image.rotate(item['rotation'])
else:
if not force:
! return None
- item.image = None
-
if hasattr(item, 'media') and item.media and \
item.media.item == item and \
--- 190,206 ----
try:
# load the thumbnail
! image = util.thumbnail.load(item.image, bg, callback)
except:
# maybe image is something else (like already an image object)
image = load(item.image)
!
if image:
if item['rotation']:
image.rotate(item['rotation'])
+ force = False
else:
if not force:
! return None, key, False
if hasattr(item, 'media') and item.media and \
item.media.item == item and \
***************
*** 271,275 ****
if not imagefile:
! return None
# load the thumbnail
--- 243,247 ----
if not imagefile:
! return None, key, True
# load the thumbnail
***************
*** 277,281 ****
if not image:
! return None
if type and len(type) > 4:
--- 249,253 ----
if not image:
! return None, key, True
if type and len(type) > 4:
***************
*** 305,307 ****
if isinstance(item.image, (str, unicode)) and item.image:
cache[key] = image
! return image
--- 277,279 ----
if isinstance(item.image, (str, unicode)) and item.image:
cache[key] = image
! return image, key, force
-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4
opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog