本文整理汇总了Python中opengltk.OpenGL.GL.glPixelStorei方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glPixelStorei方法的具体用法?Python GL.glPixelStorei怎么用?Python GL.glPixelStorei使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opengltk.OpenGL.GL
的用法示例。
在下文中一共展示了GL.glPixelStorei方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPixelStorei [as 别名]
def Draw(self):
#print "StickerImage.Draw", self
if self.image is None:
return
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glPushMatrix()
GL.glLoadIdentity()
Insert2d.Draw(self)
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glPushMatrix()
GL.glLoadIdentity()
GL.glDisable(GL.GL_DEPTH_TEST)
GL.glDisable(GL.GL_LIGHTING);
width = self.size[0]
height = self.size[1]
fullWidth = self.viewer.currentCamera.width
fullHeight = self.viewer.currentCamera.height
# we want the anchor of the image to be at the given position
posxFromLeft = self.position[0] * fullWidth - self.anchor[0] * width
posyFrombottom = (1.-self.position[1]) * fullHeight - (1.-self.anchor[1]) * height
#print "posxFromLeft, posyFrombottom", posxFromLeft, posyFrombottom
# used for picking
self.polygonContour = [ (posxFromLeft, posyFrombottom),
(posxFromLeft+width, posyFrombottom),
(posxFromLeft+width, posyFrombottom+height),
(posxFromLeft, posyFrombottom+height)
]
# this accept negative values were GL.glRasterPos2f(x,y) doesn't
GL.glRasterPos2f(0, 0)
_gllib.glBitmap(0, 0, 0, 0, posxFromLeft, posyFrombottom, 0)
GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1)
if self.image.mode == 'RGBA':
_gllib.glDrawPixels(self.image.size[0], self.image.size[1],
GL.GL_RGBA, GL.GL_UNSIGNED_BYTE,
self.image.tostring() )
elif self.image.mode == 'RGB':
_gllib.glDrawPixels(self.image.size[0], self.image.size[1],
GL.GL_RGB, GL.GL_UNSIGNED_BYTE,
self.image.tostring() )
elif self.image.mode == 'L':
_gllib.glDrawPixels(self.image.size[0], self.image.size[1],
GL.GL_LUMINANCE, GL.GL_UNSIGNED_BYTE,
self.image.tostring() )
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glPopMatrix()
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glPopMatrix()
return 1
示例2: imageAsArray
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPixelStorei [as 别名]
def imageAsArray(self):
width = self.width
height = self.height
if width is None or height is None:
return None
nar = Numeric.zeros(3*width*height, Numeric.UnsignedInt8)
self.tk.call(self._w, 'makecurrent')
GL.glPixelStorei(GL.GL_PACK_ALIGNMENT, 1)
# self.tk.call(self._w, 'swapbuffers')
GL.glReadBuffer(GL.GL_BACK)
_gllib.glReadPixels( 0, 0, width, height, GL.GL_RGB,
GL.GL_UNSIGNED_BYTE, nar)
# self.tk.call(self._w, 'swapbuffers')
return nar
示例3: redraw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPixelStorei [as 别名]
def redraw(self, event=None, filter=None):
if self.imarray is None:
return
if filter:
self.master.lift()
GL.glConvolutionFilter2D(GL.GL_CONVOLUTION_2D, GL.GL_LUMINANCE,
3, 3, GL.GL_LUMINANCE, GL.GL_FLOAT,
filter)
## GL.glConvolutionParameterfv(GL.GL_CONVOLUTION_2D,
## GL.GL_CONVOLUTION_FILTER_SCALE,
## (3., 3.,3.,3.))
## s= self.scale
## GL.glPixelTransferf(GL.GL_POST_CONVOLUTION_RED_SCALE, s)
## GL.glPixelTransferf(GL.GL_POST_CONVOLUTION_BLUE_SCALE, s)
## GL.glPixelTransferf(GL.GL_POST_CONVOLUTION_GREEN_SCALE, s)
## s = self.bias
## GL.glPixelTransferf(GL.GL_POST_CONVOLUTION_RED_BIAS, s)
## GL.glPixelTransferf(GL.GL_POST_CONVOLUTION_BLUE_BIAS, s)
## GL.glPixelTransferf(GL.GL_POST_CONVOLUTION_GREEN_BIAS, s)
## GL.GL_CONVOLUTION_FILTER_SCALE,
## (3., 3.,3.,3.))
## GL.glConvolutionParameteriv(GL.GL_CONVOLUTION_2D,
## GL.GL_CONVOLUTION_FILTER_BIAS,
## (1500, 1500, 1500, 1500))
GL.glEnable(GL.GL_CONVOLUTION_2D)
self.tk.call(self._w, 'makecurrent')
GL.glClearColor(0.0, 0.0, 0.0, 0.0)
GL.glClear(GL.GL_COLOR_BUFFER_BIT)
GL.glRasterPos2i( 0, 0)
GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1)
if self.mode=='RGB':
_gllib.glDrawPixels( self.width, self.height,
GL.GL_RGB, GL.GL_UNSIGNED_BYTE, self.imarray)
elif self.mode in ['L','P']:
_gllib.glDrawPixels( self.width, self.height,
GL.GL_LUMINANCE, GL.GL_UNSIGNED_BYTE,
self.imarray)
GL.glDisable(GL.GL_CONVOLUTION_2D)
示例4: initGL
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPixelStorei [as 别名]
def initGL(self):
GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1)
GL.glClearColor(0.4, 0.4, 0.4, 0.0)
示例5: endTile
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPixelStorei [as 别名]
def endTile(self):
assert(self.CurrentTile>=0)
# be sure OpenGL rendering is finished
GL.glFinish() #was glFlush()
# save current glPixelStore values
prevRowLength = GL.glGetIntegerv(GL.GL_PACK_ROW_LENGTH)[0]
prevSkipRows = GL.glGetIntegerv(GL.GL_PACK_SKIP_ROWS)[0]
prevSkipPixels = GL.glGetIntegerv(GL.GL_PACK_SKIP_PIXELS)[0]
#prevAlignment = GL.glGetIntegerv(GL_PACK_ALIGNMENT)[0]
if self.TileBuffer is not None:
srcX = self.TileBorder
srcY = self.TileBorder
srcWidth = self.TileWidthNB
srcHeight = self.TileHeightNB
GL.glReadPixels(srcX, srcY, srcWidth, srcHeight,
self.TileFormat, self.TileType, self.TileBuffer)
if self.ImageBuffer is not None:
srcX = self.TileBorder
srcY = self.TileBorder
srcWidth = self.CurrentTileWidth - 2 * self.TileBorder
srcHeight = self.CurrentTileHeight - 2 * self.TileBorder
destX = self.TileWidthNB * self.CurrentColumn
destY = self.TileHeightNB * self.CurrentRow
## #save single tile
## # setup pixel store for glReadPixels
## GL.glPixelStorei(GL.GL_PACK_ROW_LENGTH, self.CurrentTileWidth)
## GL.glPixelStorei(GL.GL_PACK_SKIP_ROWS, 0)
## GL.glPixelStorei(GL.GL_PACK_SKIP_PIXELS, 0)
## #GL.glPixelStorei(GL.GL_PACK_ALIGNMENT, 1)
## # read the tile into buffer
## gllib.glReadPixels(srcX, srcY, srcWidth, srcHeight,
## self.ImageFormat, self.ImageType, self.oneTileRenderBuffer)
## import Image, sys
## im = Image.fromstring('RGB', (srcWidth, srcHeight),
## self.oneTileRenderBuffer)
## if sys.platform!='win32':
## im = im.transpose(Image.FLIP_TOP_BOTTOM)
## im.save('tile%d_%d.tif'%(self.CurrentRow, self.CurrentColumn))
# setup pixel store for glReadPixels
GL.glPixelStorei(GL.GL_PACK_ROW_LENGTH, self.ImageWidth)
GL.glPixelStorei(GL.GL_PACK_SKIP_ROWS, destY)
GL.glPixelStorei(GL.GL_PACK_SKIP_PIXELS, destX)
#GL.glPixelStorei(GL.GL_PACK_ALIGNMENT, 1)
# read the tile into the final image
#print 'DEBUG Tile renderer'
#print 'column, row:', self.CurrentColumn, self.CurrentRow
#print 'srcWidth,srcHeight,destX, destY',srcWidth,srcHeight,destX, destY
gllib.glReadPixels(srcX, srcY, srcWidth, srcHeight,
self.ImageFormat, self.ImageType, self.ImageBuffer)
# restore previous glPixelStore values
GL.glPixelStorei(GL.GL_PACK_ROW_LENGTH, int(prevRowLength))
GL.glPixelStorei(GL.GL_PACK_SKIP_ROWS, int(prevSkipRows))
GL.glPixelStorei(GL.GL_PACK_SKIP_PIXELS, int(prevSkipPixels))
#GL.glPixelStorei(GL.GL_PACK_ALIGNMENT, prevAlignment)
# increment tile counter, return 1 if more tiles left to render
self.CurrentTile+=1
if self.CurrentTile >= self.Rows * self.Columns:
# restore user's viewport
GL.glViewport(int(self.ViewportSave[0]), int(self.ViewportSave[1]),
int(self.ViewportSave[2]), int(self.ViewportSave[3]))
self.CurrentTile = -1 # all done
return 0
else:
return 1