Where does SDL _ pixelformat store the color data?

Where does SDL _ pixelformat store the color data?

An SDL_PixelFormat describes the format of the pixel data stored at the pixels field of an SDL_Surface. Every surface stores an SDL_PixelFormat in the format field. If you wish to do pixel level modifications on a surface, then understanding how SDL stores its color information is essential. See Code Examples above for more information.

Which is an alias for SDL pixelformat _ RGBA32?

SDL_PIXELFORMAT_RGBA32 is an alias for SDL_PIXELFORMAT_RGBA8888 on big endian machines and for SDL_PIXELFORMAT_ABGR8888 on little endian machines, so you can use it to specify that your pixels are represented as RGBA byte arrays, like SDL_PIXELFORMAT_RGB24 is for RGB byte arrays.

How to get the name of an alias in SDL?

However, being just an alias, it has the exact same value of the aliased type so SDL_GetPixelFormatName (SDL_PIXELFORMAT_RGBA32) will return the name of the aliased type (e.g. “SDL_PIXELFORMAT_ABGR8888”), depending on your platform.

How to determine the color of a pixel in 8 bit?

So, to determine the color of a pixel in an 8-bit surface: we read the color index from surface->pixels and we use that index to read the SDL_Color structure from surface->format->palette->colors.

What are the data types of a pixel?

A pixel format has either a palette or masks. If a palette is used Rmask, Gmask, Bmask, and Amask will be 0. The data types used to represent pixels are as follows: An SDL_PixelFormat describes the format of the pixel data stored at the pixels field of an SDL_Surface.

How to copy a block of pixels to another format?

Copy a block of pixels of one format to another format. Returns 0 on success or a negative error code on failure; call SDL_GetError () for more information. All wiki content is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). Wiki powered by ghwikipp.

How to determine the color of a pixel in 8-bit surface?

So, to determine the color of a pixel in an 8-bit surface: we read the color index from surface->pixels and we use that index to read the SDL_Color structure from surface->format->palette->colors. Like so: SDL_Surface *surface; SDL_PixelFormat *fmt; SDL_Color *color; Uint8 index; . .