本文整理汇总了Python中panda3d.core.PNMImage.copyFrom方法的典型用法代码示例。如果您正苦于以下问题:Python PNMImage.copyFrom方法的具体用法?Python PNMImage.copyFrom怎么用?Python PNMImage.copyFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.PNMImage
的用法示例。
在下文中一共展示了PNMImage.copyFrom方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __makeSprite__
# 需要导入模块: from panda3d.core import PNMImage [as 别名]
# 或者: from panda3d.core.PNMImage import copyFrom [as 别名]
def __makeSprite__(self,pnm_img,subfile,flip):
img = None
if flip:
img = PNMImage(pnm_img.getXSize(),pnm_img.getYSize())
img.copyFrom(pnm_img)
img.flip(True ,False,False)
else:
img = pnm_img
sff_image = Sprite()
sff_image.setXSize(img.getXSize())
sff_image.setYSize(pnm_img.getYSize())
sff_image.setZSize(1)
sff_image.axisx = -subfile.axisx if (not flip ) else subfile.axisx
sff_image.axisy = subfile.axisy
sff_image.group = subfile.groupno
sff_image.no = subfile.imageno
sff_image.load(img)
sff_image.setWrapU(Texture.WM_border_color) # gets rid of odd black edges around image
sff_image.setWrapV(Texture.WM_border_color)
sff_image.setBorderColor(LColor(0,0,0,0))
return sff_image
示例2: flipImages
# 需要导入模块: from panda3d.core import PNMImage [as 别名]
# 或者: from panda3d.core.PNMImage import copyFrom [as 别名]
def flipImages(self,images,flipx , flipy):
"""
Returns a copy of the images flipped by the corresponding axes
"""
flipped = []
for img in images:
fimg = PNMImage(img.getXSize(),img.getYSize())
fimg.copyFrom(img)
fimg.flip(flipx,flipy,False)
flipped.append(fimg)
return flipped
示例3: loadImage
# 需要导入模块: from panda3d.core import PNMImage [as 别名]
# 或者: from panda3d.core.PNMImage import copyFrom [as 别名]
def loadImage(self,file_path,cols,rows,scale_x,scale_y,frame_rate):
# Make a filepath
image_file = Filename(file_path)
if image_file .empty():
raise IOError, "File not found"
return False
# Instead of loading it outright, check with the PNMImageHeader if we can open
# the file.
img_head = PNMImageHeader()
if not img_head.readHeader(image_file ):
raise IOError, "PNMImageHeader could not read file %s. Try using absolute filepaths"%(file_path)
return False
# Load the image with a PNMImage
full_image = PNMImage(img_head.getXSize(),img_head.getYSize())
full_image.alphaFill(0)
full_image.read(image_file)
right_image = PNMImage(img_head.getXSize(),img_head.getYSize())
left_image = PNMImage(img_head.getXSize(),img_head.getYSize())
right_image.copyFrom(full_image)
left_image.copyFrom(full_image)
left_image.flip(True,False,False)
# storing individual sprite size
self.size_ = (right_image.getReadXSize()/cols,right_image.getReadYSize()/rows)
self.seq_right_ = self.attachNewNode(self.createSequenceNode(self.name_ + '_right_seq',right_image,cols,rows,scale_x,scale_y,frame_rate))
self.seq_left_ = self.attachNewNode(self.createSequenceNode(self.name_ + '_left_seq',left_image,cols,rows,scale_x,scale_y,frame_rate))
self.seq_right_.reparentTo(self)
self.seq_left_.reparentTo(self)
right_image.clear()
left_image.clear()
full_image.clear()
self.faceRight(True)
return True
示例4: __loadSpritePair__
# 需要导入模块: from panda3d.core import PNMImage [as 别名]
# 或者: from panda3d.core.PNMImage import copyFrom [as 别名]
def __loadSpritePair__(sprite_details):
image_file = sprite_details.im_file
img_head = PNMImageHeader()
if not img_head.readHeader(image_file ):
logging.error( "PNMImageHeader could not read file %s. Try using absolute filepaths"%(image_file))
return (None,None)
# Load the right side image as a PNMImage
right_img = PNMImage(img_head.getXSize(),img_head.getYSize())
right_img.alphaFill(0)
right_img.read(image_file)
# Flip to get the left side image
left_img = PNMImage(right_img.getXSize(),right_img.getYSize())
left_img.copyFrom(right_img)
left_img.flip(True ,False,False)
images = [(right_img,False),(left_img,True)]
sprites = []
for entry in images:
img = entry[0]
flip = entry[1]
sprite = Sprite()
sprite.setXSize(img.getXSize())
sprite.setYSize(img.getYSize())
sprite.setZSize(1)
sprite.axisx = -sprite_details.axisx if (not flip ) else sprite_details.axisx
sprite.axisy = sprite_details.axisy
sprite.group = sprite_details.group_no
sprite.no = sprite_details.image_no
sprite.load(img)
sprite.setWrapU(Texture.WM_border_color) # gets rid of odd black edges around image
sprite.setWrapV(Texture.WM_border_color)
sprite.setBorderColor(LColor(0,0,0,0))
sprites.append(sprite)
return (sprites[0],sprites[1])