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