glPixelTransfer(3G) OpenGL Reference glPixelTransfer(3G)
NAME
glPixelTransferf, glPixelTransferi - set pixel transfer modes
C SPECIFICATION
void glPixelTransferf( GLenum pname,
GLfloat param )
void glPixelTransferi( GLenum pname,
GLint param )
PARAMETERS
pname Specifies the symbolic name of the pixel transfer parameter to be
set. Must be one of the following: GLMAPCOLOR, GLMAPSTENCIL,
GLINDEXSHIFT, GLINDEXOFFSET, GLREDSCALE, GLREDBIAS,
GLGREENSCALE, GLGREENBIAS, GLBLUESCALE, GLBLUEBIAS,
GLALPHASCALE, GLALPHABIAS, GLDEPTHSCALE, GLDEPTHBIAS,
GLPOSTCOLORMATRIXREDSCALESGI,
GLPOSTCOLORMATRIXGREENSCALESGI,
GLPOSTCOLORMATRIXBLUESCALESGI,
GLPOSTCOLORMATRIXALPHASCALESGI,
GLPOSTCOLORMATRIXREDBIASSGI,
GLPOSTCOLORMATRIXGREENBIASSGI,
GLPOSTCOLORMATRIXBLUEBIASSGI,
GLPOSTCOLORMATRIXALPHABIASSGI,
GLPOSTCONVOLUTIONREDSCALEEXT,
GLPOSTCONVOLUTIONGREENSCALEEXT,
GLPOSTCONVOLUTIONBLUESCALEEXT,
GLPOSTCONVOLUTIONALPHASCALEEXT,
GLPOSTCONVOLUTIONREDBIASEXT,
GLPOSTCONVOLUTIONGREENBIASEXT,
GLPOSTCONVOLUTIONBLUEBIASEXT, or
GLPOSTCONVOLUTIONALPHABIASEXT.
param Specifies the value to be assigned to pname.
DESCRIPTION
glPixelTransfer sets pixel transfer modes that affect the operation of
subsequent glDrawPixels, glReadPixels, glCopyPixels, glTexImage1D,
glTexImage2D, glTexImage3DEXT, glTexSubImage1D (or glTexSubImage1DEXT),
glTexSubImage2D (or glTexSubImage2DEXT), glTexSubImage3DEXT,
glCopyTexImage1D (or glCopyTexImage1DEXT), glCopyTexImage2D(or
glCopyTexImage2DEXT), glCopyTexImage3DEXT, glCopyTexSubImage1D (or
glCopyTexSubImage1DEXT), glCopyTexSubImage2D (or glCopyTexSubImage2DEXT),
and glCopyTexSubImage3DEXT commands. The algorithms that are specified
by pixel transfer modes operate on pixels after they are read from the
frame buffer (for glReadPixels, glCopyPixels, and the glCopyTex*
commands) or unpacked from client memory (for glDrawPixels, the
glTexImage* commands, and the glTexSubImage* commands). Pixel transfer
operations happen in the same order, and in the same manner, regardless
of the command that resulted in the pixel operation. Pixel storage modes
(see glPixelStore) control the unpacking of pixels being read from client
Page 1
glPixelTransfer(3G) OpenGL Reference glPixelTransfer(3G)
memory, and the packing of pixels being written back into client memory.
Pixel transfer operations handle four fundamental pixel types: color,
color index, depth, and stencil. Color pixels are made up of four
floating-point values with unspecified mantissa and exponent sizes,
scaled such that 0 represents zero intensity and 1 represents full
intensity. Color indices comprise a single fixed-point value, with
unspecified precision to the right of the binary point. Depth pixels
comprise a single floating-point value, with unspecified mantissa and
exponent sizes, scaled such that 0.0 represents the minimum depth buffer
value, and 1.0 represents the maximum depth buffer value. Finally,
stencil pixels comprise a single fixed-point value, with unspecified
precision to the right of the binary point.
The pixel transfer operations performed on the four basic pixel types are
as follows:
Color Each of the four color components is multiplied by a scale
factor, then added to a bias factor. That is, the red
component is multiplied by GLREDSCALE, then added to
GLREDBIAS; the green component is multiplied by
GLGREENSCALE, then added to GLGREENBIAS; the blue
component is multiplied by GLBLUESCALE, then added to
GLBLUEBIAS; and the alpha component is multiplied by
GLALPHASCALE, then added to GLALPHABIAS. After all four
color components are scaled and biased, each is clamped to
the range [0,1]. All color, scale, and bias values are
specified with glPixelTransfer.
If GLMAPCOLOR is true, each color component is scaled by
the size of the corresponding color-to-color map, then
replaced by the contents of that map indexed by the scaled
component. That is, the red component is scaled by
GLPIXELMAPRTORSIZE, then replaced by the contents of
GLPIXELMAPRTOR indexed by itself. The green component
is scaled by GLPIXELMAPGTOGSIZE, then replaced by the
contents of GLPIXELMAPGTOG indexed by itself. The blue
component is scaled by GLPIXELMAPBTOBSIZE, then
replaced by the contents of GLPIXELMAPBTOB indexed by
itself. And the alpha component is scaled by
GLPIXELMAPATOASIZE, then replaced by the contents of
GLPIXELMAPATOA indexed by itself. All components taken
from the maps are then clamped to the range [0,1].
GLMAPCOLOR is specified with glPixelTransfer. The contents
of the various maps are specified with glPixelMap.
If the SGIcolortable extension is supported,
GLCOLORTABLESGI is enabled, and the width of the color
table is non-zero, then its contents are used to replace a
subset of the components of each RGBA pixel group, based on
the internal format of the table. All the color table lookups
introduced by the SGIcolortable extension behave
Page 2
glPixelTransfer(3G) OpenGL Reference glPixelTransfer(3G)
identically: The color components are first rescaled to the
size of the color lookup table to form an index. Then a
subset of the components based on the internal format of the
table are replaced by the table entry selected by that index.
(See glColorTableSGI for more information.)
If the EXTconvolution extension is supported, and
GLCONVOLUTION1DEXT, GLCONVOLUTION2DEXT, or
GLSEPARABLE2DEXT is enabled, the pixels are convolved with
a filter kernel, then scaled and biased. (See
glConvolutionFilter1DEXT, glConvolutionFilter2DEXT,
glSeparableFilter2DEXT, and glEnable.) The scale and bias
parameters are specified by executing glPixelTransfer with
pname equal to GLPOSTCONVOLUTIONREDSCALEEXT,
GLPOSTCONVOLUTIONGREENSCALEEXT,
GLPOSTCONVOLUTIONBLUESCALEEXT,
GLPOSTCONVOLUTIONALPHASCALEEXT,
GLPOSTCONVOLUTIONREDBIASEXT,
GLPOSTCONVOLUTIONGREENBIASEXT,
GLPOSTCONVOLUTIONBLUEBIASEXT, and
GLPOSTCONVOLUTIONALPHABIASEXT. A color lookup is then
performed if the SGIcolortable extension is supported and
GLPOSTCONVOLUTIONCOLORTABLESGI is enabled.
If the SGIcolormatrix extension is supported, then the
color components of each pixel are modified by multiplying
them with the matrix at the top of the color matrix stack,
scaling them by specified values, and then biasing
(offsetting) them by specified values. That is, if the
original color components are (R, G, B, A), and the matrix at
the top of the color matrix stack is represented by m1, m2,
..., m16, then the modified color components (R', G', B', A')
are given by:
R' = ((m1*R) + (m5*G) + (m9*B) + (m13*A))*Rscale + Rbias
G' = ((m2*R) + (m6*G) + (m10*B) + (m14*A))*Gscale + Gbias
B' = ((m3*R) + (m7*G) + (m11*B) + (m15*A))*Bscale + Bbias
A' = ((m4*R) + (m8*G) + (m12*B) + (m16*A))*Ascale + Abias
The color matrix is specified using any of the OpenGL matrix
commands when the matrix mode (see glMatrixMode) is GLCOLOR.
The scale and bias terms are specified by executing
glPixelTransfer with pname equal to
GLPOSTCOLORMATRIXREDSCALESGI,
GLPOSTCOLORMATRIXGREENSCALESGI,
GLPOSTCOLORMATRIXBLUESCALESGI,
GLPOSTCOLORMATRIXALPHASCALESGI,
GLPOSTCOLORMATRIXREDBIASSGI,
GLPOSTCOLORMATRIXGREENBIASSGI,
GLPOSTCOLORMATRIXBLUEBIASSGI, or
GLPOSTCOLORMATRIXALPHABIASSGI and param equal to the
desired value.
Page 3
glPixelTransfer(3G) OpenGL Reference glPixelTransfer(3G)
A color lookup is also performed after the color matrix
operation if the SGIcolormatrix extension is supported, and
GLPROXYPOSTCOLORMATRIXCOLORTABLESGI is enabled.
If the EXThistogram extension is supported, and
GLHISTOGRAMEXT is enabled, the pixels are histogrammed.
See glHistogramEXT for more information.
If the EXThistogram extension is supported, and
GLMINMAXEXT is enabled, the minimum and maximum pixel
values are recorded. See glMinMaxEXT for more information.
Color index Each color index is shifted left by GLINDEXSHIFT bits; any
bits beyond the number of fraction bits carried by the
fixed-point index are filled with zeros. If GLINDEXSHIFT
is negative, the shift is to the right, again zero filled.
Then GLINDEXOFFSET is added to the index. GLINDEXSHIFT
and GLINDEXOFFSET are specified with glPixelTransfer.
From this point, operation diverges depending on the required
format of the resulting pixels. If the resulting pixels are
to be written to a color index buffer, or if they are being
read back to client memory in GLCOLORINDEX format, the
pixels continue to be treated as indices. If GLMAPCOLOR is
n
true, each index is masked by 2 - 1, where n is
GLPIXELMAPITOISIZE, then replaced by the contents of
GLPIXELMAPITOI indexed by the masked value.
GLMAPCOLOR is specified with glPixelTransfer. The contents
of the index map are specified with glPixelMap.
If the resulting pixels are to be written to an RGBA color
buffer, or if they are being read back to client memory in a
format other than GLCOLORINDEX, the pixels are converted
from indices to colors by referencing the four maps
GLPIXELMAPITOR, GLPIXELMAPITOG,
GLPIXELMAPITOB, and GLPIXELMAPITOA. Before being
n
dereferenced, the index is masked by 2 - 1, where n is
GLPIXELMAPITORSIZE for the red map,
GLPIXELMAPITOGSIZE for the green map,
GLPIXELMAPITOBSIZE for the blue map, and
GLPIXELMAPITOASIZE for the alpha map. All components
taken from the maps are then clamped to the range [0,1]. The
contents of the four maps are specified with glPixelMap.
The remaining pixel transfer operations described above are
then applied to the resulting RGBA components.
Depth Each depth value is multiplied by GLDEPTHSCALE, added to
GLDEPTHBIAS, then clamped to the range [0,1].
Page 4
glPixelTransfer(3G) OpenGL Reference glPixelTransfer(3G)
Stencil Each index is shifted GLINDEXSHIFT bits just as a color
index is, then added to GLINDEXOFFSET. If GLMAPSTENCIL
n
is true, each index is masked by 2 - 1, where n is
GLPIXELMAPSTOSSIZE, then replaced by the contents of
GLPIXELMAPSTOS indexed by the masked value.
The following table gives the type, initial value, and range of valid
values for each of the pixel transfer parameters that are set with
glPixelTransfer.
pname type initial value valid range
____________________________________________________________________________
GLMAPCOLOR boolean false true/false
GLMAPSTENCIL boolean false true/false
GLINDEXSHIFT integer 0 (-oo,oo)
GLINDEXOFFSET integer 0 (-oo,oo)
GLREDSCALE float 1.0 (-oo,oo)
GLGREENSCALE float 1.0 (-oo,oo)
GLBLUESCALE float 1.0 (-oo,oo)
GLALPHASCALE float 1.0 (-oo,oo)
GLDEPTHSCALE float 1.0 (-oo,oo)
GLREDBIAS float 0.0 (-oo,oo)
GLGREENBIAS float 0.0 (-oo,oo)
GLBLUEBIAS float 0.0 (-oo,oo)
GLALPHABIAS float 0.0 (-oo,oo)
GLDEPTHBIAS float 0.0 (-oo,oo)
GLPOSTCOLORMATRIXREDSCALESGI float 1.0 (-oo,oo)
GLPOSTCOLORMATRIXGREENSCALESGI float 1.0 (-oo,oo)
GLPOSTCOLORMATRIXBLUESCALESGI float 1.0 (-oo,oo)
GLPOSTCOLORMATRIXALPHASCALESGI float 1.0 (-oo,oo)
GLPOSTCOLORMATRIXREDBIASSGI float 0.0 (-oo,oo)
GLPOSTCOLORMATRIXGREENBIASSGI float 0.0 (-oo,oo)
GLPOSTCOLORMATRIXBLUEBIASSGI float 0.0 (-oo,oo)
GLPOSTCOLORMATRIXALPHABIASSGI float 0.0 (-oo,oo)
GLPOSTCONVOLUTIONREDSCALEEXT float 1.0 (-oo,oo)
GLPOSTCONVOLUTIONGREENSCALEEXT float 1.0 (-oo,oo)
GLPOSTCONVOLUTIONBLUESCALEEXT float 1.0 (-oo,oo)
GLPOSTCONVOLUTIONALPHASCALEEXT float 1.0 (-oo,oo)
GLPOSTCONVOLUTIONREDBIASEXT float 0.0 (-oo,oo)
GLPOSTCONVOLUTIONGREENBIASEXT float 0.0 (-oo,oo)
GLPOSTCONVOLUTIONBLUEBIASEXT float 0.0 (-oo,oo)
GLPOSTCONVOLUTIONALPHABIASEXT float 0.0 (-oo,oo)
glPixelTransferf can be used to set any pixel transfer parameter. If the
parameter type is boolean, 0.0 implies false and any other value implies
true. If pname is an integer parameter, param is rounded to the nearest
integer.
Likewise, glPixelTransferi can also be used to set any of the pixel
transfer parameters. Boolean parameters are set to false if param is 0
and true otherwise. param is converted to floating point before being
assigned to real-valued parameters.
Page 5
glPixelTransfer(3G) OpenGL Reference glPixelTransfer(3G)
NOTES
If a glDrawPixels, glReadPixels, glCopyPixels, glTexImage1D,
glTexImage2D, glTexImage3DEXT, glTexSubImage1D (or glTexSubImage1DEXT),
glTexSubImage2D (or glTexSubImage2DEXT), glTexSubImage3DEXT,
glCopyTexImage1D (or glCopyTexImage1DEXT), glCopyTexImage2D(or
glCopyTexImage2DEXT), glCopyTexImage3DEXT, glCopyTexSubImage1D (or
glCopyTexSubImage1DEXT), glCopyTexSubImage2D (or glCopyTexSubImage2DEXT),
or glCopyTexSubImage3DEXT command is placed in a display list (see
glNewList and glCallList), the pixel transfer mode settings in effect
when the display list is executed are the ones that are used. They may
be different from the settings when the command was compiled into the
display list.
The color matrix may be used for simple linear color-space conversions.
However, it is also useful for ``swizzling'' (reordering or duplicating)
color components. This is helpful when processing image data that is not
in one of the native OpenGL formats, or when ``packing'' up to four
independent channels of luminance data into an RGBA drawable.
glTexSubImage1D, glTexSubImage2D, glCopyTexImage1D, glCopyTexImage2D,
glCopyTexSubImage1D, and glCopyTexSubImage2D are available only of the GL
version is 1.1 or greater.
ERRORS
GLINVALIDENUM is generated if pname is not an accepted value.
GLINVALIDOPERATION is generated if glPixelTransfer is executed between
the execution of glBegin and the corresponding execution of glEnd.
ASSOCIATED GETS
glGet with argument GLMAPCOLOR
glGet with argument GLMAPSTENCIL
glGet with argument GLINDEXSHIFT
glGet with argument GLINDEXOFFSET
glGet with argument GLREDSCALE
glGet with argument GLREDBIAS
glGet with argument GLGREENSCALE
glGet with argument GLGREENBIAS
glGet with argument GLBLUESCALE
glGet with argument GLBLUEBIAS
glGet with argument GLALPHASCALE
glGet with argument GLALPHABIAS
glGet with argument GLDEPTHSCALE
glGet with argument GLDEPTHBIAS
glGet with argument GLPOSTCOLORMATRIXREDSCALESGI
glGet with argument GLPOSTCOLORMATRIXGREENSCALESGI
glGet with argument GLPOSTCOLORMATRIXBLUESCALESGI
glGet with argument GLPOSTCOLORMATRIXALPHASCALESGI
glGet with argument GLPOSTCOLORMATRIXREDBIASSGI
glGet with argument GLPOSTCOLORMATRIXGREENBIASSGI
glGet with argument GLPOSTCOLORMATRIXBLUEBIASSGI
glGet with argument GLPOSTCOLORMATRIXALPHABIASSGI
Page 6
glPixelTransfer(3G) OpenGL Reference glPixelTransfer(3G)
glGet with argument GLPOSTCONVOLUTIONREDSCALEEXT
glGet with argument GLPOSTCONVOLUTIONGREENSCALEEXT
glGet with argument GLPOSTCONVOLUTIONBLUESCALEEXT
glGet with argument GLPOSTCONVOLUTIONALPHASCALEEXT
glGet with argument GLPOSTCONVOLUTIONREDBIASEXT
glGet with argument GLPOSTCONVOLUTIONGREENBIASEXT
glGet with argument GLPOSTCONVOLUTIONBLUEBIASEXT
glGet with argument GLPOSTCONVOLUTIONALPHABIASEXT
SEE ALSO
glCallList, glCopyPixels, glCopyTexImage1D, glCopyTexImage1DEXT,
glCopyTexImage2D, glCopyTexImage2DEXT, glCopyTexImage3DEXT,
glCopyTexSubImage1D, glCopyTexSubImage1DEXT, glCopyTexSubImage2D,
glCopyTexSubImage2DEXT, glCopyTexSubImage3DEXT, glDrawPixels, glNewList,
glPixelMap, glPixelStore, glPixelZoom, glReadPixels, glTexImage1D,
glTexImage1DEXT, glTexImage2D, glTexImage2DEXT, glTexSubImage1D,
glTexSubImage1DEXT, glTexSubImage2D, glTexSubImage2DEXT
Page 7