mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge branch 'master' of github.com:kovidgoyal/calibre
This commit is contained in:
commit
66b1686732
@ -738,14 +738,14 @@ def choose_images(window, name, title, select_only_single_file=True,
|
|||||||
return fd.get_files()
|
return fd.get_files()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def pixmap_to_data(pixmap, format='JPEG'):
|
def pixmap_to_data(pixmap, format='JPEG', quality=90):
|
||||||
'''
|
'''
|
||||||
Return the QPixmap pixmap as a string saved in the specified format.
|
Return the QPixmap pixmap as a string saved in the specified format.
|
||||||
'''
|
'''
|
||||||
ba = QByteArray()
|
ba = QByteArray()
|
||||||
buf = QBuffer(ba)
|
buf = QBuffer(ba)
|
||||||
buf.open(QBuffer.WriteOnly)
|
buf.open(QBuffer.WriteOnly)
|
||||||
pixmap.save(buf, format)
|
pixmap.save(buf, format, quality=quality)
|
||||||
return bytes(ba.data())
|
return bytes(ba.data())
|
||||||
|
|
||||||
class ResizableDialog(QDialog):
|
class ResizableDialog(QDialog):
|
||||||
|
@ -236,7 +236,7 @@ class ImageDropMixin(object): # {{{
|
|||||||
|
|
||||||
def handle_image_drop(self, pmap):
|
def handle_image_drop(self, pmap):
|
||||||
self.set_pixmap(pmap)
|
self.set_pixmap(pmap)
|
||||||
self.cover_changed.emit(pixmap_to_data(pmap))
|
self.cover_changed.emit(pixmap_to_data(pmap, quality=100))
|
||||||
|
|
||||||
def dragMoveEvent(self, event):
|
def dragMoveEvent(self, event):
|
||||||
event.acceptProposedAction()
|
event.acceptProposedAction()
|
||||||
@ -268,7 +268,7 @@ class ImageDropMixin(object): # {{{
|
|||||||
if not pmap.isNull():
|
if not pmap.isNull():
|
||||||
self.set_pixmap(pmap)
|
self.set_pixmap(pmap)
|
||||||
self.cover_changed.emit(
|
self.cover_changed.emit(
|
||||||
pixmap_to_data(pmap))
|
pixmap_to_data(pmap, quality=100))
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
class ImageView(QWidget, ImageDropMixin): # {{{
|
class ImageView(QWidget, ImageDropMixin): # {{{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user