WebGLRenderingContext.pixelStorei() - Web APIs 编辑

The WebGLRenderingContext.pixelStorei() method of the WebGL API specifies the pixel storage modes.

Syntax

void gl.pixelStorei(pname, param);

Parameters

pname
A Glenum specifying which parameter to set. See below for possible values.
param
GLint specifying a value to set the pname parameter to. See below for possible values.

Return value

None.

Pixel storage parameters

Parameter name (for pname)DescriptionTypeDefault valueAllowed values (for param)Specified in
gl.PACK_ALIGNMENTPacking of pixel data into memoryGLint41, 2, 4, 8OpenGL ES 2.0
gl.UNPACK_ALIGNMENTUnpacking of pixel data from memory.GLint41, 2, 4, 8OpenGL ES 2.0
gl.UNPACK_FLIP_Y_WEBGLFlips the source data along its vertical axis if true.GLbooleanfalsetrue, falseWebGL
gl.UNPACK_PREMULTIPLY_ALPHA_WEBGLMultiplies the alpha channel into the other color channelsGLbooleanfalsetrue, falseWebGL
gl.UNPACK_COLORSPACE_CONVERSION_WEBGLDefault color space conversion or no color space conversion.GLenumgl.BROWSER_DEFAULT_WEBGLgl.BROWSER_DEFAULT_WEBGL, gl.NONEWebGL

When using a WebGL 2 context, the following values are available additionally:

ConstantDescriptionTypeDefault valueAllowed values (for param)Specified in
gl.PACK_ROW_LENGTHNumber of pixels in a row.GLint00 to InfinityOpenGL ES 3.0
gl.PACK_SKIP_PIXELSNumber of pixel locations skipped before the first pixel is written into memory.GLint00 to InfinityOpenGL ES 3.0
gl.PACK_SKIP_ROWSNumber of rows of pixel locations skipped before the first pixel is written into memoryGLint00 to InfinityOpenGL ES 3.0
gl.UNPACK_ROW_LENGTHNumber of pixels in a row.GLint00 to InfinityOpenGL ES 3.0
gl.UNPACK_IMAGE_HEIGHTImage height used for reading pixel data from memoryGLint00 to InfinityOpenGL ES 3.0
gl.UNPACK_SKIP_PIXELSNumber of pixel images skipped before the first pixel is read from memoryGLint00 to InfinityOpenGL ES 3.0
gl.UNPACK_SKIP_ROWSNumber of rows of pixel locations skipped before the first pixel is read from memoryGLint00 to InfinityOpenGL ES 3.0
gl.UNPACK_SKIP_IMAGESNumber of pixel images skipped before the first pixel is read from memoryGLint00 to InfinityOpenGL ES 3.0

Examples

Setting the pixel storage mode affects the WebGLRenderingContext.readPixels() operations, as well as unpacking of textures with the WebGLRenderingContext.texImage2D() and WebGLRenderingContext.texSubImage2D() methods.
 

var tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
gl.pixelStorei(gl.PACK_ALIGNMENT, 4);

To check the values for packing and unpacking of pixel data, you can query the same pixel storage parameters with WebGLRenderingContext.getParameter().

gl.getParameter(gl.PACK_ALIGNMENT);
gl.getParameter(gl.UNPACK_ALIGNMENT);

Specifications

SpecificationStatusComment
WebGL 1.0
The definition of 'pixelStorei' in that specification.
RecommendationInitial definition for WebGL.
WebGL 1.0
The definition of 'Pixel Storage Parameters' in that specification.
RecommendationAdditional pixel storage parameters that aren't specified in OpenGL.
OpenGL ES 2.0
The definition of 'glPixelStorei' in that specification.
StandardMan page of the OpenGL ES 2.0 API.
WebGL 2.0
The definition of 'pixelStorei' in that specification.
Editor's DraftUpdated definition for WebGL 2.
OpenGL ES 3.0
The definition of 'glPixelStorei' in that specification.
StandardMan page of the OpenGL ES 3.0 API.

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:120 次

字数:10562

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文