本文整理汇总了Python中panda3d.core.PNMImage.flip方法的典型用法代码示例。如果您正苦于以下问题:Python PNMImage.flip方法的具体用法?Python PNMImage.flip怎么用?Python PNMImage.flip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.PNMImage
的用法示例。
在下文中一共展示了PNMImage.flip方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __makeSprite__
# 需要导入模块: from panda3d.core import PNMImage [as 别名]
# 或者: from panda3d.core.PNMImage import flip [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: loadSpriteImages
# 需要导入模块: from panda3d.core import PNMImage [as 别名]
# 或者: from panda3d.core.PNMImage import flip [as 别名]
def loadSpriteImages(self,file_path,cols,rows,flipx = False,flipy = False):
"""
Loads an image file containing individual animation frames and returns then in a list of PNMImages
inputs:
- file_path
- cols
- rows
- flipx
- flipy
Output:
- tuple ( bool , list[PNMImage] )
"""
# 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)
if flipx or flipy:
full_image.flip(flipx,flipy,False)
w = int(full_image.getXSize()/cols)
h = int(full_image.getYSize()/rows)
images = []
counter = 0
for i in range(0,cols):
for j in range(0,rows):
sub_img = PNMImage(w,h)
sub_img.addAlpha()
sub_img.alphaFill(0)
sub_img.fill(1,1,1)
sub_img.copySubImage(full_image ,0 ,0 ,i*w ,j*h ,w ,h)
images.append(sub_img)
return (True, images)
示例3: flipImages
# 需要导入模块: from panda3d.core import PNMImage [as 别名]
# 或者: from panda3d.core.PNMImage import flip [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
示例4: loadImage
# 需要导入模块: from panda3d.core import PNMImage [as 别名]
# 或者: from panda3d.core.PNMImage import flip [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
示例5: __loadSpritePair__
# 需要导入模块: from panda3d.core import PNMImage [as 别名]
# 或者: from panda3d.core.PNMImage import flip [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])