← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/images into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/images into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)


Fix Image border for small images
Fix Image saving bug
-- 
https://code.launchpad.net/~trb143/openlp/images/+merge/39399
Your team OpenLP Core is requested to review the proposed merge of lp:~trb143/openlp/images into lp:openlp.
=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py	2010-10-22 17:24:56 +0000
+++ openlp/core/lib/__init__.py	2010-10-26 19:28:45 +0000
@@ -81,9 +81,6 @@
     u'start html':u'<em>', u'end tag':u'{/it}', u'end html':u'</em>',
     u'protected':True})
 
-# Image image_cache to stop regualar image resizing
-image_cache = {}
-
 def translate(context, text, comment=None):
     """
     A special shortcut method to wrap around the Qt4 translation functions.
@@ -261,20 +258,14 @@
             return preview
         preview = preview.scaled(width, height, QtCore.Qt.KeepAspectRatio,
             QtCore.Qt.SmoothTransformation)
-    image_cache_key = u'%s%s%s' % (image, unicode(width), unicode(height))
-    if image_cache_key in image_cache:
-        log.debug(u'resize_image - end cache')
-        return image_cache[image_cache_key]
     realw = preview.width()
     realh = preview.height()
     # and move it to the centre of the preview space
     new_image = QtGui.QImage(width, height,
         QtGui.QImage.Format_ARGB32_Premultiplied)
-    new_image.fill(background)
     painter = QtGui.QPainter(new_image)
+    painter.fillRect(new_image.rect(), background)
     painter.drawImage((width - realw) / 2, (height - realh) / 2, preview)
-    image_cache[image_cache_key] = new_image
-    log.debug(u'resize_image - end')
     return new_image
 
 def check_item_selected(list_widget, message):

=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py	2010-10-24 11:00:20 +0000
+++ openlp/core/ui/servicemanager.py	2010-10-26 19:28:45 +0000
@@ -650,9 +650,12 @@
                         .get_service_repr()})
                     if item[u'service_item'].uses_file():
                         for frame in item[u'service_item'].get_frames():
-                            path_from = unicode(os.path.join(
-                                frame[u'path'],
-                                frame[u'title']))
+                            if item[u'service_item'].is_image():
+                                path_from = frame[u'path']
+                            else:
+                                path_from = unicode(os.path.join(
+                                    frame[u'path'],
+                                    frame[u'title']))
                             # On write a file once
                             if not path_from in write_list:
                                 write_list.append(path_from)


Follow ups