当前位置: 首页>>代码示例>>Python>>正文


Python QtGui.qRgb方法代码示例

本文整理汇总了Python中PyQt5.QtGui.qRgb方法的典型用法代码示例。如果您正苦于以下问题:Python QtGui.qRgb方法的具体用法?Python QtGui.qRgb怎么用?Python QtGui.qRgb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtGui的用法示例。


在下文中一共展示了QtGui.qRgb方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: array_to_qimage

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import qRgb [as 别名]
def array_to_qimage(im: np.ndarray, copy=False):
        gray_color_table = [qRgb(i, i, i) for i in range(256)]
        if im is None:
            return QImage()
        if im.dtype == np.uint8:
            if len(im.shape) == 2:
                qim = QImage(im.data, im.shape[1], im.shape[0], im.strides[0], QImage.Format_Indexed8)
                qim.setColorTable(gray_color_table)
                return qim.copy() if copy else qim

            elif len(im.shape) == 3:
                if im.shape[2] == 3:
                    qim = QImage(im.data, im.shape[1], im.shape[0], im.strides[0], QImage.Format_RGB888);
                    return qim.copy() if copy else qim
                elif im.shape[2] == 4:
                    qim = QImage(im.data, im.shape[1], im.shape[0], im.strides[0], QImage.Format_ARGB32);
                    return qim.copy() if copy else qim 
开发者ID:haruiz,项目名称:CvStudio,代码行数:19,代码来源:gui_utilities.py

示例2: on_mb_click

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import qRgb [as 别名]
def on_mb_click(self, event, addr, size, mouse_offs):
        button = event.button()
        if button == Qt.MiddleButton:
            mouse = addr+mouse_offs
            c = get_byte(mouse)
            head, name, size = self._get_item_info(mouse)
            funcname = self._get_func_name(mouse)
            self.ann = [(mouse, qRgb(c, 0xFF, self.hl_color), "Address: %X" % (mouse), qRgb(c, 0xFF, self.hl_color)),
            (None, None, "  Item: %s" % (name), qRgb(c, 0xFF, self.hl_color)),
            (None, None, "  Head: %X" % (head), qRgb(c, 0xFF, self.hl_color)),
            (None, None, "  Size: %d" % (size), qRgb(c, 0xFF, self.hl_color))
            ]
            if funcname:
                self.ann.append((None, None, "  Function: %s" % (funcname), qRgb(c, 0xFF, self.hl_color)))
            self.last_sel = (head, size)
        elif button == Qt.MiddleButton:
            pass
        elif button == Qt.RightButton:
            self.switch ^= 1
            msg('Highlighting %s\n' % self.mode[self.switch]) 
开发者ID:patois,项目名称:IDACyber,代码行数:22,代码来源:crawl.py

示例3: on_process_buffer

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import qRgb [as 别名]
def on_process_buffer(self, buffers, addr, size, mouse_offs):
        colors = []
        goffs = 0
        for mapped, buf in buffers:
            xrefs = []
            if mapped: 
                for i in range(len(buf)):
                    xrefs.append(self.xrefcount(addr + goffs + i))

                if xrefs:
                    minimum, maximum = min(xrefs), max(xrefs)
                    
                for count in xrefs:
                    r, g, b = self.hm(minimum, maximum, count)
                    colors.append((True, qRgb(r, g, b)))
            else:
                for i in range(len(buf)):
                    colors.append((False, None))
            goffs += len(buf)
        return colors 
开发者ID:patois,项目名称:IDACyber,代码行数:22,代码来源:xrefsto.py

示例4: test_rgb

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import qRgb [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) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:29,代码来源:test_imageqt.py

示例5: on_process_buffer

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import qRgb [as 别名]
def on_process_buffer(self, buffers, addr, size, mouse_offs):
        colors = []
        for mapped, buf in buffers:
            if mapped:  
                for c in buf:
                    c = (c ^ self.key) & 0xFF
                    colors.append((True, qRgb(0, c, c)))
            else:
                for i in range(len(buf)):
                    colors.append((False, None))
        return colors 
开发者ID:patois,项目名称:IDACyber,代码行数:13,代码来源:xor.py

示例6: on_process_buffer

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import qRgb [as 别名]
def on_process_buffer(self, buffers, addr, size, mouse_offs):
        colors = []
        for mapped, buf in buffers:
            if mapped:
                for c in buf:
                    r = g = b = c & 0xFF
                    r, g, b = eval(self.xpr)
                    colors.append((True, qRgb(r&0xFF, g&0xFF, b&0xFF)))
            else:
                for i in range(len(buf)):
                    colors.append((False, None))
        return colors 
开发者ID:patois,项目名称:IDACyber,代码行数:14,代码来源:expr.py

示例7: on_process_buffer

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import qRgb [as 别名]
def on_process_buffer(self, buffers, addr, size, mouse_offs):
        colors = []
        self._update_key(buffers)
        for mapped, buf in buffers:
            if mapped:
                for c in buf:
                    c = (c ^ self.key)
                    if self.highlight_key and not c:
                        colors.append((True, [qRgb(0x20, c, c), qRgb(0x7a, 0x0e, 0x7a)][self.hl_color_idx]))
                    else:
                        colors.append((True, qRgb(0x20, c, c)))
            else:
                for i in range(len(buf)):
                    colors.append((False, None))
        return colors 
开发者ID:patois,项目名称:IDACyber,代码行数:17,代码来源:autoxor.py

示例8: on_process_buffer

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import qRgb [as 别名]
def on_process_buffer(self, buffers, addr, size, mouse_offs):
        colors = []
        goffs = 0

        for mapped, buf in buffers:
            if mapped:
                ip = get_ip_val()
                i = 0
                while i < len(buf):
                    if ip is not None and ip == addr + goffs + i and self.hook.highlighted:
                        size = get_item_size(ip)
                        for j in range(size):
                            colors.append((True, qRgb(0xFF, 0x45, 0)))
                        i += size
                        continue
                    else:
                        if addr + goffs + i in self.hook.hits:
                            data = self.hook.hits[addr + goffs + i]
                            size = data[1]
                            hits = data[0]
                            for j in range(size):
                                base = self.palette[len(self.palette)-1]
                                col = QColor(base).darker(100+(float(hits)/self.hook.maxhits)*105).rgb()
                                colors.append((True, col))
                            i += size
                            continue
                        else:                            
                            c = buf[i]
                            colors.append((True, self.palette[self._byte2coloridx(c)]))
                    i += 1
            else:
                for i in range(len(buf)):
                    colors.append((False, None))
            goffs += len(buf)
        return colors 
开发者ID:patois,项目名称:IDACyber,代码行数:37,代码来源:dbg.py

示例9: on_process_buffer

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import qRgb [as 别名]
def on_process_buffer(self, buffers, addr, size, mouse_offs):
        #Bit    7  6  5  4  3  2  1  0
        #Data   R  R  R  G  G  G  B  B
        colors = []
        for mapped, buf in buffers:
            if mapped:
                for c in buf:
                    red = c & 0xE0
                    green = (c << 3) & 0xE0
                    blue = (c << 6) & 0xC0
                    colors.append((True, qRgb(red, green, blue)))
            else:
                for i in range(len(buf)):
                    colors.append((False, None))
        return colors 
开发者ID:patois,项目名称:IDACyber,代码行数:17,代码来源:NES.py

示例10: on_process_buffer

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import qRgb [as 别名]
def on_process_buffer(self, buffers, addr, size, mouse_offs):
        colors = []
        head = BADADDR
        tail = BADADDR
        goffs = 0

        for mapped, buf in buffers:
            if mapped:
                if mouse_offs is not None:
                    if self.switch == 0: # data
                        head = get_item_head(addr + mouse_offs)
                        tail = get_item_end(addr + mouse_offs)
                    else: # code
                        f = get_func(addr + mouse_offs)
                        if f:
                            head = f.start_ea
                            tail = f.end_ea

                for pos in range(len(buf)):
                    c = buf[pos] & 0xFF
                    
                    highlight = False
                    if mouse_offs is not None:
                        if addr + pos + goffs >= head and addr + pos + goffs < tail:
                            highlight = True
                    if self.last_sel:
                        lhead, lsize = self.last_sel
                        if addr + pos + goffs >= lhead and addr + pos + goffs < lhead+lsize:
                            highlight = True
                    if highlight:
                        colors.append((True, qRgb(c, 0xFF, self.hl_color)))
                    else:
                        colors.append((True, qRgb(c, 0, 0)))
            else:
                for pos in range(len(buf)):
                    colors.append((False, None))
            goffs += len(buf)
        return colors 
开发者ID:patois,项目名称:IDACyber,代码行数:40,代码来源:crawl.py

示例11: on_process_buffer

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import qRgb [as 别名]
def on_process_buffer(self, buffers, addr, size, mouse_offs):
        colors = []
        for mapped, buf in buffers:
            if mapped:                
                for c in buf:
                    r, g, b = self.hm(c)
                    colors.append((True, qRgb(r, g, b)))
            else:
                for i in range(len(buf)):
                    colors.append((False, None))
        return colors 
开发者ID:patois,项目名称:IDACyber,代码行数:13,代码来源:heatmap.py

示例12: loadDisparities

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import qRgb [as 别名]
def loadDisparities(self):
        if not self.enableDisparity:
            return
        if not self.showDisparity:
            return

        filename = self.getDisparityFilename()
        if not filename:
            self.dispImg = None
            return

        # If we have everything and the filename did not change, then we are good
        if self.dispImg and filename == self.currentDispFile:
            return

        # Clear the current labels first
        self.dispImg = None

        try:
            self.dispImg = Image.open(filename)
        except IOError as e:
            # This is the error if the file does not exist
            message = "Error parsing disparities in {0}. Message: {1}".format(filename, e.strerror)
            self.statusBar().showMessage(message)
            self.dispImg = None

        if self.dispImg:
            dispNp = np.array(self.dispImg)
            dispNp /= 128
            dispNp.round()
            dispNp = np.array(dispNp, dtype=np.uint8)

            dispQt = QtGui.QImage(dispNp.data, dispNp.shape[1], dispNp.shape[0], QtGui.QImage.Format_Indexed8)

            colortable = []
            for i in range(256):
                color = self.colormap.to_rgba(i)
                colorRgb = (int(color[0] * 255), int(color[1] * 255), int(color[2] * 255))
                colortable.append(QtGui.qRgb(*colorRgb))

            dispQt.setColorTable(colortable)
            dispQt = dispQt.convertToFormat(QtGui.QImage.Format_ARGB32_Premultiplied)
            self.dispOverlay = dispQt

        # Remember the filename loaded
        self.currentDispFile = filename

        # Remember the status bar message to restore it later
        restoreMessage = self.statusBar().currentMessage()

        # Restore the message
        self.statusBar().showMessage(restoreMessage)

    #############################
    ## Drawing
    #############################

    # This method is called when redrawing everything
    # Can be manually triggered by self.update()
    # Note that there must not be any other self.update within this method
    # or any methods that are called within 
开发者ID:CharlesShang,项目名称:Detectron-PYTORCH,代码行数:63,代码来源:cityscapesViewer.py

示例13: processPicture

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import qRgb [as 别名]
def processPicture(self, **kwargs):
        if "fitwin" in kwargs.keys():  # self.size  = size of data set
            self.scale = len(self.data) - 1  # self.scale = pyramid level
            while self.scale > 0:  # self.box   = displayed part
                if self.data[self.scale].shape[-1] > self.imageLabel.width() or \
                                self.data[self.scale].shape[-2] > self.imageLabel.height():
                    break
                self.scale -= 1
            self.box = [0, self.size[0], 0, self.size[1]]
            cut_box = [foo // 2 ** self.scale for foo in self.box]
        else:
            self.scale = len(self.data) - 1
            while self.scale > 0:
                cut_box = [foo // 2 ** self.scale for foo in self.box]
                if cut_box[1] - cut_box[0] > self.imageLabel.width() or \
                                        cut_box[3] - cut_box[2] > self.imageLabel.height():
                    break
                self.scale -= 1

            cut_box = [foo // 2 ** self.scale for foo in self.box]

        cut_box[1] = cut_box[0] + (cut_box[1] - cut_box[0]) // 4 * 4  # QT Limitation!!
        cut_box[3] = cut_box[2] + (cut_box[3] - cut_box[2]) // 4 * 4
        self.scale = int(np.clip(self.scale, 0, len(self.data) - 1))
        self.box[1] = cut_box[1] * int(2 ** self.scale)
        self.box[3] = cut_box[3] * int(2 ** self.scale)

        img = self.data2img(cut_box, scale=self.scale)

        xWin = self.imageLabel.width()
        yWin = self.imageLabel.height()
        winRatio = 1.0 * xWin / yWin

        self.imgwidth = img.width()
        self.imgheight = img.height()

        imgRatio = 1.0 * self.imgwidth / self.imgheight

        if imgRatio >= winRatio:  # match widths
            self.imgwidth = xWin
            self.imgheight = int(xWin / imgRatio)
        else:  # match heights
            self.imgheight = yWin
            self.imgwidth = int(yWin * imgRatio)

        self.factor = int(100.0 * self.imgwidth / (self.box[1] - self.box[0]))
        if self.factor <= 100:
            img = img.scaled(self.imgwidth, self.imgheight)  # Bilinear?
        else:
            img = img.scaled(self.imgwidth, self.imgheight)  # Nearest Neighbour

        self.statusBar.setMessage(size=1, zoom=1, level=1, scale=1)
        self.viewCombo.setItemText(0, str(int(self.factor)) + '%')

        # colortable = [QtGui.qRgb(i, i, i) for i in range(256)]
        p = colortables(self.config['palette'])[1]
        colortable = [QtGui.qRgb(p[i, 0], p[i, 1], p[i, 2]) for i in range(256)]

        img.setColorTable(colortable)
        self.imageLabel.setPixmap(QtGui.QPixmap.fromImage(img)) 
开发者ID:birgander2,项目名称:PyRAT,代码行数:62,代码来源:Viewer.py

示例14: on_process_buffer

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import qRgb [as 别名]
def on_process_buffer(self, buffers, addr, size, mouse_offs):
        colors = []

        for mapped, buf in buffers:
            last_offs = None
            cur_len = 0
            offsets = {}
            if mapped:
                localcolors = []
                for i in range(len(buf)):
                    c = buf[i]
                    r = 0
                    printable = c >= 0x20 and c <= 0x7E
                    if printable:
                        if last_offs is not None:
                            cur_len += 1
                        else:
                            last_offs = i
                            cur_len = 1
                    else:
                        if last_offs is not None and cur_len >= self.threshold:
                            offsets[last_offs] = cur_len
                        last_offs = None
                        cur_len = 0
                    # bg color
                    localcolors.append(0x101010)

                for k, v in offsets.items():
                    for i in range(v):
                            c = buf[k+i]
                            
                            b = c + (0xFF - 0x7E)
                            if (c >= 0x41 and c <= 0x5A or
                                    c >= 0x61 and c <= 0x7A or
                                    c >= 0x30 and c <= 0x39):
                                localcolors[k+i] = qRgb(b, b&0x7E, 0)
                            else:
                                localcolors[k+i] = qRgb(b&0x7E, b&0x7E, b&0x7E)
                for color in localcolors:
                    colors.append((True, color))
            else:
                for i in range(len(buf)):
                    colors.append((False, None))

        return colors 
开发者ID:patois,项目名称:IDACyber,代码行数:47,代码来源:ascii.py


注:本文中的PyQt5.QtGui.qRgb方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。