Changed QPixmaps to QImages to see the difference.

This commit is contained in:
Raoul Snyman 2009-06-10 17:37:33 +02:00
parent 296a573007
commit a8307e430b
7 changed files with 30 additions and 26 deletions

View File

@ -70,19 +70,21 @@ class Renderer:
def scale_bg_image(self):
assert self._frame
preview = QtGui.QPixmap(self._bg_image_filename)
preview = QtGui.QImage(self._bg_image_filename)
width = self._frame.width()
height = self._frame.height()
preview = preview.scaled(width, height, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)
realwidth = preview.width()
realheight = preview.height()
# and move it to the centre of the preview space
self.bg_image = QtGui.QPixmap(width, height)
self.bg_image.fill(QtCore.Qt.transparent)
painter = QtGui.QPainter(self.bg_image)
self.bg_image = QtGui.QImage(width, height, QtGui.QImage.Format_ARGB32_Premultiplied)
self.bg_image.fill(QtCore.Qt.black)
painter = QtGui.QPainter()
painter.begin(self.bg_image)
self.background_offsetx = (width - realwidth) / 2
self.background_offsety = (height - realheight) / 2
painter.drawPixmap(self.background_offsetx, self.background_offsety , preview)
painter.drawImage(self.background_offsetx, self.background_offsety, preview)
painter.end()
def set_frame_dest(self, frame_width, frame_height, preview=False):
"""
@ -91,7 +93,8 @@ class Renderer:
if preview == True:
self._bg_frame = None
log.debug(u'set frame dest (frame) w %d h %d', frame_width, frame_height)
self._frame = QtGui.QPixmap(frame_width, frame_height)
self._frame = QtGui.QImage(frame_width, frame_height,
QtGui.QImage.Format_ARGB32_Premultiplied)
if self._bg_image_filename is not None:
self.scale_bg_image()
if self._bg_frame is None:
@ -134,7 +137,7 @@ class Renderer:
if footer_lines is not None:
bbox1 = self._render_lines_unaligned(footer_lines, True)
# reset the frame. first time do not worrk about what you paint on.
self._frame = QtGui.QPixmap(self._bg_frame)
self._frame = QtGui.QImage(self._bg_frame)
x, y = self._correctAlignment(self._rect, bbox)
bbox = self._render_lines_unaligned(lines, False, (x, y))
if footer_lines is not None:
@ -147,7 +150,8 @@ class Renderer:
Results cached for performance reasons.
"""
assert(self._theme)
self._bg_frame = QtGui.QPixmap(self._frame.width(), self._frame.height())
self._bg_frame = QtGui.QImage(self._frame.width(), self._frame.height(),
QtGui.QImage.Format_ARGB32_Premultiplied)
log.debug(u'render background %s ', self._theme.background_type)
painter = QtGui.QPainter()
painter.begin(self._bg_frame)
@ -178,10 +182,9 @@ class Renderer:
rectPath.closeSubpath()
painter.drawPath(rectPath)
elif self._theme.background_type== u'image': # image
painter.fillRect(self._frame.rect(), QtCore.Qt.black)
if self.bg_image is not None:
painter.drawPixmap(0 ,0 , self.bg_image)
else:
painter.fillRect(self._frame.rect(), QtGui.QColor(u'#000000'))
painter.drawImage(0 ,0 , self.bg_image)
painter.end()
def _split_set_of_lines(self, lines, footer):

View File

@ -526,4 +526,4 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
def previewTheme(self, theme):
if self.allowPreview:
frame = self.thememanager.generateImage(theme)
self.ThemePreview.setPixmap(frame)
self.ThemePreview.setPixmap(QtGui.QPixmap.fromImage(frame))

View File

@ -62,15 +62,16 @@ class MainDisplay(QtGui.QWidget):
else:
self.showMinimized()
painter = QtGui.QPainter()
self.blankFrame = QtGui.QPixmap(screen[u'size'].width(), screen[u'size'].height())
self.blankFrame = QtGui.QImage(screen[u'size'].width(),
screen[u'size'].height(), QtGui.QImage.Format_ARGB32_Premultiplied)
painter.begin(self.blankFrame)
painter.fillRect(self.blankFrame.rect(), QtGui.QColor(u'#000000'))
painter.fillRect(self.blankFrame.rect(), QtCore.Qt.black)
self.frameView(self.blankFrame)
def frameView(self, frame):
self.frame = frame
if not self.displayBlank:
self.display.setPixmap(frame)
self.display.setPixmap(QtGui.QPixmap.fromImage(frame))
elif self.alertactive:
self.displayAlert()

View File

@ -280,7 +280,7 @@ class SlideController(QtGui.QWidget):
"""
Generates a preview of the current slide.
"""
self.SlidePreview.setPixmap(frame[0])
self.SlidePreview.setPixmap(QtGui.QPixmap.fromImage(frame[0]))
if self.isLive:
no = frame[1]
LiveFrame = self.serviceitem.frames[no][u'image']

View File

@ -63,22 +63,22 @@ class ThemeData(QtCore.QAbstractListModel):
theme = shortfilename.split(u'.')
# create a preview image
if os.path.exists(filename):
preview = QtGui.QPixmap(str(filename))
preview = QtGui.QImage(str(filename))
width = self.maximagewidth
height = self.rowheight
preview = preview.scaled(width, height, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)
realwidth = preview.width()
realheight = preview.height()
# and move it to the centre of the preview space
pixmap = QtGui.QPixmap(width, height)
pixmap.fill(QtCore.Qt.transparent)
pixmap = QtGui.QImage(width, height, QtGui.QImage.Format_ARGB32_Premultiplied)
pixmap.fill(QtCore.Qt.black)
painter = QtGui.QPainter(pixmap)
painter.drawPixmap((width - realwidth) / 2, (height - realheight) / 2, preview)
painter.drawImage((width - realwidth) / 2, (height - realheight) / 2, preview)
else:
width = self.maximagewidth
height = self.rowheight
pixmap = QtGui.QtGui.QPixmap(width, height)
pixmap.fill(QtCore.Qt.transparent)
pixmap = QtGui.QImage(width, height, QtGui.QImage.Format_ARGB32_Premultiplied)
pixmap.fill(QtCore.Qt.black)
# finally create the row
self.items.insert(row, (filename, pixmap, shortfilename, theme[0]))
log.info(u'Items: %s' % self.items)
@ -347,11 +347,11 @@ class ThemeManager(QtGui.QWidget):
theme.parse(theme_xml)
theme.extend_image_filename(dir)
frame = self.generateImage(theme)
im = frame.toImage()
#im = frame.toImage()
samplepathname = os.path.join(self.path, name + u'.png')
if os.path.exists(samplepathname):
os.unlink(samplepathname)
im.save(samplepathname, u'png')
frame.save(samplepathname, u'png')
log.debug(u'Theme image written to %s', samplepathname)
def generateImage(self, themedata):

View File

@ -67,7 +67,7 @@ class SongManager():
"""
Returns the details of a song
"""
return self.session.query(Song).order_by(title).all()
return self.session.query(Song).order_by(Song.title).all()
def search_song_title(self, keywords):
"""

View File

@ -105,7 +105,7 @@ class SongsPlugin(Plugin):
QtCore.QObject.connect(self.ExportOpenSongItem, QtCore.SIGNAL("triggered()"), self.onExportOpenSongItemClicked)
def initialise(self):
pass
self.media_item.displayResults(self.songmanager.get_songs())
def onImportOpenlp1ItemClick(self):
self.openlp_import_form.show()