mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 17:54:32 +03:00
tests for imageqt4/5
This commit is contained in:
parent
938323bd2b
commit
29fb4523d5
|
@ -1,9 +1,39 @@
|
|||
from tester import *
|
||||
|
||||
from PIL import Image
|
||||
try:
|
||||
from PIL import ImageQt
|
||||
except ImportError as v:
|
||||
skip(v)
|
||||
|
||||
success()
|
||||
try:
|
||||
from PyQt5.QtGui import QImage, qRgb, qRgba
|
||||
except:
|
||||
try:
|
||||
from PyQt4.QtGui import QImage, qRgb, qRgba
|
||||
except:
|
||||
skip('PyQT4 or 5 not installed')
|
||||
|
||||
from PIL import ImageQt
|
||||
|
||||
def test_rgb():
|
||||
# from https://qt-project.org/doc/qt-4.8/qcolor.html
|
||||
# typedef QRgb
|
||||
# An ARGB quadruplet on the format #AARRGGBB, equivalent to an unsigned int.
|
||||
|
||||
assert_equal(qRgb(0,0,0), qRgba(0,0,0,255))
|
||||
|
||||
def checkrgb(r,g,b):
|
||||
val = ImageQt.rgb(r,g,b)
|
||||
print val
|
||||
val = val % 2**24 # drop the alpha
|
||||
assert_equal(val >> 16, r)
|
||||
assert_equal(((val >> 8 ) % 2**8), g)
|
||||
assert_equal(val % 2**8, b)
|
||||
|
||||
checkrgb(0,0,0)
|
||||
checkrgb(255,0,0)
|
||||
checkrgb(0,255,0)
|
||||
checkrgb(0,0,255)
|
||||
|
||||
|
||||
def test_image():
|
||||
for mode in ('1', 'RGB', 'RGBA', 'L', 'P'):
|
||||
print ( "Testing mode %s" % mode)
|
||||
assert_no_exception(lambda: ImageQt.ImageQt(lena(mode)))
|
||||
|
|
Loading…
Reference in New Issue
Block a user