2.0 3.0 > comp > gb.opengl > gl > pixelstorei
Previous  Next  Edit  Rename  Undo  Search  Administration
 Documentation
Gl.PixelStorei (gb.opengl)
Static Sub PixelStorei ( Pname As Integer, Param As Integer )

Set pixel storage modes.

### Parameters

pname

Specifies the symbolic name of the parameter to be set. Six values affect the packing of pixel data into memory: Gl.PACK_SWAP_BYTES, Gl.PACK_LSB_FIRST, Gl.PACK_ROW_LENGTH, Gl.PACK_IMAGE_HEIGHT, Gl.PACK_SKIP_PIXELS, Gl.PACK_SKIP_ROWS, Gl.PACK_SKIP_IMAGES, and Gl.PACK_ALIGNMENT. Six more affect the unpacking of pixel data from memory: Gl.UNPACK_SWAP_BYTES, Gl.UNPACK_LSB_FIRST, Gl.UNPACK_ROW_LENGTH, Gl.UNPACK_IMAGE_HEIGHT, Gl.UNPACK_SKIP_PIXELS, Gl.UNPACK_SKIP_ROWS, Gl.UNPACK_SKIP_IMAGES, and Gl.UNPACK_ALIGNMENT.

param

Specifies the value that pname is set to.

### Description

Gl.PixelStore sets pixel storage modes that affect the operation of subsequent Gl.ReadPixels as well as the unpacking of texture patterns (see Gl.TexImage1D, Gl.TexImage2D, Gl.TexImage3D, Gl.TexSubImage1D, Gl.TexSubImage2D, Gl.TexSubImage3D).

pname is a symbolic constant indicating the parameter to be set, and param is the new value. Six of the twelve storage parameters affect how pixel data is returned to client memory. They are as follows:

Gl.PACK_SWAP_BYTES

If true, byte ordering for multibyte color components, depth components, or stencil indices is reversed. That is, if a four-byte Përbërës consists of bytes ${\mathit{b}}_{0}$, ${\mathit{b}}_{1}$, ${\mathit{b}}_{2}$, ${\mathit{b}}_{3}$, it is stored in memory as ${\mathit{b}}_{3}$, ${\mathit{b}}_{2}$, ${\mathit{b}}_{1}$, ${\mathit{b}}_{0}$ if Gl.PACK_SWAP_BYTES is true. Gl.PACK_SWAP_BYTES has no effect on the memory order of components within a pixel, only on the order of bytes within components or indices. For example, the three components of a Gl.RGB format pixel are always stored with red first, green second, and blue third, regardless of the value of Gl.PACK_SWAP_BYTES.

Gl.PACK_LSB_FIRST

If true, bits are ordered within a byte from least significant to most significant; otherwise, the first bit in each byte is the most significant one.

Gl.PACK_ROW_LENGTH

If greater than 0, Gl.PACK_ROW_LENGTH defines the number of pixels in a row. If the first pixel of a row is placed at location $\mathit{p}$ in memory, then the location of the first pixel of the next row is obtained by skipping

$\mathit{k}=\left\{\begin{array}{c}\mathit{n}\mathit{l}\\ \frac{\mathit{a}}{\mathit{s}}⌈\frac{\mathit{s}\mathit{n}\mathit{l}}{\mathit{a}}⌉\end{array}\begin{array}{c}\mathit{s}>=\mathit{a}\\ \mathit{s}<\mathit{a}\end{array}\right\$

components or indices, where $\mathit{n}$ is the number of components or indices in a pixel, $\mathit{l}$ is the number of pixels in a row (Gl.PACK_ROW_LENGTH if it is greater than 0, the $\mathit{width}$ argument to the pixel routine otherwise), $\mathit{a}$ is the value of Gl.PACK_ALIGNMENT, and $\mathit{s}$ is the size, in bytes, of a single component (if $\mathit{a}<\mathit{s}$, then it is as if $\mathit{a}=\mathit{s}$). In the case of 1-bit values, the location of the next row is obtained by skipping

$\mathit{k}=8\mathit{a}⌈\frac{\mathit{n}\mathit{l}}{8\mathit{a}}⌉$

components or indices.

The word component in this description refers to the nonindex values red, green, blue, alpha, and depth. Storage format Gl.RGB, for example, has three components per pixel: first red, then green, and finally blue.

Gl.PACK_IMAGE_HEIGHT

If greater than 0, Gl.PACK_IMAGE_HEIGHT defines the number of pixels in an image three-dimensional texture volume, where ``image'' is defined by all pixels sharing the same third dimension index. If the first pixel of a row is placed at location $\mathit{p}$ in memory, then the location of the first pixel of the next row is obtained by skipping

$\mathit{k}=\left\{\begin{array}{c}\mathit{n}\mathit{l}\mathit{h}\\ \frac{\mathit{a}}{\mathit{s}}⌈\frac{\mathit{s}\mathit{n}\mathit{l}\mathit{h}}{\mathit{a}}⌉\end{array}\begin{array}{c}\mathit{s}>=\mathit{a}\\ \mathit{s}<\mathit{a}\end{array}\right\$

components or indices, where $\mathit{n}$ is the number of components or indices in a pixel, $\mathit{l}$ is the number of pixels in a row (Gl.PACK_ROW_LENGTH if it is greater than 0, the $\mathit{width}$ argument to Gl.TexImage3D otherwise), $\mathit{h}$ is the number of rows in a pixel image (Gl.PACK_IMAGE_HEIGHT if it is greater than 0, the $\mathit{height}$ argument to the Gl.TexImage3D routine otherwise), $\mathit{a}$ is the value of Gl.PACK_ALIGNMENT, and $\mathit{s}$ is the size, in bytes, of a single component (if $\mathit{a}<\mathit{s}$, then it is as if $\mathit{a}=\mathit{s}$).

The word component in this description refers to the nonindex values red, green, blue, alpha, and depth. Storage format Gl.RGB, for example, has three components per pixel: first red, then green, and finally blue.

Gl.PACK_SKIP_PIXELS, Gl.PACK_SKIP_ROWS, and Gl.PACK_SKIP_IMAGES

These values are provided as a convenience to the programmer; they provide no functionality that cannot be duplicated simply by incrementing the pointer passed to Gl.ReadPixels. Setting Gl.PACK_SKIP_PIXELS to $\mathit{i}$ is equivalent to incrementing the pointer by $\mathit{i}\mathit{n}$ components or indices, where $\mathit{n}$ is the number of components or indices in each pixel. Setting Gl.PACK_SKIP_ROWS to $\mathit{j}$ is equivalent to incrementing the pointer by $\mathit{j}\mathit{m}$ components or indices, where $\mathit{m}$ is the number of components or indices per row, as just computed in the Gl.PACK_ROW_LENGTH section. Setting Gl.PACK_SKIP_IMAGES to $\mathit{k}$ is equivalent to incrementing the pointer by $\mathit{k}\mathit{p}$, where $\mathit{p}$ is the number of components or indices per image, as computed in the Gl.PACK_IMAGE_HEIGHT section.

Gl.PACK_ALIGNMENT

Specifies the alignment requirements for the start of each pixel row in memory. The allowable values are 1 (byte-alignment), 2 (rows aligned to even-numbered bytes), 4 (word-alignment), and 8 (rows start on double-word boundaries).

The other six of the twelve storage parameters affect how pixel data is read from client memory. These values are significant for Gl.TexImage1D, Gl.TexImage2D, Gl.TexImage3D, Gl.TexSubImage1D, Gl.TexSubImage2D, and Gl.TexSubImage3D

They are as follows:

Gl.UNPACK_SWAP_BYTES

If true, byte ordering for multibyte color components, depth components, or stencil indices is reversed. That is, if a four-byte component consists of bytes ${\mathit{b}}_{0}$, ${\mathit{b}}_{1}$, ${\mathit{b}}_{2}$, ${\mathit{b}}_{3}$, it is taken from memory as ${\mathit{b}}_{3}$, ${\mathit{b}}_{2}$, ${\mathit{b}}_{1}$, ${\mathit{b}}_{0}$ if Gl.UNPACK_SWAP_BYTES is true. Gl.UNPACK_SWAP_BYTES has no effect on the memory order of components within a pixel, only on the order of bytes within components or indices. For example, the three components of a Gl.RGB format pixel are always stored with red first, green second, and blue third, regardless of the value of Gl.UNPACK_SWAP_BYTES.

Gl.UNPACK_LSB_FIRST

If true, bits are ordered within a byte from least significant to most significant; otherwise, the first bit in each byte is the most significant one.

Gl.UNPACK_ROW_LENGTH

If greater than 0, Gl.UNPACK_ROW_LENGTH defines the number of pixels in a row. If the first pixel of a row is placed at location $\mathit{p}$ in memory, then the location of the first pixel of the next row is obtained by skipping

$\mathit{k}=\left\{\begin{array}{c}\mathit{n}\mathit{l}\\ \frac{\mathit{a}}{\mathit{s}}⌈\frac{\mathit{s}\mathit{n}\mathit{l}}{\mathit{a}}⌉\end{array}\begin{array}{c}\mathit{s}>=\mathit{a}\\ \mathit{s}<\mathit{a}\end{array}\right\$

components or indices, where $\mathit{n}$ is the number of components or indices in a pixel, $\mathit{l}$ is the number of pixels in a row (Gl.UNPACK_ROW_LENGTH if it is greater than 0, the $\mathit{width}$ argument to the pixel routine otherwise), $\mathit{a}$ is the value of Gl.UNPACK_ALIGNMENT, and $\mathit{s}$ is the size, in bytes, of a single component (if $\mathit{a}<\mathit{s}$, then it is as if $\mathit{a}=\mathit{s}$). In the case of 1-bit values, the location of the next row is obtained by skipping

$\mathit{k}=8\mathit{a}⌈\frac{\mathit{n}\mathit{l}}{8\mathit{a}}⌉$

components or indices.

The word component in this description refers to the nonindex values red, green, blue, alpha, and depth. Storage format Gl.RGB, for example, has three components per pixel: first red, then green, and finally blue.

Gl.UNPACK_IMAGE_HEIGHT

If greater than 0, Gl.UNPACK_IMAGE_HEIGHT defines the number of pixels in an image of a three-dimensional texture volume. Where ``image'' is defined by all pixel sharing the same third dimension index. If the first pixel of a row is placed at location $\mathit{p}$ in memory, then the location of the first pixel of the next row is obtained by skipping

$\mathit{k}=\left\{\begin{array}{c}\mathit{n}\mathit{l}\mathit{h}\\ \frac{\mathit{a}}{\mathit{s}}⌈\frac{\mathit{s}\mathit{n}\mathit{l}\mathit{h}}{\mathit{a}}⌉\end{array}\begin{array}{c}\mathit{s}>=\mathit{a}\\ \mathit{s}<\mathit{a}\end{array}\right\$

components or indices, where $\mathit{n}$ is the number of components or indices in a pixel, $\mathit{l}$ is the number of pixels in a row (Gl.UNPACK_ROW_LENGTH if it is greater than 0, the $\mathit{width}$ argument to Gl.TexImage3D otherwise), $\mathit{h}$ is the number of rows in an image (Gl.UNPACK_IMAGE_HEIGHT if it is greater than 0, the $\mathit{height}$ argument to Gl.TexImage3D otherwise), $\mathit{a}$ is the value of Gl.UNPACK_ALIGNMENT, and $\mathit{s}$ is the size, in bytes, of a single component (if $\mathit{a}<\mathit{s}$, then it is as if $\mathit{a}=\mathit{s}$).

The word component in this description refers to the nonindex values red, green, blue, alpha, and depth. Storage format Gl.RGB, for example, has three components per pixel: first red, then green, and finally blue.

Gl.UNPACK_SKIP_PIXELS and Gl.UNPACK_SKIP_ROWS

These values are provided as a convenience to the programmer; they provide no functionality that cannot be duplicated by incrementing the pointer passed to Gl.TexImage1D, Gl.TexImage2D, Gl.TexSubImage1D or Gl.TexSubImage2D. Setting Gl.UNPACK_SKIP_PIXELS to $\mathit{i}$ is equivalent to incrementing the pointer by $\mathit{i}\mathit{n}$ components or indices, where $\mathit{n}$ is the number of components or indices in each pixel. Setting Gl.UNPACK_SKIP_ROWS to $\mathit{j}$ is equivalent to incrementing the pointer by $\mathit{j}\mathit{k}$ components or indices, where $\mathit{k}$ is the number of components or indices per row, as just computed in the Gl.UNPACK_ROW_LENGTH section.

Gl.UNPACK_ALIGNMENT

Specifies the alignment requirements for the start of each pixel row in memory. The allowable values are 1 (byte-alignment), 2 (rows aligned to even-numbered bytes), 4 (word-alignment), and 8 (rows start on double-word boundaries).

The following table gives the type, initial value, and range of valid values for each storage parameter that can be set with Gl.PixelStore.

pname Type Initial Value Valid Range
Gl.PACK_SWAP_BYTES boolean false true or false
Gl.PACK_LSB_FIRST boolean false true or false
Gl.PACK_ROW_LENGTH integer 0 $\left[0,\infty \right)$
Gl.PACK_IMAGE_HEIGHT integer 0 $\left[0,\infty \right)$
Gl.PACK_SKIP_ROWS integer 0 $\left[0,\infty \right)$
Gl.PACK_SKIP_PIXELS integer 0 $\left[0,\infty \right)$
Gl.PACK_SKIP_IMAGES integer 0 $\left[0,\infty \right)$
Gl.PACK_ALIGNMENT integer 4 1, 2, 4, or 8
Gl.UNPACK_SWAP_BYTES boolean false true or false
Gl.UNPACK_LSB_FIRST boolean false true or false
Gl.UNPACK_ROW_LENGTH integer 0 $\left[0,\infty \right)$
Gl.UNPACK_IMAGE_HEIGHT integer 0 $\left[0,\infty \right)$
Gl.UNPACK_SKIP_ROWS integer 0 $\left[0,\infty \right)$
Gl.UNPACK_SKIP_PIXELS integer 0 $\left[0,\infty \right)$
Gl.UNPACK_SKIP_IMAGES integer 0 $\left[0,\infty \right)$
Gl.UNPACK_ALIGNMENT integer 4 1, 2, 4, or 8

Gl.PixelStoref can be used to set any pixel store parameter. If the parameter type is boolean, then if param is 0, the parameter is false; otherwise it is set to true. If pname is a integer type parameter, param is rounded to the nearest integer.

Likewise, Gl.PixelStorei can also be used to set any of the pixel store parameters. Boolean parameters are set to false if param is 0 and true otherwise.

### Errors

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

Gl.INVALID_VALUE is generated if a negative row length, pixel skip, or row skip value is specified, or if alignment is specified as other than 1, 2, 4, or 8.

### Associated Gets

Gl.Get with argument Gl.PACK_SWAP_BYTES

Gl.Get with argument Gl.PACK_LSB_FIRST

Gl.Get with argument Gl.PACK_ROW_LENGTH

Gl.Get with argument Gl.PACK_IMAGE_HEIGHT

Gl.Get with argument Gl.PACK_SKIP_ROWS

Gl.Get with argument Gl.PACK_SKIP_PIXELS

Gl.Get with argument Gl.PACK_SKIP_IMAGES

Gl.Get with argument Gl.PACK_ALIGNMENT

Gl.Get with argument Gl.UNPACK_SWAP_BYTES

Gl.Get with argument Gl.UNPACK_LSB_FIRST

Gl.Get with argument Gl.UNPACK_ROW_LENGTH

Gl.Get with argument Gl.UNPACK_IMAGE_HEIGHT

Gl.Get with argument Gl.UNPACK_SKIP_ROWS

Gl.Get with argument Gl.UNPACK_SKIP_PIXELS

Gl.Get with argument Gl.UNPACK_SKIP_IMAGES

Gl.Get with argument Gl.UNPACK_ALIGNMENT