aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/webglrenderingcontext/pixelstorei
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/webglrenderingcontext/pixelstorei
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/webglrenderingcontext/pixelstorei')
-rw-r--r--files/zh-cn/web/api/webglrenderingcontext/pixelstorei/index.html233
1 files changed, 233 insertions, 0 deletions
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
+---
+<div>{{APIRef("WebGL")}}</div>
+
+<p><strong><code>WebGLRenderingContext.pixelStorei()</code></strong> 是 <a href="/en-US/docs/Web/API/WebGL_API">WebGL API</a> 中用于图像预处理的函数。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">void <var>gl</var>.pixelStorei(<var>pname</var>, <var>param</var>);
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt>pname</dt>
+ <dd> {{domxref("Glenum")}} 类型 ,表示处理的方式。关于该参数可选值,请见下面表格。</dd>
+ <dt>param</dt>
+ <dd> {{domxref("GLint")}}  类型,表示 pname 处理方式的参数。关于该参数可选值,请见下面表格。</dd>
+</dl>
+
+<h3 id="返回值">返回值</h3>
+
+<p>None.</p>
+
+<h2 id="像素存储参数">像素存储参数</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">模式名称 (<code>pname</code>)</th>
+ <th scope="col">描述</th>
+ <th scope="col">类型</th>
+ <th scope="col">默认值</th>
+ <th scope="col"> param 的可选值</th>
+ <th scope="col">Specified in</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>gl.PACK_ALIGNMENT</code></td>
+ <td>Packing of pixel data into memory</td>
+ <td>{{domxref("GLint")}}</td>
+ <td>4</td>
+ <td>1, 2, 4, 8</td>
+ <td>OpenGL ES 2.0</td>
+ </tr>
+ <tr>
+ <td><code>gl.UNPACK_ALIGNMENT</code></td>
+ <td>Unpacking of pixel data from memory.</td>
+ <td>{{domxref("GLint")}}</td>
+ <td>4</td>
+ <td>1, 2, 4, 8</td>
+ <td>OpenGL ES 2.0</td>
+ </tr>
+ <tr>
+ <td><code>gl.UNPACK_FLIP_Y_WEBGL</code></td>
+ <td>
+ <p dir="ltr" id="tw-target-text">如果为true,则把图片上下对称翻转坐标轴(图片本身不变)。</p>
+ </td>
+ <td>{{domxref("GLboolean")}}</td>
+ <td>false</td>
+ <td>true, false</td>
+ <td>WebGL</td>
+ </tr>
+ <tr>
+ <td><code>gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL</code></td>
+ <td>Multiplies the alpha channel into the other color channels</td>
+ <td>{{domxref("GLboolean")}}</td>
+ <td>false</td>
+ <td>true, false</td>
+ <td>WebGL</td>
+ </tr>
+ <tr>
+ <td><code>gl.UNPACK_COLORSPACE_CONVERSION_WEBGL</code></td>
+ <td>Default color space conversion or no color space conversion.</td>
+ <td>{{domxref("GLenum")}}</td>
+ <td><code>gl.BROWSER_DEFAULT_WEBGL</code></td>
+ <td><code>gl.BROWSER_DEFAULT_WEBGL</code>, <code>gl.NONE</code></td>
+ <td>WebGL</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}}, the following values are available additionally:</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Constant</th>
+ <th scope="col">Description</th>
+ <th scope="col">Type</th>
+ <th scope="col">Default value</th>
+ <th scope="col">Allowed values (for <code>param</code>)</th>
+ <th scope="col">Specified in</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>gl.PACK_ROW_LENGTH</code></td>
+ <td>Number of pixels in a row.</td>
+ <td>{{domxref("GLint")}}</td>
+ <td>0</td>
+ <td>0 to <code>Infinity</code></td>
+ <td>OpenGL ES 3.0</td>
+ </tr>
+ <tr>
+ <td><code>gl.PACK_SKIP_PIXELS</code></td>
+ <td>Number of pixel locations skipped before the first pixel is written into memory.</td>
+ <td>{{domxref("GLint")}}</td>
+ <td>0</td>
+ <td>0 to <code>Infinity</code></td>
+ <td>OpenGL ES 3.0</td>
+ </tr>
+ <tr>
+ <td><code>gl.PACK_SKIP_ROWS</code></td>
+ <td>Number of rows of pixel locations skipped before the first pixel is written into memory</td>
+ <td>{{domxref("GLint")}}</td>
+ <td>0</td>
+ <td>0 to <code>Infinity</code></td>
+ <td>OpenGL ES 3.0</td>
+ </tr>
+ <tr>
+ <td><code>gl.UNPACK_ROW_LENGTH</code></td>
+ <td>Number of pixels in a row.</td>
+ <td>{{domxref("GLint")}}</td>
+ <td>0</td>
+ <td>0 to <code>Infinity</code></td>
+ <td>OpenGL ES 3.0</td>
+ </tr>
+ <tr>
+ <td><code>gl.UNPACK_IMAGE_HEIGHT</code></td>
+ <td>Image height used for reading pixel data from memory</td>
+ <td>{{domxref("GLint")}}</td>
+ <td>0</td>
+ <td>0 to <code>Infinity</code></td>
+ <td>OpenGL ES 3.0</td>
+ </tr>
+ <tr>
+ <td><code>gl.UNPACK_SKIP_PIXELS</code></td>
+ <td>Number of pixel images skipped before the first pixel is read from memory</td>
+ <td>{{domxref("GLint")}}</td>
+ <td>0</td>
+ <td>0 to <code>Infinity</code></td>
+ <td>OpenGL ES 3.0</td>
+ </tr>
+ <tr>
+ <td><code>gl.UNPACK_SKIP_ROWS</code></td>
+ <td>Number of rows of pixel locations skipped before the first pixel is read from memory</td>
+ <td>{{domxref("GLint")}}</td>
+ <td>0</td>
+ <td>0 to <code>Infinity</code></td>
+ <td>OpenGL ES 3.0</td>
+ </tr>
+ <tr>
+ <td><code>gl.UNPACK_SKIP_IMAGES</code></td>
+ <td>Number of pixel images skipped before the first pixel is read from memory</td>
+ <td>{{domxref("GLint")}}</td>
+ <td>0</td>
+ <td>0 to <code>Infinity</code></td>
+ <td>OpenGL ES 3.0</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Examples">Examples</h2>
+
+<p>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.<br>
+  </p>
+
+<pre class="brush: js">var tex = gl.createTexture();
+gl.bindTexture(gl.TEXTURE_2D, tex);
+gl.pixelStorei(gl.PACK_ALIGNMENT, 4);
+</pre>
+
+<p>To check the values for packing and unpacking of pixel data, you can query the same pixel storage parameters with {{domxref("WebGLRenderingContext.getParameter()")}}.</p>
+
+<pre class="brush: js">gl.getParameter(gl.PACK_ALIGNMENT);
+gl.getParameter(gl.UNPACK_ALIGNMENT);
+</pre>
+
+<h2 id="Specifications">Specifications</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('WebGL', "#5.14.3", "pixelStorei")}}</td>
+ <td>{{Spec2('WebGL')}}</td>
+ <td>Initial definition for WebGL.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('WebGL', "#PIXEL_STORAGE_PARAMETERS", "Pixel Storage Parameters")}}</td>
+ <td>{{Spec2('WebGL')}}</td>
+ <td>Additional pixel storage parameters that aren't specified in OpenGL.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('OpenGL ES 2.0', "glPixelStorei.xml", "glPixelStorei")}}</td>
+ <td>{{Spec2('OpenGL ES 2.0')}}</td>
+ <td>Man page of the OpenGL ES 2.0 API.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('WebGL2', "#3.7.2", "pixelStorei")}}</td>
+ <td>{{Spec2('WebGL2')}}</td>
+ <td>Updated definition for WebGL 2.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('OpenGL ES 3.0', "glPixelStorei.xhtml", "glPixelStorei")}}</td>
+ <td>{{Spec2('OpenGL ES 3.0')}}</td>
+ <td>Man page of the OpenGL ES 3.0 API.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("api/WebGLRenderingContext", "WebGLRenderingContext.pixelStorei")}}</p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li>{{domxref("WebGLRenderingContext.readPixels()")}}</li>
+ <li>{{domxref("WebGLRenderingContext.texImage2D()")}}</li>
+ <li>{{domxref("WebGLRenderingContext.texSubImage2D()")}}</li>
+</ul>