1
0
mirror of https://github.com/thp/pyotherside.git synced 2025-01-17 23:22:53 +08:00
pyotherside/examples/imageprovider_data.py
2014-02-06 21:31:24 +01:00

55 lines
2.7 KiB
Python

#
# PyOtherSide: Asynchronous Python 3 Bindings for Qt 5
# Copyright (c) 2011, 2013, Thomas Perl <m@thp.io>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
#
import pyotherside
import os
import base64
# base64-encoded image data (PNG)
IMAGE_DATA = b"""
iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAMAAADVRocKAAABRFBMVEX////C0d5+pcZklb1JhbZD
g7ZDf7JQhbBkkbV9ob/X3uOdutFDhbs4gr44fLU3ea83dqtkjrI4f7o3c6VCc6VJiLtEicDN3+73
9/+CrdFwlrWbv9329fU8cp6Cr9Q2bZybvdo3apRakb/v7+//7WD/5ln44W5/qMr/617/41T51ls4
hcP/20z12oL7zkewx9n/1UTx5cNyoMVQfKH16Mb/4FL/0ED12Y1Sjb341Wj4zVd/nrjx7Nr/zDv7
yED71U/8xTmAo8DG1OD/2En/xTJDeafc4ef145j64mL7wDf15qb/vCn5wkSApsb3zXTz8vJCfa76
vkCQr8n/tSH22Jf5wEmhus9Jf6z/zVf/4Jf/1nv/9+X/03b9vi7/+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tMDRUMDM6NTk6MzQrMDA6MDDJQvVEAAAA
AElFTkSuQmCC
"""
def load_data(image_id, requested_size):
# If you return data in the format "pyotherside.format_data", the size is
# ignored; the data is interpreted as image file data (e.g. PNG, jpeg, ..)
return bytearray(base64.b64decode(IMAGE_DATA)), (-1, -1), pyotherside.format_data
pyotherside.set_image_provider(load_data)