Fix for failing ImageQt with mode 'L' image

This commit is contained in:
wiredfool 2013-11-20 22:20:13 -08:00
parent 29fb4523d5
commit dbecc1cb70

View File

@ -20,17 +20,17 @@ from PIL import Image
from PIL._util import isPath
try:
from PyQt5.QtGui import QImage, qRgb
from PyQt5.QtGui import QImage, qRgba
except:
from PyQt4.QtGui import QImage, qRgb
from PyQt4.QtGui import QImage, qRgba
##
# (Internal) Turns an RGB color into a Qt compatible color integer.
def rgb(r, g, b):
def rgb(r, g, b, a=255):
# use qRgb to pack the colors, and then turn the resulting long
# into a negative integer with the same bitpattern.
return (qRgb(r, g, b) & 0xffffff) - 0x1000000
return (qRgba(r, g, b, a) & 0xffffffff)
##
# An PIL image wrapper for Qt. This is a subclass of PyQt4's QImage