How to get SDL_Surface->pixels size?

I hope to copy RGBA data from “SDL_Surface->pixels”, but I am not sure whether “pixels” is RGBA array, and what’s “pixels” size. Thank you:D

The amount of bytes the pixel data takes is .h * .pitch. You can also find
more information on byte and bits size about the image by looking at the
.format field (It’s a SDL_PixelFormat*, which lets you access stuff like
how many bytes per pixel you have there).

If you’re copying pixel data directly through an SDL_Surface .pixels
member, you should be aware of padding bytes. Each row of your image may be
padded with some bytes. The row pixel bytes + row padding bytes is your
image’s pitch. When you’re going through the image bytes, you want to be
careful about that. You can look more about image pitch on the web.

If you’re copying from an SDL_Surface to another, consider using SDL’s own
functions.On Tue, Jun 9, 2015 at 11:39 PM, Nemo3773 <377307289 at qq.com> wrote:

I hope to copy RGBA data from “SDL_Surface->pixels”, but I am not sure
whether “pixels” is RGBA array, and what’s “pixels” size. Thank you:D


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

On image formats and functions to deal with SDL_Surface instances, you
should check https://wiki.libsdl.org/CategoryPixels and
https://wiki.libsdl.org/CategorySurface in case you haven’t already. Also,
check https://wiki.libsdl.org/SDL_Surface and look at the .format field
(it’s a pointer to an SDL_PixelFormat,
https://wiki.libsdl.org/SDL_PixelFormat).

The wiki is easy enough to follow.On Tue, Jun 9, 2015 at 11:56 PM, Pedro Henrique Antunes de Oliveira < @Pedro_Henrique_Antun> wrote:

The amount of bytes the pixel data takes is .h * .pitch. You can also find
more information on byte and bits size about the image by looking at the
.format field (It’s a SDL_PixelFormat*, which lets you access stuff like
how many bytes per pixel you have there).

If you’re copying pixel data directly through an SDL_Surface .pixels
member, you should be aware of padding bytes. Each row of your image may be
padded with some bytes. The row pixel bytes + row padding bytes is your
image’s pitch. When you’re going through the image bytes, you want to be
careful about that. You can look more about image pitch on the web.

If you’re copying from an SDL_Surface to another, consider using SDL’s own
functions.

On Tue, Jun 9, 2015 at 11:39 PM, Nemo3773 <377307289 at qq.com> wrote:

I hope to copy RGBA data from “SDL_Surface->pixels”, but I am not sure
whether “pixels” is RGBA array, and what’s “pixels” size. Thank you:D


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org