本文整理汇总了Python中pandac.PandaModules.PNMImage.copySubImage方法的典型用法代码示例。如果您正苦于以下问题:Python PNMImage.copySubImage方法的具体用法?Python PNMImage.copySubImage怎么用?Python PNMImage.copySubImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandac.PandaModules.PNMImage
的用法示例。
在下文中一共展示了PNMImage.copySubImage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadFlatQuad
# 需要导入模块: from pandac.PandaModules import PNMImage [as 别名]
# 或者: from pandac.PandaModules.PNMImage import copySubImage [as 别名]
def loadFlatQuad(self, fullFilename):
cm = CardMaker("cm-%s" % fullFilename)
cm.setColor(1.0, 1.0, 1.0, 1.0)
aspect = base.camLens.getAspectRatio()
htmlWidth = 2.0 * aspect * WEB_WIDTH_PIXELS / float(WIN_WIDTH)
htmlHeight = 2.0 * float(WEB_HEIGHT_PIXELS) / float(WIN_HEIGHT)
cm.setFrame(-htmlWidth / 2.0, htmlWidth / 2.0, -htmlHeight / 2.0, htmlHeight / 2.0)
bottomRightX = WEB_WIDTH_PIXELS / float(WEB_WIDTH + 1)
bottomRightY = WEB_HEIGHT_PIXELS / float(WEB_HEIGHT + 1)
cm.setUvRange(Point2(0, 1 - bottomRightY), Point2(bottomRightX, 1))
card = cm.generate()
quad = NodePath(card)
jpgFile = PNMImage(WEB_WIDTH, WEB_HEIGHT)
smallerJpgFile = PNMImage()
readFile = smallerJpgFile.read(Filename(fullFilename))
if readFile:
jpgFile.copySubImage(smallerJpgFile, 0, 0)
guiTex = Texture("guiTex")
guiTex.setupTexture(Texture.TT2dTexture, WEB_WIDTH, WEB_HEIGHT, 1, Texture.TUnsignedByte, Texture.FRgba)
guiTex.setMinfilter(Texture.FTLinear)
guiTex.load(jpgFile)
guiTex.setWrapU(Texture.WMClamp)
guiTex.setWrapV(Texture.WMClamp)
ts = TextureStage("webTS")
quad.setTexture(ts, guiTex)
quad.setTransparency(0)
quad.setTwoSided(True)
quad.setColor(1.0, 1.0, 1.0, 1.0)
result = quad
else:
result = None
Texture.setTexturesPower2(1)
return result
示例2: make_blocks_texmap
# 需要导入模块: from pandac.PandaModules import PNMImage [as 别名]
# 或者: from pandac.PandaModules.PNMImage import copySubImage [as 别名]
def make_blocks_texmap(self):
images = []
# 0 - sand
images.append(PNMImage('res/textures/{0}sand.png'.format(
Config().tex_suffix)))
# 1 - land
images.append(PNMImage('res/textures/{0}land.png'.format(
Config().tex_suffix)))
# 2 - low_mount
images.append(PNMImage("res/textures/{0}low_mount.png".format(
Config().tex_suffix)))
# 3 - mid_mount
images.append(PNMImage("res/textures/{0}mid_mount.png".format(
Config().tex_suffix)))
# 4 - high_mount
images.append(PNMImage("res/textures/{0}high_mount.png".format(
Config().tex_suffix)))
d = images[0].getReadXSize()
# 16 x 16 textures
size = d * self.map_size
image_all = PNMImage(size, size)
n = 0
for i in xrange(0, size, d):
for j in xrange(0, size, d):
image_all.copySubImage(images[n], j, i)
n += 1
if n >= len(images):
break
if n >= len(images):
break
self['world_blocks'] = Texture()
self['world_blocks'].load(image_all)
self['world_blocks'].setMagfilter(Texture.FTLinearMipmapLinear)
self['world_blocks'].setMinfilter(Texture.FTLinearMipmapLinear)
示例3: HtmlView
# 需要导入模块: from pandac.PandaModules import PNMImage [as 别名]
# 或者: from pandac.PandaModules.PNMImage import copySubImage [as 别名]
#.........这里部分代码省略.........
ll.setZ(ll.getZ() + offset.getZ())
ur.setZ(ur.getZ() + offset.getZ())
self.notify.debug('new LL=%s, UR=%s' % (ll, ur))
relPointll = self.quad.getRelativePoint(aspect2d, ll)
self.notify.debug('relPoint = %s' % relPointll)
self.mouseLL = (aspect2d.getScale()[0] * ll[0], aspect2d.getScale()[2] * ll[2])
self.mouseUR = (aspect2d.getScale()[0] * ur[0], aspect2d.getScale()[2] * ur[2])
self.notify.debug('original mouseLL=%s, mouseUR=%s' % (self.mouseLL, self.mouseUR))
def writeTex(self, filename = 'guiText.png'):
self.notify.debug('writing texture')
self.guiTex.generateRamMipmapImages()
self.guiTex.write(filename)
def toggleRotation(self):
if self.interval.isPlaying():
self.interval.finish()
else:
self.interval.loop()
def mouseDown(self, button):
messenger.send('wakeup')
self.webView.injectMouseDown(button)
def mouseUp(self, button):
self.webView.injectMouseUp(button)
def reload(self):
pass
def zoomIn(self):
self.webView.zoomIn()
def zoomOut(self):
self.webView.zoomOut()
def toggleTransparency(self):
self.transparency = not self.transparency
self.webView.setTransparent(self.transparency)
def update(self, task):
if base.mouseWatcherNode.hasMouse():
x, y = self._translateRelativeCoordinates(base.mouseWatcherNode.getMouseX(), base.mouseWatcherNode.getMouseY())
if self.mx - x != 0 or self.my - y != 0:
self.webView.injectMouseMove(x, y)
self.mx, self.my = x, y
if self.webView.isDirty():
self.webView.render(self.imgBuffer.buffer_info()[0], WEB_WIDTH * 4, 4)
Texture.setTexturesPower2(2)
textureBuffer = self.guiTex.modifyRamImage()
textureBuffer.setData(self.imgBuffer.tostring())
if self.useHalfTexture:
self.guiTex.store(self.fullPnmImage)
self.leftPnmImage.copySubImage(self.fullPnmImage, 0, 0, 0, 0, WEB_HALF_WIDTH, WEB_HEIGHT)
self.rightPnmImage.copySubImage(self.fullPnmImage, 0, 0, WEB_HALF_WIDTH, 0, WEB_HALF_WIDTH, WEB_HEIGHT)
self.leftGuiTex.load(self.leftPnmImage)
self.rightGuiTex.load(self.rightPnmImage)
self.quad.hide()
Texture.setTexturesPower2(1)
GlobalWebcore.update()
return Task.cont
def _translateRelativeCoordinates(self, x, y):
sx = int((x - self.mouseLL[0]) / (self.mouseUR[0] - self.mouseLL[0]) * WEB_WIDTH_PIXELS)
sy = WEB_HEIGHT_PIXELS - int((y - self.mouseLL[1]) / (self.mouseUR[1] - self.mouseLL[1]) * WEB_HEIGHT_PIXELS)
return (sx, sy)
def unload(self):
self.ignoreAll()
self.webView.destroy()
self.webView = None
return
def onCallback(self, name, args):
if name == 'requestFPS':
pass
def onBeginNavigation(self, url, frameName):
pass
def onBeginLoading(self, url, frameName, statusCode, mimeType):
pass
def onFinishLoading(self):
self.notify.debug('finished loading')
def onReceiveTitle(self, title, frameName):
pass
def onChangeTooltip(self, tooltip):
pass
def onChangeCursor(self, cursor):
pass
def onChangeKeyboardFocus(self, isFocused):
pass
def onChangeTargetURL(self, url):
pass