def convert_bitmap(image, width=None, height=None): pix = None if isinstance(image, ImageResource): pix = traitsui_convert_bitmap(image) elif isinstance(image, Image): # image = image.convert('RGBA') data = image.tostring('raw', 'RGBA') im = QImage(data, image.size[0], image.size[1], QImage.Format_ARGB32) pix = QPixmap.fromImage(QImage.rgbSwapped(im)) else: s = image.shape if len(s) >= 2: # im = QImage(image.tostring(),s[1], s[0], QImage.Format_RGB888) im = QImage(image, s[1], s[0], QImage.Format_RGB888) pix = QPixmap.fromImage(QImage.rgbSwapped(im)) else: pix = QPixmap() if pix: if width > 0 and height > 0: pix = pix.scaled(width, height) elif width > 0: pix = pix.scaledToWidth(width) if height > 0: pix = pix.scaledToHeight(height) return pix
def requestPixmap(self, path, rsize, size): """@reimp @public @param[in] providerId unicode unused @param[out] rsize QSize @param[in] size QSize @return QPixmap not None virtual QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) """ ret = QPixmap(QUrl(path).toLocalFile()) if ret.isNull(): derror("failed to load image: '%s'" % path) elif size != ret.size() and not size.isEmpty() and not ret.size( ).isEmpty(): if ret.width() * size.height() > ret.height() * size.width(): ret = ret.scaledToHeight(min(800, size.height()), Qt.SmoothTransformation) else: w = 1000 if ret.width() > ret.height() else 600 ret = ret.scaledToWidth(min(w, size.width()), Qt.SmoothTransformation) #elif size != ret.size(): # ret = (ret.scaled(size, Qt.KeepAspectRatio, Qt.SmoothTransformation) if not size.isEmpty() else # ret.scaledToWidth(size.width(), Qt.SmoothTransformation) if size.width() > 0 else # ret.scaledToHeight(size.height(), Qt.SmoothTransformation) if size.height() > 0 else # ret) rsize.setWidth(ret.width()) rsize.setHeight(ret.height()) return ret
def convert_bitmap(image, width=None, height=None): if isinstance(image, ImageResource): pix = traitsui_convert_bitmap(image) elif isinstance(image, Image): data = image.tostring('raw', 'RGBA') im = QImage(data, image.size[0], image.size[1], QImage.Format_ARGB32) pix = QPixmap.fromImage(QImage.rgbSwapped(im)) else: s = image.shape if len(s) >= 2: pix = QPixmap.fromImage(array2qimage(image)) else: pix = QPixmap() if pix: if width > 0 and height > 0: pix = pix.scaled(width, height) elif width > 0: pix = pix.scaledToWidth(width) if height > 0: pix = pix.scaledToHeight(height) return pix
def requestPixmap(self, name, rsize, size): """@reimp @public @param[in] providerId unicode unused @param[out] rsize QSize @param[in] size QSize @return QPixmap not None virtual QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) """ ret = QPixmap(rc.image_path(name)) if ret.isNull(): derror("failed to load image: '%s'" % name) elif ret.size() != size: ret = ( ret.scaled(size, Qt.KeepAspectRatio, Qt.SmoothTransformation) if not size.isEmpty() else ret.scaledToWidth( size.width(), Qt.SmoothTransformation) if size.width() > 0 else ret.scaledToHeight(size.height(), Qt.SmoothTransformation) if size.height() > 0 else ret) rsize.setWidth(ret.width()) rsize.setHeight(ret.height()) return ret
handler.close() stderr_logger.removeFilter(handler) except: pass ######################################### # INITIALIZATION ## Market() # EXECUTE setup = Ui_manager(version) setup.show() splash.finish(setup) sys.exit(app.exec_()) if __name__ == '__main__': app = QApplication(sys.argv) with open(getFromConfig("path", "stylesheet_file"), 'r') as f: style = f.read() app.setStyleSheet(style) pixmap = QPixmap("./data/lancement.png") pixmap = pixmap.scaledToHeight(150, Qt.SmoothTransformation) splash = QSplashScreen(pixmap, Qt.WindowStaysOnTopHint) splash.show() app.processEvents() main()