2.0 3.0  > comp > gb.opengl > gl > copypixels
Anterior  Próximo  Editar  Renomear  Desfazer  Procurar  Administração

Documentação
Cuidado! Esta página não está traduziada.  Veja a versão em inglês
Gl.CopyPixels (gb.opengl)
`Static Sub CopyPixels ( X As Integer, Y As Integer, Width As Integer, Height As Integer, Buffer As Integer )`

Copy pixels in the frame buffer.

### Parameters

x, y

Specify the window coordinates of the lower left corner of the rectangular region of pixels to be copied.

width, height

Specify the dimensions of the rectangular region of pixels to be copied. Both must be nonnegative.

type

Specifies whether color values, depth values, or stencil values are to be copied. Symbolic constants Gl.COLOR, Gl.DEPTH, and Gl.STENCIL are accepted.

### Description

Gl.CopyPixels copies a screen-aligned rectangle of pixels from the specified frame buffer location to a region relative to the current raster position. Its operation is well defined only if the entire pixel source region is within the exposed portion of the window. Results of copies from outside the window, or from regions of the window that are not exposed, are hardware dependent and undefined.

x and y specify the window coordinates of the lower left corner of the rectangular region to be copied. width and height specify the dimensions of the rectangular region to be copied. Both width and height must not be negative.

Several parameters control the processing of the pixel data while it is being copied. These parameters are set with three commands: Gl.PixelTransfer, Gl.PixelMap, and Gl.PixelZoom. This reference page describes the effects on Gl.CopyPixels of most, but not all, of the parameters specified by these three commands.

Gl.CopyPixels copies values from each pixel with the lower left-hand corner at $\left(\mathit{x}+\mathit{i},\mathit{y}+\mathit{j}\right)$ for $0<=\mathit{i}<\mathit{width}$ and $0<=\mathit{j}<\mathit{height}$. This pixel is said to be the $\mathit{i}$th pixel in the $\mathit{j}$th row. Pixels are copied in row order from the lowest to the highest row, left to right in each row.

type specifies whether color, depth, or stencil data is to be copied. The details of the transfer for each data type are as follows:

Gl.COLOR

Indices or RGBA colors are read from the buffer currently specified as the read source buffer (see Gl.ReadBuffer). If the GL is in color index mode, each index that is read from this buffer is converted to a fixed-point format with an unspecified number of bits to the right of the binary point. Each index is then shifted left by Gl.INDEX_SHIFT bits, and added to Gl.INDEX_OFFSET. If Gl.INDEX_SHIFT is negative, the shift is to the right. In either case, zero bits fill otherwise unspecified bit locations in the result. If Gl.MAP_COLOR is true, the index is replaced with the value that it references in lookup table Gl.PIXEL_MAP_I_TO_I. Whether the lookup replacement of the index is done or not, the integer part of the index is then ANDed with ${2}^{\mathit{b}}-1$, where $\mathit{b}$ is the number of bits in a color index buffer.

If the GL is in RGBA mode, the red, green, blue, and alpha components of each pixel that is read are converted to an internal floating-point format with unspecified precision. The conversion maps the largest representable componente value to 1.0, and component value 0 to 0.0. The resulting floating-point color values are then multiplied by Gl.c_SCALE and added to Gl.c_BIAS, where c is RED, GREEN, BLUE, and ALPHA for the respective color components. The results are clamped to the range 0,1. If Gl.MAP_COLOR is true, each color component is scaled by the size of lookup table Gl.PIXEL_MAP_c_TO_c, then replaced by the value that it references in that table. c is R, G, B, or A.

If the ARB_imaging extension is supported, the color values may be additionally processed by color-table lookups, color-matrix transformations, and convolution filters.

The GL then converts the resulting indices or RGBA colors to fragments by attaching the current raster position z coordinate and texture coordinates to each pixel, then assigning window coordinates $\left({\mathit{x}}_{\mathit{r}}+\mathit{i},{\mathit{y}}_{\mathit{r}}+\mathit{j}\right)$, where $\left({\mathit{x}}_{\mathit{r}},{\mathit{y}}_{\mathit{r}}\right)$ is the current raster position, and the pixel was the $\mathit{i}$th pixel in the $\mathit{j}$th row. These pixel fragments are then treated just like the fragments generated by rasterizing points, lines, or polygons. Texture mapping, fog, and all the fragment operations are applied before the fragments are written to the frame buffer.

Gl.DEPTH

Depth values are read from the depth buffer and converted directly to an internal floating-point format with unspecified precision. The resulting floating-point depth value is then multiplied by Gl.DEPTH_SCALE and added to Gl.DEPTH_BIAS. The result is clamped to the range 0,1.

The GL then converts the resulting depth components to fragments by attaching the current raster position color or color index and texture coordinates to each pixel, then assigning window coordinates $\left({\mathit{x}}_{\mathit{r}}+\mathit{i},{\mathit{y}}_{\mathit{r}}+\mathit{j}\right)$, where $\left({\mathit{x}}_{\mathit{r}},{\mathit{y}}_{\mathit{r}}\right)$ is the current raster position, and the pixel was the $\mathit{i}$th pixel in the $\mathit{j}$th row. These pixel fragments are then treated just like the fragments generated by rasterizing points, lines, or polygons. Texture mapping, fog, and all the fragment operations are applied before the fragments are written to the frame buffer.

Gl.STENCIL

Stencil indices are read from the stencil buffer and converted to an internal fixed-point format with an unspecified number of bits to the right of the binary point. Each fixed-point index is then shifted left by Gl.INDEX_SHIFT bits, and added to Gl.INDEX_OFFSET. If Gl.INDEX_SHIFT is negative, the shift is to the right. In either case, zero bits fill otherwise unspecified bit locations in the result. If Gl.MAP_STENCIL is true, the index is replaced with the value that it references in lookup table Gl.PIXEL_MAP_S_TO_S. Whether the lookup replacement of the index is done or not, the integer part of the index is then ANDed with ${2}^{\mathit{b}}-1$, where $\mathit{b}$ is the number of bits in the stencil buffer. The resulting stencil indices are then written to the stencil buffer such that the index read from the $\mathit{i}$th location of the $\mathit{j}$th row is written to location $\left({\mathit{x}}_{\mathit{r}}+\mathit{i},{\mathit{y}}_{\mathit{r}}+\mathit{j}\right)$, where $\left({\mathit{x}}_{\mathit{r}},{\mathit{y}}_{\mathit{r}}\right)$ is the current raster position. Only the pixel ownership test, the scissor test, and the stencil writemask affect these write operations.

The rasterization described thus far assumes pixel zoom factors of 1.0. If Gl.PixelZoom is used to change the $\mathit{x}$ and $\mathit{y}$ pixel zoom factors, pixels are converted to fragments as follows. If $\left({\mathit{x}}_{\mathit{r}},{\mathit{y}}_{\mathit{r}}\right)$ is the current raster position, and a given pixel is in the $\mathit{i}$th location in the $\mathit{j}$th row of the source pixel rectangle, then fragments are generated for pixels whose centers are in the rectangle with corners at

$\left({\mathit{x}}_{\mathit{r}}+{\mathit{zoom}}_{\mathit{x}}\mathit{i},{\mathit{y}}_{\mathit{r}}+{\mathit{zoom}}_{\mathit{y}}\mathit{j}\right)$

and

$\left({\mathit{x}}_{\mathit{r}}+{\mathit{zoom}}_{\mathit{x}}\left(\mathit{i}+1\right),{\mathit{y}}_{\mathit{r}}+{\mathit{zoom}}_{\mathit{y}}\left(\mathit{j}+1\right)\right)$

where ${\mathit{zoom}}_{\mathit{x}}$ is the value of Gl.ZOOM_X and ${\mathit{zoom}}_{\mathit{y}}$ is the value of Gl.ZOOM_Y.

### Examples

To copy the color pixel in the lower left corner of the window to the current raster position, use

```glCopyPixels(0, 0, 1, 1, Gl.COLOR);
```

### Notes

Modes specified by Gl.PixelStore have no effect on the operation of Gl.CopyPixels.

### Errors

Gl.INVALID_ENUM is generated if type is not an accepted value.

Gl.INVALID_VALUE is generated if either width or height is negative.

Gl.INVALID_OPERATION is generated if type is Gl.DEPTH and there is no depth buffer.

Gl.INVALID_OPERATION is generated if type is Gl.STENCIL and there is no stencil buffer.

Gl.INVALID_OPERATION is generated if Gl.CopyPixels is executed between the execution of Gl.Begin and the corresponding execution of Gl.End.

### Associated Gets

Gl.Get with argument Gl.CURRENT_RASTER_POSITION

Gl.Get with argument Gl.CURRENT_RASTER_POSITION_VALID

### Veja também

Gl.ColorTable, Gl.ConvolutionFilter1D, Gl.ConvolutionFilter2D, Gl.DepthFunc, Gl.DrawBuffer, Gl.DrawPixels, Gl.MatrixMode, Gl.PixelMap, Gl.PixelTransfer, Gl.PixelZoom, Gl.RasterPos, Gl.ReadBuffer, Gl.ReadPixels, Gl.SeparableFilter2D, Gl.StencilFunc, Gl.WindowPos

See original documentation on OpenGL website
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 30, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.8141686916351318, "perplexity_flag": "middle"}