forked from openlp/openlp
Path image improvements
This commit is contained in:
parent
4f04bba5e6
commit
cef92476ad
@ -223,16 +223,20 @@ def image_to_byte(image):
|
||||
``image``
|
||||
The image to converted.
|
||||
"""
|
||||
log.debug(u'image_to_byte')
|
||||
log.debug(u'image_to_byte - start')
|
||||
byte_array = QtCore.QByteArray()
|
||||
# use buffer to store pixmap into byteArray
|
||||
buffie = QtCore.QBuffer(byte_array)
|
||||
buffie.open(QtCore.QIODevice.WriteOnly)
|
||||
if isinstance(image, QtGui.QImage):
|
||||
pixmap = QtGui.QPixmap.fromImage(image)
|
||||
else:
|
||||
pixmap = QtGui.QPixmap(image)
|
||||
pixmap.save(buffie, "PNG")
|
||||
# if isinstance(image, QtGui.QImage):
|
||||
# log.debug(u'image_to_byte - image')
|
||||
# #pixmap = QtGui.QPixmap.fromImage(image)
|
||||
# pixmap = image
|
||||
# else:
|
||||
# log.debug(u'image_to_byte - pixmap')
|
||||
# pixmap = QtGui.QPixmap(image)
|
||||
image.save(buffie, "PNG")
|
||||
log.debug(u'image_to_byte - end')
|
||||
# convert to base64 encoding so does not get missed!
|
||||
return byte_array.toBase64()
|
||||
|
||||
@ -253,7 +257,10 @@ def resize_image(image, width, height, background=QtCore.Qt.black):
|
||||
The background colour defaults to black.
|
||||
|
||||
"""
|
||||
log.debug(u'resize_image')
|
||||
log.debug(u'resize_image - start')
|
||||
if isinstance(image, QtGui.QImage):
|
||||
preview = image
|
||||
else:
|
||||
preview = QtGui.QImage(image)
|
||||
if not preview.isNull():
|
||||
# Only resize if different size
|
||||
@ -263,6 +270,7 @@ def resize_image(image, width, height, background=QtCore.Qt.black):
|
||||
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()
|
||||
@ -273,6 +281,7 @@ def resize_image(image, width, height, background=QtCore.Qt.black):
|
||||
painter = QtGui.QPainter(new_image)
|
||||
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):
|
||||
|
@ -184,7 +184,7 @@ class MainDisplay(DisplayWidget):
|
||||
`slide`
|
||||
The slide text to be displayed
|
||||
"""
|
||||
log.debug(u'text')
|
||||
log.debug(u'text to display')
|
||||
# Wait for the webview to update before displayiong text.
|
||||
while not self.loaded:
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
@ -199,7 +199,7 @@ class MainDisplay(DisplayWidget):
|
||||
`slide`
|
||||
The slide text to be displayed
|
||||
"""
|
||||
log.debug(u'alert')
|
||||
log.debug(u'alert to display')
|
||||
if self.height() != self.screen[u'size'].height() \
|
||||
or not self.isVisible() or self.videoWidget.isVisible():
|
||||
shrink = True
|
||||
@ -230,7 +230,7 @@ class MainDisplay(DisplayWidget):
|
||||
`Image`
|
||||
The Image to be displayed can be QImage or QPixmap
|
||||
"""
|
||||
log.debug(u'image')
|
||||
log.debug(u'image to display')
|
||||
image = resize_image(image, self.screen[u'size'].width(),
|
||||
self.screen[u'size'].height())
|
||||
self.resetVideo()
|
||||
|
@ -584,11 +584,11 @@ class SlideController(QtGui.QWidget):
|
||||
else:
|
||||
label = QtGui.QLabel()
|
||||
label.setMargin(4)
|
||||
pixmap = resize_image(frame[u'image'],
|
||||
self.parent.RenderManager.width,
|
||||
self.parent.RenderManager.height)
|
||||
# pixmap = resize_image(frame[u'image'],
|
||||
# self.parent.RenderManager.width,
|
||||
# self.parent.RenderManager.height)
|
||||
label.setScaledContents(True)
|
||||
label.setPixmap(QtGui.QPixmap.fromImage(pixmap))
|
||||
label.setPixmap(QtGui.QPixmap.fromImage(frame[u'image']))
|
||||
self.PreviewListWidget.setCellWidget(framenumber, 0, label)
|
||||
slideHeight = width * self.parent.RenderManager.screen_ratio
|
||||
row += 1
|
||||
|
Loading…
Reference in New Issue
Block a user