本文整理汇总了Python中PIL.ImageQt.ImageQt方法的典型用法代码示例。如果您正苦于以下问题:Python ImageQt.ImageQt方法的具体用法?Python ImageQt.ImageQt怎么用?Python ImageQt.ImageQt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PIL.ImageQt
的用法示例。
在下文中一共展示了ImageQt.ImageQt方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_map
# 需要导入模块: from PIL import ImageQt [as 别名]
# 或者: from PIL.ImageQt import ImageQt [as 别名]
def load_map(self, lat0=42, lat1=-1, lon0=55, lon1=3, zoom=3):
"""
Load a map image into the widget
:param lat0:
:param lat1:
:param lon0:
:param lon1:
:param zoom: 1~14
"""
# store coordinates
self.lat0 = lat0
self.lat1 = lat1
self.lon0 = lon0
self.lon1 = lon1
self.zoom = zoom
# get map
map = smopy.Map((lat0, lat1, lon0, lon1), z=zoom)
w, h = map.img.size
self.img = ImageQt(map.img)
self.image = QPixmap.fromImage(self.img)
# resize widget
self.setRect(0.0, 0.0, w, h)
示例2: test_sanity
# 需要导入模块: from PIL import ImageQt [as 别名]
# 或者: from PIL.ImageQt import ImageQt [as 别名]
def test_sanity(self):
for mode in ('RGB', 'RGBA', 'L', 'P', '1'):
src = hopper(mode)
data = ImageQt.toqimage(src)
self.assertIsInstance(data, QImage)
self.assertFalse(data.isNull())
# reload directly from the qimage
rt = ImageQt.fromqimage(data)
if mode in ('L', 'P', '1'):
self.assert_image_equal(rt, src.convert('RGB'))
else:
self.assert_image_equal(rt, src)
if mode == '1':
# BW appears to not save correctly on QT4 and QT5
# kicks out errors on console:
# libpng warning: Invalid color type/bit depth combination
# in IHDR
# libpng error: Invalid IHDR data
continue
# Test saving the file
tempfile = self.tempfile('temp_{}.png'.format(mode))
data.save(tempfile)
# Check that it actually worked.
reloaded = Image.open(tempfile)
# Gray images appear to come back in palette mode.
# They're roughly equivalent
if QT_VERSION == 4 and mode == 'L':
src = src.convert('P')
self.assert_image_equal(reloaded, src)
示例3: __init__
# 需要导入模块: from PIL import ImageQt [as 别名]
# 或者: from PIL.ImageQt import ImageQt [as 别名]
def __init__(self):
super(Example, self).__init__()
img = hopper().resize((1000, 1000))
qimage = ImageQt.ImageQt(img)
pixmap1 = QtGui.QPixmap.fromImage(qimage)
QHBoxLayout(self) # hbox
lbl = QLabel(self)
# Segfault in the problem
lbl.setPixmap(pixmap1.copy())
示例4: setUp
# 需要导入模块: from PIL import ImageQt [as 别名]
# 或者: from PIL.ImageQt import ImageQt [as 别名]
def setUp(self):
PillowQtTestCase.setUp(self)
try:
if ImageQt.qt_version == '5':
from PyQt5.QtGui import QGuiApplication
elif ImageQt.qt_version == '4':
from PyQt4.QtGui import QGuiApplication
elif ImageQt.qt_version == 'side':
from PySide.QtGui import QGuiApplication
elif ImageQt.qt_version == 'side2':
from PySide2.QtGui import QGuiApplication
except ImportError:
self.skipTest('QGuiApplication not installed')
self.app = QGuiApplication([])
示例5: test_rgb
# 需要导入模块: from PIL import ImageQt [as 别名]
# 或者: from PIL.ImageQt import ImageQt [as 别名]
def test_rgb(self):
# from https://doc.qt.io/archives/qt-4.8/qcolor.html
# typedef QRgb
# An ARGB quadruplet on the format #AARRGGBB,
# equivalent to an unsigned int.
if ImageQt.qt_version == '5':
from PyQt5.QtGui import qRgb
elif ImageQt.qt_version == '4':
from PyQt4.QtGui import qRgb
elif ImageQt.qt_version == 'side':
from PySide.QtGui import qRgb
elif ImageQt.qt_version == 'side2':
from PySide2.QtGui import qRgb
self.assertEqual(qRgb(0, 0, 0), qRgba(0, 0, 0, 255))
def checkrgb(r, g, b):
val = ImageQt.rgb(r, g, b)
val = val % 2**24 # drop the alpha
self.assertEqual(val >> 16, r)
self.assertEqual(((val >> 8) % 2**8), g)
self.assertEqual(val % 2**8, b)
checkrgb(0, 0, 0)
checkrgb(255, 0, 0)
checkrgb(0, 255, 0)
checkrgb(0, 0, 255)
示例6: test_image
# 需要导入模块: from PIL import ImageQt [as 别名]
# 或者: from PIL.ImageQt import ImageQt [as 别名]
def test_image(self):
for mode in ('1', 'RGB', 'RGBA', 'L', 'P'):
ImageQt.ImageQt(hopper(mode))
示例7: paintEvent
# 需要导入模块: from PIL import ImageQt [as 别名]
# 或者: from PIL.ImageQt import ImageQt [as 别名]
def paintEvent(self, event):
imageqt = ImageQt.ImageQt(self.display_image)
p = QtGui.QPainter()
p.begin(self)
p.setRenderHint(QtGui.QPainter.Antialiasing, True);
scale = self.height() / float(imageqt.height() + 10)
p.scale(scale, scale)
p.translate((self.width() / 2 / scale - imageqt.width() / 2),
(self.height() / 2 / scale - imageqt.height() / 2))
p.fillRect(0, 0, imageqt.width(), imageqt.height(), QtGui.QColor(0, 0, 0))
p.drawImage(0, 0, imageqt)
NODE_RADIUS = 4
# draw nodes
for loop in self.snake.loops:
for i in range(len(loop.nodes)):
p.setPen(QtGui.QColor(255, 0, 0))
p.setBrush(QtGui.QBrush(QtGui.QColor(255, 0, 0)))
p.drawEllipse(loop.nodes[i][1] - NODE_RADIUS / 2.0,
loop.nodes[i][0] - NODE_RADIUS / 2.0, NODE_RADIUS, NODE_RADIUS)
# draw lines between nodes
for loop in self.snake.loops:
for i in range(len(loop.nodes)):
if len(loop.nodes) > 1:
n = i+1
if n == len(loop.nodes):
n = 0
p.setPen(QtGui.QColor(0, 255, 0))
p.drawLine(loop.nodes[i][1], loop.nodes[i][0], loop.nodes[n][1], loop.nodes[n][0])
p.end()
示例8: updateCountdown
# 需要导入模块: from PIL import ImageQt [as 别名]
# 或者: from PIL.ImageQt import ImageQt [as 别名]
def updateCountdown(self, event):
picture = Image.open(event.picture)
self._gui.centralWidget().picture = ImageQt.ImageQt(picture)
self._gui.centralWidget().update()
示例9: showReview
# 需要导入模块: from PIL import ImageQt [as 别名]
# 或者: from PIL.ImageQt import ImageQt [as 别名]
def showReview(self, state):
picture = Image.open(state.picture)
self._picture = ImageQt.ImageQt(picture)
review_time = self._cfg.getInt('Photobooth', 'display_time') * 1000
self._setWidget(Frames.PictureMessage(self._picture))
QtCore.QTimer.singleShot(
review_time,
lambda: self._comm.send(Workers.MASTER, GuiEvent('postprocess')))
self._postprocess.do(self._picture)
示例10: print
# 需要导入模块: from PIL import ImageQt [as 别名]
# 或者: from PIL.ImageQt import ImageQt [as 别名]
def print(self, picture):
if self._conn is not None:
if isinstance(picture, ImageQt.ImageQt):
picture.save(self._tmp_filename)
else:
picture.save(self._tmp_filename, format='JPEG')
self._conn.printFile(self._printer, self._tmp_filename,
"photobooth", {})
示例11: updateLabelToClusterShowImage
# 需要导入模块: from PIL import ImageQt [as 别名]
# 或者: from PIL.ImageQt import ImageQt [as 别名]
def updateLabelToClusterShowImage(displayLabel, filename, width=240, height=240):
# Compute cluster memberships
compactness = int(COMPACTNESS_SETTING_OPTIONS[SELECTED_COMPACTNESS_SETTING_INDEX])
n = int(CLUSTER_SETTING_OPTIONS[SELECTED_CLUSTER_SETTING_INDEX])
spectral_roi.spectral_cluster(filename, CLUSTER_IMAGE_FILENAME, compactness, n)
# Display result
picture = Image.open(CLUSTER_IMAGE_FILENAME)
picture.thumbnail((width,height), Image.ANTIALIAS)
pixmap = QtGui.QPixmap.fromImage(ImageQt(picture))
displayLabel.setPixmap(pixmap)
displayLabel.setFixedSize(width, height)
示例12: updateLabelToShowImage
# 需要导入模块: from PIL import ImageQt [as 别名]
# 或者: from PIL.ImageQt import ImageQt [as 别名]
def updateLabelToShowImage(displayLabel, filename, width=240, height=240):
picture = Image.open(filename)
picture.thumbnail((width,height), Image.ANTIALIAS)
pixmap = QtGui.QPixmap.fromImage(ImageQt(picture))
displayLabel.setPixmap(pixmap)
displayLabel.setFixedSize(width, height)
示例13: __init__
# 需要导入模块: from PIL import ImageQt [as 别名]
# 或者: from PIL.ImageQt import ImageQt [as 别名]
def __init__(self, parent, address):
super(BitcoinQRCodePopup, self).__init__(parent)
self.address = address
self.setWindowTitle(address)
img = qrcode.make('bitcoin:' + address)
self.imageLabel = QLabel()
self.imageLabel.setPixmap(QPixmap.fromImage(ImageQt(img)))
layout = QVBoxLayout()
layout.addWidget(self.imageLabel)
self.setLayout(layout)
self.initUI()
示例14: run
# 需要导入模块: from PIL import ImageQt [as 别名]
# 或者: from PIL.ImageQt import ImageQt [as 别名]
def run(self):
global img
while cam_open == True:
try:
img = ImageQt(cam[cam_no].getImage().resize((240, 180)))
time.sleep(0.01)
self.trigger.emit()
except:
pass
#重新连接