forked from openlp/openlp
Renderer replacement started
This commit is contained in:
parent
1a2dfc863d
commit
02c0fe9e89
@ -165,12 +165,51 @@ def context_menu_separator(base):
|
|||||||
action.setSeparator(True)
|
action.setSeparator(True)
|
||||||
return action
|
return action
|
||||||
|
|
||||||
def resize_image(image, width, height):
|
def resize_image_for_web(image, width, height, background=QtCore.Qt.black):
|
||||||
|
"""
|
||||||
|
Resize an image to fit on the current screen for the web and retuns
|
||||||
|
it as a byte stream.
|
||||||
|
|
||||||
|
``image``
|
||||||
|
The image to resize.
|
||||||
|
``width``
|
||||||
|
The new image width.
|
||||||
|
``height``
|
||||||
|
The new image height.
|
||||||
|
``background ``
|
||||||
|
The background colour defaults to black.
|
||||||
|
"""
|
||||||
|
new_image = resize_image(image, width, height, background)
|
||||||
|
return image_to_byte(image)
|
||||||
|
|
||||||
|
def image_to_byte(image):
|
||||||
|
"""
|
||||||
|
Resize an image to fit on the current screen for the web and retuns
|
||||||
|
it as a byte stream.
|
||||||
|
|
||||||
|
``image``
|
||||||
|
The image to converted.
|
||||||
|
"""
|
||||||
|
byte_array = QtCore.QByteArray()
|
||||||
|
buffer = QtCore.QBuffer(byte_array) #// use buffer to store pixmap into byteArray
|
||||||
|
buffer.open(QtCore.QIODevice.WriteOnly)
|
||||||
|
pixmap = QtGui.QPixmap(image)
|
||||||
|
pixmap.save(buffer, "PNG")
|
||||||
|
#convert to base64 encoding so does not get missed!
|
||||||
|
return byte_array
|
||||||
|
|
||||||
|
def resize_image(image, width, height, background=QtCore.Qt.black):
|
||||||
"""
|
"""
|
||||||
Resize an image to fit on the current screen.
|
Resize an image to fit on the current screen.
|
||||||
|
|
||||||
``image``
|
``image``
|
||||||
The image to resize.
|
The image to resize.
|
||||||
|
``width``
|
||||||
|
The new image width.
|
||||||
|
``height``
|
||||||
|
The new image height.
|
||||||
|
``background ``
|
||||||
|
The background colour defaults to black.
|
||||||
"""
|
"""
|
||||||
preview = QtGui.QImage(image)
|
preview = QtGui.QImage(image)
|
||||||
if not preview.isNull():
|
if not preview.isNull():
|
||||||
@ -186,7 +225,7 @@ def resize_image(image, width, height):
|
|||||||
# and move it to the centre of the preview space
|
# and move it to the centre of the preview space
|
||||||
new_image = QtGui.QImage(width, height,
|
new_image = QtGui.QImage(width, height,
|
||||||
QtGui.QImage.Format_ARGB32_Premultiplied)
|
QtGui.QImage.Format_ARGB32_Premultiplied)
|
||||||
new_image.fill(QtCore.Qt.black)
|
new_image.fill(background)
|
||||||
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)
|
||||||
return new_image
|
return new_image
|
||||||
@ -215,6 +254,7 @@ from settingstab import SettingsTab
|
|||||||
from serviceitem import ServiceItem
|
from serviceitem import ServiceItem
|
||||||
from serviceitem import ServiceItemType
|
from serviceitem import ServiceItemType
|
||||||
from serviceitem import ItemCapabilities
|
from serviceitem import ItemCapabilities
|
||||||
|
from htmlbuilder import build_html
|
||||||
from toolbar import OpenLPToolbar
|
from toolbar import OpenLPToolbar
|
||||||
from dockwidget import OpenLPDockWidget
|
from dockwidget import OpenLPDockWidget
|
||||||
from theme import ThemeLevel, ThemeXML
|
from theme import ThemeLevel, ThemeXML
|
||||||
|
@ -167,21 +167,25 @@ class Renderer(object):
|
|||||||
shell = "<p>%s</p>"
|
shell = "<p>%s</p>"
|
||||||
temp_text = u''
|
temp_text = u''
|
||||||
old_html_text = u''
|
old_html_text = u''
|
||||||
|
page = []
|
||||||
for line in text:
|
for line in text:
|
||||||
#do we need a <br> here?
|
# mark line ends
|
||||||
temp_text = temp_text + line
|
temp_text = temp_text + line + u'<br>'
|
||||||
html_text = shell % temp_text
|
html_text = shell % temp_text
|
||||||
doc.setHtml(html_text)
|
doc.setHtml(html_text)
|
||||||
|
#Text too long so gone to next mage
|
||||||
if layout.pageCount() != 1:
|
if layout.pageCount() != 1:
|
||||||
formatted.append(old_html_text)
|
page.append(shell % old_html_text)
|
||||||
|
formatted.append(page)
|
||||||
temp_text = line
|
temp_text = line
|
||||||
old_html_text = temp_text
|
old_html_text = temp_text
|
||||||
formatted.append(old_html_text)
|
page.append(shell % old_html_text)
|
||||||
for f in formatted:
|
formatted.append(page)
|
||||||
print "f", f
|
print "ft", formatted
|
||||||
print "st", split_text
|
print "st", split_text
|
||||||
log.debug(u'format_slide - End')
|
log.debug(u'format_slide - End')
|
||||||
return split_text
|
#return split_text
|
||||||
|
return formatted
|
||||||
|
|
||||||
def pre_render_text(self, text):
|
def pre_render_text(self, text):
|
||||||
metrics = QtGui.QFontMetrics(self.main_font)
|
metrics = QtGui.QFontMetrics(self.main_font)
|
||||||
|
@ -40,8 +40,6 @@ from slidecontroller import HideMode
|
|||||||
from servicenoteform import ServiceNoteForm
|
from servicenoteform import ServiceNoteForm
|
||||||
from serviceitemeditform import ServiceItemEditForm
|
from serviceitemeditform import ServiceItemEditForm
|
||||||
from screen import ScreenList
|
from screen import ScreenList
|
||||||
from maindisplay import MainDisplay
|
|
||||||
from maindisplay import VideoDisplay
|
|
||||||
from maindisplay import DisplayManager
|
from maindisplay import DisplayManager
|
||||||
from amendthemeform import AmendThemeForm
|
from amendthemeform import AmendThemeForm
|
||||||
from slidecontroller import SlideController
|
from slidecontroller import SlideController
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user