EN
Este contenido no se encuentra disponible en su idioma, pero aquí tiene la versión en inglés.

pixelStorei method

Sets pixel storage modes for readPixels and unpacking of textures with texImage2D and texSubImage2D .

IE11

 

Syntax

WebGLRenderingContext.pixelStorei(pname, param);

Parameters

pname [in]

Type: Number

The symbolic parameter name. One of the following

ValueMeaning
gl.PACK_ALIGNMENT

Affects packing of pixel data into memory. The initial param value is 4, but it can be set to 1,2,4, or 8.

gl.UNPACK_ALIGNMENT

Affects unpacking of pixel data from memory. The initial param value is 4, but can be set to 1,2,4, or 8.

gl.UNPACK_FLIP_Y_WEBGL

Flips the source data along its vertical axis when texImage2D or texSubImage2D are called when param is true. The initial value for param is false.

gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL

Multiplies the alpha channel, if it exists, into the other color channels during the data transfer when texImage2D or texSubImage2D are called when param is true. The initial value for param is false.

gl.UNPACK_COLORSPACE_CONVERSION_WEBGL

The browser's default colorspace conversion is applied when texImage2D or texSubImage2D are called with an HTMLImageElement texture data source. The initial value for param is BROWSER_DEFAULT_WEBGL. No colorspace conversion is applied when set to NONE.

 

param [in]

Type: Number

Values depend on value of pname. See table above.

Return value

This method does not return a value.

Remarks

WebGL errorDescription
gl.INVALID_VALUE If the alignment specified is not 1,2, 4, or 8.
gl.INVALID_ENUMIf pname isn't an accepted value.

 

If a link operation fails, any info associated with a previous link operation of program is lost.

Examples

The following example uses pixelStorei to change the coordinate mapping of an image for use as a texture. For more info on this example, see Get started with WebGL.


// Create a texture object that will contain the image.
var texture = gl.createTexture();

// Bind the texture the target (TEXTURE_2D) of the active texture unit.
gl.bindTexture(gl.TEXTURE_2D, texture);

// Flip the image's Y axis to match the WebGL texture coordinate space.
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
    
// Set the parameters so we can render any size image.        
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); 
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);

  // Upload the resized canvas image into the texture.
//    Note: a canvas is used here but can be replaced by an image object. 
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas);


See also

WebGLRenderingContext

 

 

Mostrar:
© 2014 Microsoft