SGE Documentation - Pixels

# Pixel operations

- _PutPixel
- sge_PutPixel
- sge_CalcYPitch
- sge_pPutPixel
- sge_GetPixel
- sge_write_block
- sge_read_block

_PutPixel

- void _PutPixel(SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color)
- void _PutPixel(SDL_Surface *surface, Sint16 x, Sint16 y, Uint8 R, Uint8 G, Uint8 B)
- void _PutPixelAlpha(SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color, Uint8 alpha)
- void _PutPixelAlpha(SDL_Surface *surface, Sint16 x, Sint16 y, Uint8 R, Uint8 G, Uint8 B, Uint8 alpha)
- void _PutPixel8(SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color)
- void _PutPixel16(SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color)
- void _PutPixel24(SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color)
- void _PutPixel32(SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color)
- void _PutPixelX(SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color)

Writes a pixel to the specified position. Does NOT lock or update the surface, but respects clipping. The 'Uint32 color' version is faster. _PutPixelAlpha() will blend the pixel with the background. For the speed maniac the [8/16/24/32] functions are also available, which only work on the correct bpp (8/16/24/32). They do not respect clipping. _PutPixelX() works like _PutPixel() but ignores clipping.
sge_PutPixel

- void sge_PutPixel(SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color)
- void sge_PutPixel(SDL_Surface *surface, Sint16 x, Sint16 y, Uint8 R, Uint8 G, Uint8 B)
- void sge_PutPixelAlpha(SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color, Uint8 alpha)
- void sge_PutPixelAlpha(SDL_Surface *surface, Sint16 x, Sint16 y, Uint8 R, Uint8 G, Uint8 B, Uint8 alpha)

Unlike _PutPixel these functions does lock and update the surface.
Sint32 sge_CalcYPitch(SDL_Surface *surface, Sint16 y)
Returns the y pitch offset, use it with sge_pPutPixel. Note that the return type is *Sint32*.
void sge_pPutPixel(SDL_Surface *surface, Sint16 x, Sint32 ypitch, Uint32 color)
Writes a pixel to the specified position using the precalculated ypitch. This saves one mul and one div when writing more than one time to the same y coord.
Does not lock or update the surface, but respects clipping.
Uint32 sge_GetPixel(SDL_Surface *surface, Sint16 x, Sint16 y)
Gets the color of the specified pixel.
void sge_write_block8(SDL_Surface *Surface, Uint8 *block, Sint16 y)
void sge_write_block16(SDL_Surface *Surface, Uint16 *block, Sint16 y)
void sge_write_block32(SDL_Surface *Surface, Uint32 *block, Sint16 y)
These functions writes the given block (of color values) to the surface. A block consist of Surface->w (the width of the surface) numbers of color values. Write your data to the block and then call sge_write_block() to update the y:th line on the surface with new color values. Note the difference in byte size for the block elements for different bpp. This is much faster then using the put pixel functions to update a line. 24-bpp version not included (OK! I admit that I don't like 24bpp - it's slow!). Does not lock or update the surface, nor does it respect clipping - but it's fast!.
void sge_read_block8(SDL_Surface *Surface, Uint8 *block, Sint16 y)
void sge_read_block16(SDL_Surface *Surface, Uint16 *block, Sint16 y)
void sge_read_block32(SDL_Surface *Surface, Uint32 *block, Sint16 y)
Reads the y:th line to block. See above for more information.

Copyright © 1999-2003 Anders Lindström
Last updated 030808