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


Python QGraphicsPixmapItem.setScale方法代码示例

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


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

示例1: paintBoundaries

# 需要导入模块: from PyQt4.QtGui import QGraphicsPixmapItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsPixmapItem import setScale [as 别名]
def paintBoundaries(tgslicesFile, zSlice, d, boundaryData, mask, filename, swapCoordinates=False, colortable=None, penWidth=4.0):
    print "* making boundary img '%s'" % filename
    
    #b = BoundariesLayerPy(tgslicesFile=tgslicesFile, normalAxis=2, data2scene=QTransform(), swapCoordinates=True)
    b = BoundariesLayer(None, 2, QTransform(), True)
    
    n  = b.normalAxis()
    axis = None
    if swapCoordinates:
        if   n == 0: axis = "z"
        elif n == 1: axis = "y"
        else:        axis = "x"
    else:
        if   n == 0: axis = "x"
        elif n == 1: axis = "y"
        else:        axis = "z"
    
    f = h5py.File(tgslicesFile, 'r')
    group = "%s/%d" % (axis, zSlice)
    serializedBoundaries = f[group].value
    f.close()
    
    assert d.ndim == 2
    
    scene = QGraphicsScene()
    
    b.setSliceNumber( zSlice )
    b.setBoundaries(serializedBoundaries)
    b.setColormap("tyr")
    assert boundaryData.dtype == numpy.float32
    assert mask.dtype == numpy.float32
    b.setBoundaryData(boundaryData, boundaryData.size, boundaryData)
    b.setBoundaryMask(mask, mask.size)
    if colortable is not None:
        b.setColormap(colortable)
    print "setting pen width to be %f" % penWidth
    b.setPenWidth(float(penWidth))
    print "...done"
   
    mag = 4
    shape = d.shape
    
    dBig = vigra.sampling.resizeImageNoInterpolation(d.astype(numpy.float32), (mag*shape[0], mag*shape[1]))
    #dBig = dBig.swapaxes(0,1)
    qimg = qimage2ndarray.gray2qimage(dBig)
    #qimg = qimg.mirrored(True, False)
    imgItm = QGraphicsPixmapItem(QPixmap(qimg))
    imgItm.setScale(1.0/mag)
    scene.addItem(imgItm)
    
    sourceRect = QRectF(0,0,shape[1], shape[0])
    targetRect = QRectF(0,0,mag*shape[1], mag*shape[0])
    scene.setSceneRect(sourceRect)
    scene.addItem(b)
    
    img = QImage(targetRect.width(), targetRect.height(), QImage.Format_ARGB32);
    painter = QPainter(img);
    painter.setRenderHint(QPainter.Antialiasing);
    scene.render(painter, targetRect, sourceRect );
    img.save(filename)
    painter.end()
    #print "img has size ", img.width(), img.height()
    img = None
    painter = None
    scene = None
开发者ID:DerThorsten,项目名称:mambo_jambo,代码行数:67,代码来源:paint_boundaries.py


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