glReadPixels: Unterschied zwischen den Versionen

Aus DGL Wiki
Wechseln zu: Navigation, Suche
()
K ()
Zeile 55: Zeile 55:
 
=== Format Parameter ===
 
=== Format Parameter ===
 
'''GL_COLOR_INDEX'''
 
'''GL_COLOR_INDEX'''
<b><i>
+
: Farben Indizen werden aus dem  von glReadBuffer ausgewählten [[Farbpuffer]] gelesen.<b><i> Each index is converted to fixed point, shifted left or right depending on the value and sign of GL_INDEX_SHIFT, and added to GL_INDEX_OFFSET. If GL_MAP_COLOR is GL_TRUE, indices are replaced by their mappings in the table GL_PIXEL_MAP_I_TO_I.  
: Color indices are read from the color buffer selected by glReadBuffer. Each index is converted to fixed point, shifted left or right depending on the value and sign of GL_INDEX_SHIFT, and added to GL_INDEX_OFFSET. If GL_MAP_COLOR is GL_TRUE, indices are replaced by their mappings in the table GL_PIXEL_MAP_I_TO_I.  
 
 
</i></b>
 
</i></b>
 
'''GL_STENCIL_INDEX'''
 
'''GL_STENCIL_INDEX'''
Zeile 120: Zeile 119:
  
 
<br>
 
<br>
 +
 
== Hinweise ==
 
== Hinweise ==
 
Werte von Pixel die außerhalb des Fensters, das mit dem aktuellen GL-Kontext verbunden ist, liegen, sind undefiniert.
 
Werte von Pixel die außerhalb des Fensters, das mit dem aktuellen GL-Kontext verbunden ist, liegen, sind undefiniert.

Version vom 11. Oktober 2004, 14:33 Uhr

Hinweis: Dieser Artikel ist noch unvollständig.
(Mehr Informationen/weitere Artikel)

{{{1}}}

Incomplete.jpg

glReadPixels


Name

glReadPixels - ließt einen Block von Pixel aus dem Framebuffer.


Delphi-Spezifikation

procedure glReadPixels(x: TGLint; y: TGLint; 
                             width: TGLsizei; height: TGLsizei; 
                             format: TGLenum; _type: TGLenum; 
                             pixels: PGLvoid);


Parameter

x, y Beschreibt die Fensterkoordinaten des ersten Pixels, dass aus dem Framebuffer gelesen wird. Diese Position ist die untere, linke Ecke eines Rechtecks von Pixeln.
width, height Beschreibt die Dimensionen des Pixelrechtecks. Die Angaben werden dabei in Pixel gemacht.
format Bestimmt das Format der Pixeldaten. Folgende symbolische Werte werden akzeptiert:
GL_COLOR_INDEX, GL_STENCIL_INDEX, GL_DEPTH_COMPONENT, GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA, GL_RGB, GL_RGBA, GL_LUMINANCE, und GL_LUMINANCE_ALPHA
type Beschreibt den Datentyp der Pixeldaten. Muss einer der Folgenden sein:
GL_UNSIGNED_BYTE, GL_BYTE, GL_BITMAP, GL_UNSIGNED_SHORT, GL_SHORT, GL_UNSIGNED_INT, GL_INT, oder GL_FLOAT
pixels Liefert die Pixeldaten zurück.


Beschreibung

glReadPixels kopiert Pixeldaten aus dem Framebuffer in den Klientspeicher der für pixels reserviert wurde. Der Kopiervorgang beginnt dabei mit dem Pixel, dessen linke untere Ecke am Punkt(x, y) liegt. Verschiedene Parameter kontrollieren die Verarbeitung der Pixeldaten bevor diese in den Klientspeicher geschrieben werden.. Diese Parameter werden mit drei Befehlen gesetzt:
glPixelStore, glPixelTransfer und glPixelMap.
Dieser Artikel beschreibt die Effekte welche die meisten, aber nicht alle Parameter der genannten Artikel auf glReadPixels haben.

glReadPixels liefert die Werte der Pixel die im Rechteck [x+i, y+j] liegen. (mit 0<=i<width bzw. 0<=j<height)
Dabei bezeichnet [i,j] das i-te Pixel in der j-ten Zeile. Die Pixel werden zeilenweise beginnend mit der niedrigsten Zeile und von links nach rechts (innerhalb der Zeile) zurück geliefert.

Der Parameter format bestimmt das Format der zurück gelieferten Pixelwerte. Akzeptiert werden:

Format Parameter

GL_COLOR_INDEX

Farben Indizen werden aus dem von glReadBuffer ausgewählten Farbpuffer gelesen. Each index is converted to fixed point, shifted left or right depending on the value and sign of GL_INDEX_SHIFT, and added to GL_INDEX_OFFSET. If GL_MAP_COLOR is GL_TRUE, indices are replaced by their mappings in the table GL_PIXEL_MAP_I_TO_I.

GL_STENCIL_INDEX

Stencil values are read from the stencil buffer. Each index is converted to fixed point, shifted left or right depending on the value and sign of GL_INDEX_SHIFT, and added to GL_INDEX_OFFSET. If GL_MAP_STENCIL is GL_TRUE, indices are replaced by their mappings in the table GL_PIXEL_MAP_S_TO_S.

GL_DEPTH_COMPONENT

Depth values are read from the depth buffer. Each component is converted to floating point such that the minimum depth value maps to 0.0 and the maximum value maps to 1.0. Each component is then multiplied by GL_DEPTH_SCALE, added to GL_DEPTH_BIAS, and finally clamped to the range [0,1].

GL_RED
GL_GREEN
GL_BLUE
GL_ALPHA
GL_RGB
GL_RGBA
GL_LUMINANCE
GL_LUMINANCE_ALPHA

Processing differs depending on whether color buffers store color indices or RGBA color components. If color indices are stored, they are read from the color buffer selected by glReadBuffer. Each index is converted to fixed point, shifted left or right depending on the value and sign of GL_INDEX_SHIFT, and added to GL_INDEX_OFFSET. Indices are then replaced by the red, green, blue, and alpha values obtained by indexing the GL_PIXEL_MAP_I_TO_R, GL_PIXEL_MAP_I_TO_G, GL_PIXEL_MAP_I_TO_B, and GL_PIXEL_MAP_I_TO_A tables.

If RGBA color components are stored in the color buffers, they are read from the color buffer selected by glReadBuffer. Each color component is converted to floating point such that zero intensity maps to 0.0 and full intensity maps to 1.0. Each component is then multiplied by GL_c_SCALE and added to GL_c_BIAS, where c is GL_RED, GL_GREEN, GL_BLUE, and GL_ALPHA. Each component is clamped to the range [0,1]. Finally, if GL_MAP_COLOR is GL_TRUE, each color component c is replaced by its mapping in the table GL_PIXEL_MAP_c_TO_c, where c again is GL_RED, GL_GREEN, GL_BLUE, and GL_ALPHA. Each component is scaled to the size of its corresponding table before the lookup is performed.

Finally, unneeded data is discarded. For example, GL_RED discards the green, blue, and alpha components, while GL_RGB discards only the alpha component. GL_LUMINANCE computes a single component value as the sum of the red, green, and blue components, and GL_LUMINANCE_ALPHA does the same, while keeping alpha as a second value.

The shift, scale, bias, and lookup factors described above are all specified by glPixelTransfer. The lookup table contents themselves are specified by glPixelMap.

The final step involves converting the indices or components to the proper format, as specified by type. If format is GL_COLOR_INDEX or GL_STENCIL_INDEX and type is not GL_FLOAT, each index is masked with the mask value given in the following table. If type is GL_FLOAT, then each integer index is converted to single-precision floating-point format.

If format is GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA, GL_RGB, GL_RGBA, GL_LUMINANCE, or GL_LUMINANCE_ALPHA and type is not GL_FLOAT, each component is multiplied by the multiplier shown in the following table. If type is GL_FLOAT, then each component is passed as is (or converted to the clients single-precision floating-point format if it is different from the one used by the GL).

Type Index Mask Komponenten
Konvertierung
GL_UNSIGNED_BYTE 2^8-1 (2^8-1)c
GL_BYTE 2^7-1 ([2^7-1]c-1)/2
GL_BITMAP 1 1
GL_UNSIGNED_SHORT 2^16-1 (2^16-1) c
GL_SHORT 2^15-1 [(2^15-1) c-1] / 2
GL_UNSIGNED_INT 2^32-1 (2^32-1) c
GL_INT 2^31-1 [(2^31-1) c-1] / 2
GL_FLOAT keine c

Ein Rechenbeispiel zum besseren Verständnis.

Return values are placed in memory as follows. If format is GL_COLOR_INDEX, GL_STENCIL_INDEX, GL_DEPTH_COMPONENT, GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA, or GL_LUMINANCE, a single value is returned and the data for the ith pixel in the jth row is placed in location (j) width + i. GL_RGB returns three values, GL_RGBA returns four values, and GL_LUMINANCE_ALPHA returns two values for each pixel, with all values corresponding to a single pixel occupying contiguous space in pixels. Storage parameters set by glPixelStore, such as GL_PACK_SWAP_BYTES and GL_PACK_LSB_FIRST, affect the way that data is written into memory. See glPixelStore for a description.


Hinweise

Werte von Pixel die außerhalb des Fensters, das mit dem aktuellen GL-Kontext verbunden ist, liegen, sind undefiniert.

Wenn ein Fehler bei der durchführung der Funktion auftritt, werden keine Veränderungen am Inhalt von pixels durchgeführt.


Fehlermeldungen

GL_INVALID_ENUM wird generiert wenn format oder type ein ungültiger Wert übergeben wird.
GL_INVALID_VALUE wird generiert wenn entweder width oder height negativ ist.
GL_INVALID_OPERATION wird generiert wenn format GL_COLOR_INDEX ist und der Farbpuffer RGBA Werte enthält.
GL_INVALID_OPERATION wird generiert wenn format GL_STENCIL_INDEX ist und kein Schablonen-(/Stencil-)Puffer existiert.
GL_INVALID_OPERATION wird generiert wenn format GL_DEPTH_COMPONENT ist und kein Tiefenpuffer existiert.
GL_INVALID_OPERATION wird generiert wenn glReadPixels innerhalb eines glBegin-glEnd Blocks aufgerufen wird.


Zugehörige Wertrückgaben

glGet mit Token GL_INDEX_MODE


Siehe auch

glCopyPixels, glDrawPixels, glPixelMap, glPixelStore, glPixelTransfer, glReadBuffer