我们从Python开源项目中,提取了以下13个代码示例,用于说明如何使用PyQt4.QtGui.qRgba()。
def convert_shtx_4bit(data): width = to_u16(data[0:2]) height = to_u16(data[2:4]) unk = data[4:12] p = 12 palette = [] for i in range(16): palette.append(qRgba(data[p], data[p + 1], data[p + 2], data[p + 3])) p += 4 pixels = data[p : p + (width * height / 2)] pixels2 = bytearray() for b in pixels: pixels2.append(b & 0x0F) pixels2.append(b >> 4) img = QImage(pixels2, width, height, QImage.Format_Indexed8) img.setColorTable(palette) return img
def rgb(r, g, b, a=255): """(Internal) Turns an RGB color into a Qt compatible color integer.""" # use qRgb to pack the colors, and then turn the resulting long # into a negative integer with the same bitpattern. return (qRgba(r, g, b, a) & 0xffffffff) # :param im A PIL Image object, or a file name # (given either as Python string or a PyQt string object)
def rgb(r, g, b, a=255): """(Internal) Turns an RGB color into a Qt compatible color integer.""" # use qRgb to pack the colors, and then turn the resulting long # into a negative integer with the same bitpattern. return (qRgba(r, g, b, a) & 0xffffffff)
def convert_shtx_8bit(data): width = to_u16(data[0:2]) height = to_u16(data[2:4]) unk = to_u16(data[4:6]) p = 6 palette = [] for i in range(256): palette.append(qRgba(data[p], data[p + 1], data[p + 2], data[p + 3])) p += 4 # For some reason, a couple images have blank palettes and are actually RGBA images. if not palette == [0L] * 256: pixels = data[p : p + (width * height)] img = QImage(pixels, width, height, QImage.Format_Indexed8) img.setColorTable(palette) else: pixels = data[p:] height = len(pixels) / width / 4 img = QImage(pixels, width, height, QImage.Format_ARGB32) return img