mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
QbyteArray().data() is always bytes and does not need to be cast to it
a dbus.ByteArray() can simply be initialized from the QByteArray directly.
This commit is contained in:
parent
d0a30b1f84
commit
96c71e7ae4
@ -67,7 +67,7 @@ class HTMLRenderer(object):
|
|||||||
buf = QBuffer(ba)
|
buf = QBuffer(ba)
|
||||||
buf.open(QBuffer.WriteOnly)
|
buf.open(QBuffer.WriteOnly)
|
||||||
image.save(buf, 'JPEG')
|
image.save(buf, 'JPEG')
|
||||||
self.data = bytes(ba.data())
|
self.data = ba.data()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.exception = e
|
self.exception = e
|
||||||
self.traceback = traceback.format_exc()
|
self.traceback = traceback.format_exc()
|
||||||
|
@ -464,7 +464,7 @@ class PDFStream(object):
|
|||||||
ba = QByteArray()
|
ba = QByteArray()
|
||||||
buf = QBuffer(ba)
|
buf = QBuffer(ba)
|
||||||
image.save(buf, 'jpeg', 94)
|
image.save(buf, 'jpeg', 94)
|
||||||
data = bytes(ba.data())
|
data = ba.data()
|
||||||
|
|
||||||
if has_alpha:
|
if has_alpha:
|
||||||
soft_mask = self.write_image(tmask, w, h, 8)
|
soft_mask = self.write_image(tmask, w, h, 8)
|
||||||
|
@ -687,7 +687,7 @@ def pixmap_to_data(pixmap, format='JPEG', quality=None):
|
|||||||
buf = QBuffer(ba)
|
buf = QBuffer(ba)
|
||||||
buf.open(QBuffer.WriteOnly)
|
buf.open(QBuffer.WriteOnly)
|
||||||
pixmap.save(buf, format, quality=quality)
|
pixmap.save(buf, format, quality=quality)
|
||||||
return bytes(ba.data())
|
return ba.data()
|
||||||
|
|
||||||
|
|
||||||
def decouple(prefix):
|
def decouple(prefix):
|
||||||
|
@ -128,7 +128,7 @@ def icon_to_dbus_menu_icon(icon, size=32):
|
|||||||
buf = QBuffer(ba)
|
buf = QBuffer(ba)
|
||||||
buf.open(QBuffer.WriteOnly)
|
buf.open(QBuffer.WriteOnly)
|
||||||
icon.pixmap(32).save(buf, 'PNG')
|
icon.pixmap(32).save(buf, 'PNG')
|
||||||
return dbus.ByteArray(bytes((ba.data())))
|
return dbus.ByteArray(ba)
|
||||||
|
|
||||||
|
|
||||||
def setup_for_cli_run():
|
def setup_for_cli_run():
|
||||||
|
@ -76,7 +76,7 @@ def image_to_data(image): # {{{
|
|||||||
buf.open(QBuffer.WriteOnly)
|
buf.open(QBuffer.WriteOnly)
|
||||||
if not image.save(buf, CACHE_FORMAT):
|
if not image.save(buf, CACHE_FORMAT):
|
||||||
raise EncodeError('Failed to encode thumbnail')
|
raise EncodeError('Failed to encode thumbnail')
|
||||||
ret = bytes(ba.data())
|
ret = ba.data()
|
||||||
buf.close()
|
buf.close()
|
||||||
return ret
|
return ret
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -68,4 +68,4 @@ def to_png(bmp):
|
|||||||
buf = QBuffer(ba)
|
buf = QBuffer(ba)
|
||||||
buf.open(QBuffer.WriteOnly)
|
buf.open(QBuffer.WriteOnly)
|
||||||
i.save(buf, 'png')
|
i.save(buf, 'png')
|
||||||
return bytes(ba.data())
|
return ba.data()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user