From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../webglrenderingcontext/pixelstorei/index.html | 233 +++++++++++++++++++++ 1 file changed, 233 insertions(+) create mode 100644 files/zh-cn/web/api/webglrenderingcontext/pixelstorei/index.html (limited to 'files/zh-cn/web/api/webglrenderingcontext/pixelstorei') diff --git a/files/zh-cn/web/api/webglrenderingcontext/pixelstorei/index.html b/files/zh-cn/web/api/webglrenderingcontext/pixelstorei/index.html new file mode 100644 index 0000000000..1a84fa6f9a --- /dev/null +++ b/files/zh-cn/web/api/webglrenderingcontext/pixelstorei/index.html @@ -0,0 +1,233 @@ +--- +title: WebGLRenderingContext.pixelStorei() +slug: Web/API/WebGLRenderingContext/pixelStorei +translation_of: Web/API/WebGLRenderingContext/pixelStorei +--- +
{{APIRef("WebGL")}}
+ +

WebGLRenderingContext.pixelStorei() 是 WebGL API 中用于图像预处理的函数。

+ +

语法

+ +
void gl.pixelStorei(pname, param);
+
+ +

参数

+ +
+
pname
+
 {{domxref("Glenum")}} 类型 ,表示处理的方式。关于该参数可选值,请见下面表格。
+
param
+
 {{domxref("GLint")}}  类型,表示 pname 处理方式的参数。关于该参数可选值,请见下面表格。
+
+ +

返回值

+ +

None.

+ +

像素存储参数

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
模式名称 (pname)描述类型默认值 param 的可选值Specified in
gl.PACK_ALIGNMENTPacking of pixel data into memory{{domxref("GLint")}}41, 2, 4, 8OpenGL ES 2.0
gl.UNPACK_ALIGNMENTUnpacking of pixel data from memory.{{domxref("GLint")}}41, 2, 4, 8OpenGL ES 2.0
gl.UNPACK_FLIP_Y_WEBGL +

如果为true,则把图片上下对称翻转坐标轴(图片本身不变)。

+
{{domxref("GLboolean")}}falsetrue, falseWebGL
gl.UNPACK_PREMULTIPLY_ALPHA_WEBGLMultiplies the alpha channel into the other color channels{{domxref("GLboolean")}}falsetrue, falseWebGL
gl.UNPACK_COLORSPACE_CONVERSION_WEBGLDefault color space conversion or no color space conversion.{{domxref("GLenum")}}gl.BROWSER_DEFAULT_WEBGLgl.BROWSER_DEFAULT_WEBGL, gl.NONEWebGL
+ +

When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}}, the following values are available additionally:

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

Examples

+ +

Setting the pixel storage mode affects the {{domxref("WebGLRenderingContext.readPixels()")}} operations, as well as unpacking of textures with the {{domxref("WebGLRenderingContext.texImage2D()")}} and {{domxref("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 {{domxref("WebGLRenderingContext.getParameter()")}}.

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

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('WebGL', "#5.14.3", "pixelStorei")}}{{Spec2('WebGL')}}Initial definition for WebGL.
{{SpecName('WebGL', "#PIXEL_STORAGE_PARAMETERS", "Pixel Storage Parameters")}}{{Spec2('WebGL')}}Additional pixel storage parameters that aren't specified in OpenGL.
{{SpecName('OpenGL ES 2.0', "glPixelStorei.xml", "glPixelStorei")}}{{Spec2('OpenGL ES 2.0')}}Man page of the OpenGL ES 2.0 API.
{{SpecName('WebGL2', "#3.7.2", "pixelStorei")}}{{Spec2('WebGL2')}}Updated definition for WebGL 2.
{{SpecName('OpenGL ES 3.0', "glPixelStorei.xhtml", "glPixelStorei")}}{{Spec2('OpenGL ES 3.0')}}Man page of the OpenGL ES 3.0 API.
+ +

Browser compatibility

+ + + +

{{Compat("api/WebGLRenderingContext", "WebGLRenderingContext.pixelStorei")}}

+ +

See also

+ + -- cgit v1.2.3-54-g00ecf