SDL_CreateRGBSurfaceFrom

Started by
26 comments, last by sdlprorammer 19 years, 10 months ago
SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); Can anyone explain to me what the parameter "pitch" is? PLEASE don''t use advanced terms... thanks in advance
Advertisement
http://sdldoc.csn.ul.ie/
Quote from the above linked documentation: "pitch is the length of each scanline in bytes."
So if the line is 640 pixels wide, and each pixel is three bytes, then pitch is 640*3.
EDIT: That would be a line in the source image. I.e. the one "pixels" is pointing to.

[edited by - TomasH on May 27, 2004 6:53:13 AM]
thanls for the help!
you said:
"So if the line is 640 pixels wide, and each pixel is three bytes, then pitch is 640*3."
1)"line" refers to "void *pixels"?
2) If we are going to create a surface initialized by the bytes pointed by "void *pixels", then why do we need the RGB and A masks? Those data ( for the color 0 should be included in the bytes of "pixels", shouldn''t they? So??

thanks...
quote:Original post by sdlprorammer
1)"line" refers to "void *pixels"?

Yes
quote:Original post by sdlprorammer
2) If we are going to create a surface initialized by the bytes pointed by "void *pixels", then why do we need the RGB and A masks? Those data ( for the color 0 should be included in the bytes of "pixels", shouldn''t they? So??

Because "pixels" just points to raw data - i.e. there is no information on how the data is ordered...
thatnks but...:
>Because "pixels" just points to raw data - i.e. there is no information on how the data is ordered...

Eeeer.. what do u mean? What kind of data are these that can not be ( basiccally ) used?
quote:Original post by TomasH
So if the line is 640 pixels wide, and each pixel is three bytes, then pitch is 640*3.


No, the pitch is the number of bytes from the start of one line to the next. This may or may not be width * bytesperpixel.

quote:
Eeeer.. what do u mean? What kind of data are these that can not be ( basiccally ) used?


Because you know the pixelformat, so you know how the data is stored.
>Because you know the pixelformat, so you know how the data is stored.
Then i don''t need to know RGBA in advance. ... ??.. but the function requires themm..?
quote:Original post by DBX
quote:Original post by TomasH
So if the line is 640 pixels wide, and each pixel is three bytes, then pitch is 640*3.


No, the pitch is the number of bytes from the start of one line to the next. This may or may not be width * bytesperpixel.

Oh, yes, of course you''re right. Sorry...

quote:Original post by sdlprorammer
>Because you know the pixelformat, so you know how the data is stored.
Then i don''t need to know RGBA in advance. ... ??.. but the function requires themm..?

Yes, you should have this information.
SDL_CreateRGBSurfaceFrom is used to take pixel data that you have loaded from a file or created in some other way and use it (or part of it) to create a SDL surface. So if you managed to load the data or create it, you really should know how the data is stored. Right?
>No, the pitch is the number of bytes from the start of one line to the next. This may or may not be width * bytesperpixel.

Then how can i determine what value to pass to the function?????????

>SDL_CreateRGBSurfaceFrom is used to take pixel data that you have loaded from a file or created in some other way and use it (or part of it) to create a SDL surface.
Ok, so far we are OK.

>So if you managed to load the data or create it, you really should know how the data is stored. Right?
But RGBA is what the data contains! ???

This topic is closed to new replies.

Advertisement