Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

sdlprorammer

SDL_CreateRGBSurfaceFrom

This topic is 5138 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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]

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
>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..?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
>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! ???

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!