Python PyQt4.QtGui.qRgb() Examples
The following are 9
code examples of PyQt4.QtGui.qRgb().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
PyQt4.QtGui
, or try the search function
.
Example #1
Source File: test_imageqt.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #2
Source File: ImageQt.py From mxnet-lambda with Apache License 2.0 | 5 votes |
def rgb(r, g, b): # 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 ## # An PIL image wrapper for Qt. This is a subclass of PyQt4's QImage # class. # # @param im A PIL Image object, or a file name (given either as Python # string or a PyQt string object).
Example #3
Source File: ImageQt.py From CNCGToolKit with MIT License | 5 votes |
def rgb(r, g, b): # 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 ## # An PIL image wrapper for Qt. This is a subclass of PyQt4's QImage # class. # # @param im A PIL Image object, or a file name (given either as Python # string or a PyQt string object).
Example #4
Source File: colormapcombo.py From segyviewer with GNU Lesser General Public License v3.0 | 5 votes |
def _create_icon(self, color_map_name, image, values): """" :type color_map_name: str :type image: QImage :type values: np.ndarray """ color_map = ScalarMappable(cmap=color_map_name) rgba = color_map.to_rgba(values, bytes=True) color_table = [qRgb(c[0], c[1], c[2]) for c in rgba] image.setColorTable(color_table) return QPixmap.fromImage(image).scaledToWidth(128)
Example #5
Source File: ImageQt.py From keras-lambda with MIT License | 5 votes |
def rgb(r, g, b): # 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 ## # An PIL image wrapper for Qt. This is a subclass of PyQt4's QImage # class. # # @param im A PIL Image object, or a file name (given either as Python # string or a PyQt string object).
Example #6
Source File: cityscapesViewer.py From fcn8s_tensorflow with GNU General Public License v3.0 | 4 votes |
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
Example #7
Source File: cityscapesViewer.py From rec-attend-public with MIT License | 4 votes |
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
Example #8
Source File: cityscapesViewer.py From LightNet with MIT License | 4 votes |
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
Example #9
Source File: cityscapesViewer.py From TFSegmentation with Apache License 2.0 | 4 votes |
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