本文整理汇总了Python中pandac.PandaModules.PNMImage.blendSubImage方法的典型用法代码示例。如果您正苦于以下问题:Python PNMImage.blendSubImage方法的具体用法?Python PNMImage.blendSubImage怎么用?Python PNMImage.blendSubImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandac.PandaModules.PNMImage
的用法示例。
在下文中一共展示了PNMImage.blendSubImage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Heightfield
# 需要导入模块: from pandac.PandaModules import PNMImage [as 别名]
# 或者: from pandac.PandaModules.PNMImage import blendSubImage [as 别名]
#.........这里部分代码省略.........
tilePos = (500,500)
tileSize = (4000,4000)
imgTilePos = self.world2MapPos(tilePos)
imgTileSize = self.world2MapPos( (tilePos[0] + tileSize[0], tilePos[1] + tileSize[1]) )
imgTileSize = (imgTileSize[0] - imgTilePos[0], imgTileSize[1] - imgTilePos[1])
tileSquare = PNMImage(Filename("tile.png"))
tileStamp = PNMImage(int(imgTileSize[0] * (5/3)),int(imgTileSize[1] * (5/3)))
tileStamp.makeGrayscale()
tileStamp.addAlpha()
tileStamp.gaussianFilterFrom(1, tileSquare)
count = 4
total = 0.0
selectXLow = int(imgTilePos[0] + imgTileSize[0] * 0.25)
selectXHigh = int(imgTilePos[0] + imgTileSize[0] * 0.75)
selectYLow = int(imgTilePos[1] + imgTileSize[1] * 0.25)
selectYHigh = int(imgTilePos[1] + imgTileSize[1] * 0.75)
total += self.myImage.getGray(selectXLow,selectYLow)
total += self.myImage.getGray(selectXLow,selectYLow)
total += self.myImage.getGray(selectXHigh,selectYHigh)
total += self.myImage.getGray(selectXHigh,selectYHigh)
average = total/count
tileStamp.fill(average)
edgeWidth = imgTilePos[0]*(1/3)
self.myImage.blendSubImage(tileStamp, int( imgTilePos[0]-edgeWidth),
int( imgTilePos[1]-edgeWidth),
0, 0, int(imgTileSize[0]*( 5/3 ) ),
int(imgTileSize[1]*( 5/3 ) ), 1)
def getCurrentTerrain(self):
if self.terrain2.getRoot().isHidden():
return self.terrain1
else:
return self.terrain2
def getHiddenTerrain(self):
if self.terrain1.getRoot().isHidden():
return self.terrain1
else:
return self.terrain2
def updateWithNewImage(self):
posX = base.camera.getX() + MAPSIZE/2
posY = base.camera.getY() + MAPSIZE/2
if self.terrain2.getRoot().isHidden():
self.terrain2.setHeightfield(self.myImage)
self.terrain2.setFocalPoint(posX, posY)
if Thread.isThreadingSupported():
thread.start_new_thread(self.updateWithNewImageThread,(self.terrain2,1))
else:
self.updateWithNewImageThread(self.terrain2)
self.terrain1.getRoot().hide()
self.terrain2.getRoot().show()
print "done"
else:
self.terrain1.setHeightfield(self.myImage)
self.terrain1.setFocalPoint(posX, posY)
示例2: __init__
# 需要导入模块: from pandac.PandaModules import PNMImage [as 别名]
# 或者: from pandac.PandaModules.PNMImage import blendSubImage [as 别名]
#.........这里部分代码省略.........
self.node.setTwoSided(True)
# Make a filepath
self.imgFile = Filename(image_path)
if self.imgFile.empty():
raise IOError, "File not found"
# Instead of loading it outright, check with the PNMImageHeader if we can open
# the file.
imgHead = PNMImageHeader()
if not imgHead.readHeader(self.imgFile):
raise IOError, "PNMImageHeader could not read file. Try using absolute filepaths"
# Load the image with a PNMImage
image = PNMImage()
image.read(self.imgFile)
self.sizeX = image.getXSize()
self.sizeY = image.getYSize()
# We need to find the power of two size for the another PNMImage
# so that the texture thats loaded on the geometry won't have artifacts
textureSizeX = self.nextsize(self.sizeX)
textureSizeY = self.nextsize(self.sizeY)
# The actual size of the texture in memory
self.realSizeX = textureSizeX
self.realSizeY = textureSizeY
self.paddedImg = PNMImage(textureSizeX, textureSizeY)
if image.hasAlpha():
self.paddedImg.alphaFill(0)
# Copy the source image to the image we're actually using
self.paddedImg.blendSubImage(image, 0, 0)
# We're done with source image, clear it
image.clear()
# The pixel sizes for each cell
self.colSize = self.sizeX/self.cols
self.rowSize = self.sizeY/self.rows
# How much padding the texture has
self.paddingX = textureSizeX - self.sizeX
self.paddingY = textureSizeY - self.sizeY
# Set UV padding
self.uPad = float(self.paddingX)/textureSizeX
self.vPad = float(self.paddingY)/textureSizeY
# The UV dimensions for each cell
self.uSize = (1.0 - self.uPad) / self.cols
self.vSize = (1.0 - self.vPad) / self.rows
self.cards = []
self.rowPerFace = rowPerFace
for i in range(len(rowPerFace)):
card = CardMaker("Sprite2d-Geom")
# The positions to create the card at
if anchorX == self.ALIGN_LEFT:
posLeft = 0
posRight = (self.colSize/scale)*repeatX
elif anchorX == self.ALIGN_CENTER:
posLeft = -(self.colSize/2.0/scale)*repeatX
posRight = (self.colSize/2.0/scale)*repeatX
elif anchorX == self.ALIGN_RIGHT: