|
Size: 3100
Comment: minor change
|
Size: 1866
Comment: update content - w/ Sam; remove draft
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 3: | Line 3: |
| ||<tablewidth="100%" style="color: #FF0000;" :> DRAFT|| | |
| Line 6: | Line 5: |
| Use this function to allocate ,,and free,, an RGB surface ^from pixels???^. | Use this function to allocate a new RGB surface with existing pixel data. |
| Line 24: | Line 23: |
| ||'''pixels'''||a pointer to a set of pixels to use on the surface|| ||'''width'''||the width of the surface ^(in pixels)^|| ||'''height'''||the height of the surface ^(in pixels)^|| |
||'''pixels'''||a pointer to existing pixel data|| ||'''width'''||the width of the surface|| ||'''height'''||the height of the surface|| |
| Line 28: | Line 27: |
| ||'''pitch'''||the pitch of the pixels|| | ||'''pitch'''||the length of a row of pixels in bytes|| |
| Line 35: | Line 34: |
| Returns a pointer to ,,an,, ^the^ [[SDL_Surface]] structure ,,to be,, ^that is^ created. If the function runs out of memory it will return NULL. | Returns the new [[SDL_Surface]] structure that is created or NULL if it fails; call [[SDL_GetError]]() for more information. |
| Line 43: | Line 42: |
| If ,,the,, '''depth''' is 4 or 8 bits, an empty palette is allocated for the surface. If ,,the,, '''depth''' is greater than 8 bits, the pixel format is set using the flags '[RGB]mask'. <<Color2(green,Should it still mention flags since there is no flag param in this function? Should it instead say using the source pixel format?)>> | <<Include(SDL_CreateRGBSurface, , , from="== Remarks ==", to="== Related Functions ==")>> |
| Line 45: | Line 44: |
| *<<BR>>No copy is made from the pixel data. A special undocumented [[SDL_Surface]] flag is set. The pixel data won't be deallocated automatically when [[SDL_FreeSurface]]() is invoked with the surface and it should not be freed until the surface has been freed. The data stored in '''pixels''' is assumed to have '''depth''' bits per pixel. '''pitch''' is the size of the scanline of the surface, in bytes (i.e. `widthInPixels*bytesPerPixel`). The scanline is the width of the image multiplied by bytes per pixel, plus any bytes added for alignment (that is if '''pixels''' points to the leftmost pixel on the first row of the surface, then '''pixels'''+'''pitch''' points to the leftmost pixel on the second row of the surface). <<Color2(green,If the above text is to remain should words like scanline be formatted differently - like `scanline`?)>> The pixel data is considered to be in software memory. If the pixel data lies in hardware memory (as pixel data from a hardware surface), the appropriate surface flag has to be set manually. <<BR>>* |
No copy is made of the pixel data. You should not free the pixel data until you have freed the surface. The pixel data won't be freed automatically when the surface is freed. |
SDL_CreateRGBSurfaceFrom
Use this function to allocate a new RGB surface with existing pixel data.
Contents
Syntax
SDL_Surface* SDL_CreateRGBSurfaceFrom (void* pixels,
int width,
int height,
int depth,
int pitch,
Uint32 Rmask,
Uint32 Gmask,
Uint32 Bmask,
Uint32 Amask)
Function Parameters
pixels |
a pointer to existing pixel data |
width |
the width of the surface |
height |
the height of the surface |
depth |
the depth of the surface in bits; see Remarks for details |
pitch |
the length of a row of pixels in bytes |
Rmask |
the red mask for the pixels |
Gmask |
the green mask for the pixels |
Bmask |
the blue mask for the pixels |
Amask |
the alpha mask for the pixels |
Return Value
Returns the new SDL_Surface structure that is created or NULL if it fails; call SDL_GetError() for more information.
Code Examples
You can add your code example here
Remarks
If depth is 4 or 8 bits, an empty palette is allocated for the surface. If depth is greater than 8 bits, the pixel format is set using the [RGBA]mask parameters.
The [RGBA]mask parameters are the bitmasks used to extract that color from a pixel. For instance, Rmask being FF000000 means the red data is stored in the most significant byte. Using zeros for the RGB masks sets a default value, based on the depth. (e.g. SDL_CreateRGBSurface(0,w,h,32,0,0,0,0);) However, using zero for the Amask results in an Amask of 0.
By default surfaces with an alpha mask are set up for blending as with
SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_BLEND)
You can change this by calling SDL_SetSurfaceBlendMode() and selecting a different blendMode.
No copy is made of the pixel data. You should not free the pixel data until you have freed the surface. The pixel data won't be freed automatically when the surface is freed.
