Class SdlSurface
- java.lang.Object
-
- io.github.libsdl4j.api.surface.SdlSurface
-
public final class SdlSurface extends Object
Definitions from file SDL_surface.hSDL_Surface
management functions.
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static int
SDL_BlitScaled(SDL_Surface src, SDL_Rect srcRect, SDL_Surface dst, SDL_Rect dstRect)
Perform a scaled surface copy to a destination surface.static int
SDL_BlitSurface(SDL_Surface src, SDL_Rect srcRect, SDL_Surface dst, SDL_Rect dstRect)
Performs a fast blit from the source surface to the destination surface.static int
SDL_ConvertPixels(int width, int height, int srcFormat, com.sun.jna.Pointer src, int srcPitch, int dstFormat, com.sun.jna.Pointer dst, int dstPitch)
Copy a block of pixels of one format to another format.static SDL_Surface
SDL_ConvertSurface(SDL_Surface src, SDL_PixelFormat fmt, int flags)
Copy an existing surface to a new surface of the specified format.static SDL_Surface
SDL_ConvertSurfaceFormat(SDL_Surface src, int pixelFormat, int flags)
Copy an existing surface to a new surface of the specified format enum.static SDL_Surface
SDL_CreateRGBSurface(int flags, int width, int height, int depth, int rMask, int gMask, int bMask, int aMask)
Allocate a new RGB surface.static SDL_Surface
SDL_CreateRGBSurfaceFrom(com.sun.jna.Pointer pixels, int width, int height, int depth, int pitch, int rMask, int gMask, int bMask, int aMask)
Allocate a new RGB surface with existing pixel data.static SDL_Surface
SDL_CreateRGBSurfaceWithFormat(int flags, int width, int height, int depth, int format)
Allocate a new RGB surface with a specific pixel format.static SDL_Surface
SDL_CreateRGBSurfaceWithFormatFrom(com.sun.jna.Pointer pixels, int width, int height, int depth, int pitch, int format)
Allocate a new RGB surface with with a specific pixel format and existing pixel data.static SDL_Surface
SDL_DuplicateSurface(SDL_Surface surface)
static int
SDL_FillRect(SDL_Surface dst, SDL_Rect rect, int color)
Perform a fast fill of a rectangle with a specific color.static int
SDL_FillRects(SDL_Surface dst, com.sun.jna.Pointer rects, int count, int color)
Perform a fast fill of a set of rectangles with a specific color.static int
SDL_FillRects(SDL_Surface dst, ContiguousArrayList<SDL_Rect> rects, int color)
Perform a fast fill of a set of rectangles with a specific color.static void
SDL_FreeSurface(SDL_Surface surface)
Free an RGB surface.static void
SDL_GetClipRect(SDL_Surface surface, SDL_Rect rect)
Get the clipping rectangle for a surface.static int
SDL_GetColorKey(SDL_Surface surface, com.sun.jna.ptr.IntByReference key)
Get the color key (transparent pixel) for a surface.static int
SDL_GetSurfaceAlphaMod(SDL_Surface surface, com.sun.jna.ptr.ByteByReference alpha)
Get the additional alpha value used in blit operations.static int
SDL_GetSurfaceBlendMode(SDL_Surface surface, SDL_BlendMode.Ref blendMode)
Get the blend mode used for blit operations.static int
SDL_GetSurfaceColorMod(SDL_Surface surface, com.sun.jna.ptr.ByteByReference r, com.sun.jna.ptr.ByteByReference g, com.sun.jna.ptr.ByteByReference b)
Get the additional color value multiplied into blit operations.static int
SDL_GetYUVConversionMode()
Get the YUV conversion modestatic int
SDL_GetYUVConversionModeForResolution(int width, int height)
Get the YUV conversion mode, returning the correct mode for the resolution when the current conversion mode is SDL_YUV_CONVERSION_AUTOMATICstatic boolean
SDL_HasColorKey(SDL_Surface surface)
Returns whether the surface has a color keystatic boolean
SDL_HasSurfaceRLE(SDL_Surface surface)
Returns whether the surface is RLE enabledstatic SDL_Surface
SDL_LoadBMP(String file)
Load a surface from a file.static SDL_Surface
SDL_LoadBMP_RW(SDL_RWops src, int freesrc)
Load a BMP image from a seekable SDL data stream.static int
SDL_LockSurface(SDL_Surface surface)
Set up a surface for directly accessing the pixels.static int
SDL_LowerBlit(SDL_Surface src, SDL_Rect srcrect, SDL_Surface dst, SDL_Rect dstrect)
Perform low-level surface blitting only.static int
SDL_LowerBlitScaled(SDL_Surface src, SDL_Rect srcRect, SDL_Surface dst, SDL_Rect dstRect)
Perform low-level surface scaled blitting only.static boolean
SDL_MUSTLOCK(SDL_Surface s)
Evaluates to true if the surface needs to be locked before access.static int
SDL_PremultiplyAlpha(int width, int height, int srcFormat, com.sun.jna.Pointer src, int srcPitch, int dstFormat, com.sun.jna.Pointer dst, int dstPitch)
Premultiply the alpha on a block of pixels.static int
SDL_SaveBMP(SDL_Surface surface, String file)
Save a surface to a file.static int
SDL_SaveBMP_RW(SDL_Surface surface, SDL_RWops dst, int freedst)
Save a surface to a seekable SDL data stream in BMP format.static boolean
SDL_SetClipRect(SDL_Surface surface, SDL_Rect rect)
Set the clipping rectangle for a surface.static int
SDL_SetColorKey(SDL_Surface surface, int flag, int key)
Set the color key (transparent pixel) in a surface.static int
SDL_SetSurfaceAlphaMod(SDL_Surface surface, byte alpha)
Set an additional alpha value used in blit operations.static int
SDL_SetSurfaceBlendMode(SDL_Surface surface, int blendMode)
Set the blend mode used for blit operations.static int
SDL_SetSurfaceColorMod(SDL_Surface surface, byte r, byte g, byte b)
Set an additional color value multiplied into blit operations.static int
SDL_SetSurfacePalette(SDL_Surface surface, SDL_Palette palette)
Set the palette used by a surface.static int
SDL_SetSurfaceRLE(SDL_Surface surface, int flag)
Set the RLE acceleration hint for a surface.static void
SDL_SetYUVConversionMode(int mode)
Set the YUV conversion modestatic int
SDL_SoftStretch(SDL_Surface src, SDL_Rect srcrect, SDL_Surface dst, SDL_Rect dstrect)
Perform a fast, low quality, stretch blit between two surfaces of the same format.static int
SDL_SoftStretchLinear(SDL_Surface src, SDL_Rect srcrect, SDL_Surface dst, SDL_Rect dstrect)
Perform bilinear scaling between two surfaces of the same format, 32BPP.static void
SDL_UnlockSurface(SDL_Surface surface)
Release a surface after directly accessing the pixels.static int
SDL_UpperBlit(SDL_Surface src, SDL_Rect srcrect, SDL_Surface dst, SDL_Rect dstrect)
Deprecated.static int
SDL_UpperBlitScaled(SDL_Surface src, SDL_Rect srcRect, SDL_Surface dst, SDL_Rect dstRect)
Deprecated.
-
-
-
Method Detail
-
SDL_MUSTLOCK
public static boolean SDL_MUSTLOCK(SDL_Surface s)
Evaluates to true if the surface needs to be locked before access.
-
SDL_CreateRGBSurface
public static SDL_Surface SDL_CreateRGBSurface(int flags, int width, int height, int depth, int rMask, int gMask, int bMask, int aMask)
Allocate a new RGB surface.If
depth
is 4 or 8 bits, an empty palette is allocated for the surface. Ifdepth
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 0xFF000000 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. For example: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
.- Parameters:
flags
- the flags are unused and should be set to 0width
- the width of the surfaceheight
- the height of the surfacedepth
- the depth of the surface in bitsrMask
- the red mask for the pixelsgMask
- the green mask for the pixelsbMask
- the blue mask for the pixelsaMask
- the alpha mask for the pixels- Returns:
- the new SDL_Surface structure that is created or null if it fails; call SDL_GetError() for more information.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_CreateRGBSurfaceFrom(Pointer, int, int, int, int, int, int, int, int)
,SDL_CreateRGBSurfaceWithFormat(int, int, int, int, int)
,SDL_FreeSurface(SDL_Surface)
-
SDL_CreateRGBSurfaceWithFormat
public static SDL_Surface SDL_CreateRGBSurfaceWithFormat(int flags, int width, int height, int depth, int format)
Allocate a new RGB surface with a specific pixel format.This function operates mostly like SDL_CreateRGBSurface(), except instead of providing pixel color masks, you provide it with a predefined format from SDL_PixelFormatEnum.
- Parameters:
flags
- the flags are unused and should be set to 0width
- the width of the surfaceheight
- the height of the surfacedepth
- the depth of the surface in bitsformat
- the SDL_PixelFormatEnum for the new surface's pixel format.- Returns:
- the new SDL_Surface structure that is created or null if it fails; call SDL_GetError() for more information.
- Since:
- This function is available since SDL 2.0.5.
- See Also:
SDL_CreateRGBSurface(int, int, int, int, int, int, int, int)
,SDL_CreateRGBSurfaceFrom(Pointer, int, int, int, int, int, int, int, int)
,SDL_FreeSurface(SDL_Surface)
-
SDL_CreateRGBSurfaceFrom
public static SDL_Surface SDL_CreateRGBSurfaceFrom(com.sun.jna.Pointer pixels, int width, int height, int depth, int pitch, int rMask, int gMask, int bMask, int aMask)
Allocate a new RGB surface with existing pixel data.This function operates mostly like SDL_CreateRGBSurface(), except it does not allocate memory for the pixel data, instead the caller provides an existing buffer of data for the surface to use.
No copy is made of the pixel data. Pixel data is not managed automatically; you must free the surface before you free the pixel data.
- Parameters:
pixels
- a pointer to existing pixel datawidth
- the width of the surfaceheight
- the height of the surfacedepth
- the depth of the surface in bitspitch
- the pitch of the surface in bytesrMask
- the red mask for the pixelsgMask
- the green mask for the pixelsbMask
- the blue mask for the pixelsaMask
- the alpha mask for the pixels- Returns:
- the new SDL_Surface structure that is created or null if it fails; call SDL_GetError() for more information.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_CreateRGBSurface(int, int, int, int, int, int, int, int)
,SDL_CreateRGBSurfaceWithFormat(int, int, int, int, int)
,SDL_FreeSurface(SDL_Surface)
-
SDL_CreateRGBSurfaceWithFormatFrom
public static SDL_Surface SDL_CreateRGBSurfaceWithFormatFrom(com.sun.jna.Pointer pixels, int width, int height, int depth, int pitch, int format)
Allocate a new RGB surface with with a specific pixel format and existing pixel data.This function operates mostly like SDL_CreateRGBSurfaceFrom(), except instead of providing pixel color masks, you provide it with a predefined format from SDL_PixelFormatEnum.
No copy is made of the pixel data. Pixel data is not managed automatically; you must free the surface before you free the pixel data.
- Parameters:
pixels
- a pointer to existing pixel datawidth
- the width of the surfaceheight
- the height of the surfacedepth
- the depth of the surface in bitspitch
- the pitch of the surface in bytesformat
- the SDL_PixelFormatEnum for the new surface's pixel format.- Returns:
- the new SDL_Surface structure that is created or null if it fails; call SDL_GetError() for more information.
- Since:
- This function is available since SDL 2.0.5.
- See Also:
SDL_CreateRGBSurfaceFrom(Pointer, int, int, int, int, int, int, int, int)
,SDL_CreateRGBSurfaceWithFormat(int, int, int, int, int)
,SDL_FreeSurface(SDL_Surface)
-
SDL_FreeSurface
public static void SDL_FreeSurface(SDL_Surface surface)
Free an RGB surface.It is safe to pass null to this function.
- Parameters:
surface
- the SDL_Surface to free.- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_CreateRGBSurface(int, int, int, int, int, int, int, int)
,SDL_CreateRGBSurfaceFrom(Pointer, int, int, int, int, int, int, int, int)
,SDL_LoadBMP(String)
,SDL_LoadBMP_RW(SDL_RWops, int)
-
SDL_SetSurfacePalette
public static int SDL_SetSurfacePalette(SDL_Surface surface, SDL_Palette palette)
Set the palette used by a surface.A single palette can be shared with many surfaces.
- Parameters:
surface
- the SDL_Surface structure to updatepalette
- the SDL_Palette structure to use- Returns:
- 0 on success or a negative error code on failure; call SDL_GetError() for more information.
- Since:
- This function is available since SDL 2.0.0.
-
SDL_LockSurface
public static int SDL_LockSurface(SDL_Surface surface)
Set up a surface for directly accessing the pixels.Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write to and read from
surface.pixels
, using the pixel format stored insurface.format
. Once you are done accessing the surface, you should use SDL_UnlockSurface() to release it.Not all surfaces require locking. If
SDL_MUSTLOCK(surface)
evaluates to 0, then you can read and write to the surface at any time, and the pixel format of the surface will not change.- Parameters:
surface
- the SDL_Surface structure to be locked- Returns:
- 0 on success or a negative error code on failure; call SDL_GetError() for more information.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_MUSTLOCK(SDL_Surface)
,SDL_UnlockSurface(SDL_Surface)
-
SDL_UnlockSurface
public static void SDL_UnlockSurface(SDL_Surface surface)
Release a surface after directly accessing the pixels.- Parameters:
surface
- the SDL_Surface structure to be unlocked- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_LockSurface(SDL_Surface)
-
SDL_LoadBMP_RW
public static SDL_Surface SDL_LoadBMP_RW(SDL_RWops src, int freesrc)
Load a BMP image from a seekable SDL data stream.The new surface should be freed with SDL_FreeSurface(). Not doing so will result in a memory leak.
src is an open SDL_RWops buffer, typically loaded with SDL_RWFromFile. Alternitavely, you might also use the macro SDL_LoadBMP to load a bitmap from a file, convert it to an SDL_Surface and then close the file.
- Parameters:
src
- the data stream for the surfacefreesrc
- non-zero to close the stream after being read- Returns:
- a pointer to a new SDL_Surface structure or null if there was an error; call SDL_GetError() for more information.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_FreeSurface(SDL_Surface)
,SdlRWops.SDL_RWFromFile(String, String)
,SDL_LoadBMP(String)
,SDL_SaveBMP_RW(SDL_Surface, SDL_RWops, int)
-
SDL_LoadBMP
public static SDL_Surface SDL_LoadBMP(String file)
Load a surface from a file.Convenience method.
-
SDL_SaveBMP_RW
public static int SDL_SaveBMP_RW(SDL_Surface surface, SDL_RWops dst, int freedst)
Save a surface to a seekable SDL data stream in BMP format.Surfaces with a 24-bit, 32-bit and paletted 8-bit format get saved in the BMP directly. Other RGB formats with 8-bit or higher get converted to a 24-bit surface or, if they have an alpha mask or a colorkey, to a 32-bit surface before they are saved. YUV and paletted 1-bit and 4-bit formats are not supported.
- Parameters:
surface
- the SDL_Surface structure containing the image to be saveddst
- a data stream to save tofreedst
- non-zero to close the stream after being written- Returns:
- 0 on success or a negative error code on failure; call SDL_GetError() for more information.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_LoadBMP_RW(SDL_RWops, int)
,SDL_SaveBMP(SDL_Surface, String)
-
SDL_SaveBMP
public static int SDL_SaveBMP(SDL_Surface surface, String file)
Save a surface to a file.Convenience method.
-
SDL_SetSurfaceRLE
public static int SDL_SetSurfaceRLE(SDL_Surface surface, int flag)
Set the RLE acceleration hint for a surface.If RLE is enabled, color key and alpha blending blits are much faster, but the surface must be locked before directly accessing the pixels.
- Parameters:
surface
- the SDL_Surface structure to optimizeflag
- 0 to disable, non-zero to enable RLE acceleration- Returns:
- 0 on success or a negative error code on failure; call SDL_GetError() for more information.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_BlitSurface(SDL_Surface, SDL_Rect, SDL_Surface, SDL_Rect)
,SDL_LockSurface(SDL_Surface)
,SDL_UnlockSurface(SDL_Surface)
-
SDL_HasSurfaceRLE
public static boolean SDL_HasSurfaceRLE(SDL_Surface surface)
Returns whether the surface is RLE enabledIt is safe to pass a null
surface
here; it will return false.- Parameters:
surface
- the SDL_Surface structure to query- Returns:
- true if the surface is RLE enabled, false otherwise.
- Since:
- This function is available since SDL 2.0.14.
- See Also:
SDL_SetSurfaceRLE(SDL_Surface, int)
-
SDL_SetColorKey
public static int SDL_SetColorKey(SDL_Surface surface, int flag, int key)
Set the color key (transparent pixel) in a surface.The color key defines a pixel value that will be treated as transparent in a blit. For example, one can use this to specify that cyan pixels should be considered transparent, and therefore not rendered.
It is a pixel of the format used by the surface, as generated by SDL_MapRGB().
RLE acceleration can substantially speed up blitting of images with large horizontal runs of transparent pixels. See SDL_SetSurfaceRLE() for details.
- Parameters:
surface
- the SDL_Surface structure to updateflag
- true to enable color key, false to disable color keykey
- the transparent pixel- Returns:
- 0 on success or a negative error code on failure; call SDL_GetError() for more information.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_BlitSurface(SDL_Surface, SDL_Rect, SDL_Surface, SDL_Rect)
,SDL_GetColorKey(SDL_Surface, IntByReference)
-
SDL_HasColorKey
public static boolean SDL_HasColorKey(SDL_Surface surface)
Returns whether the surface has a color keyIt is safe to pass a null
surface
here; it will return false.- Parameters:
surface
- the SDL_Surface structure to query- Returns:
- true if the surface has a color key, false otherwise.
- Since:
- This function is available since SDL 2.0.9.
- See Also:
SDL_SetColorKey(SDL_Surface, int, int)
,SDL_GetColorKey(SDL_Surface, IntByReference)
-
SDL_GetColorKey
public static int SDL_GetColorKey(SDL_Surface surface, com.sun.jna.ptr.IntByReference key)
Get the color key (transparent pixel) for a surface.The color key is a pixel of the format used by the surface, as generated by SDL_MapRGB().
If the surface doesn't have color key enabled this function returns -1.
- Parameters:
surface
- the SDL_Surface structure to querykey
- a pointer filled in with the transparent pixel- Returns:
- 0 on success or a negative error code on failure; call SDL_GetError() for more information.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_BlitSurface(SDL_Surface, SDL_Rect, SDL_Surface, SDL_Rect)
,SDL_SetColorKey(SDL_Surface, int, int)
-
SDL_SetSurfaceColorMod
public static int SDL_SetSurfaceColorMod(SDL_Surface surface, byte r, byte g, byte b)
Set an additional color value multiplied into blit operations.When this surface is blitted, during the blit operation each source color channel is modulated by the appropriate color value according to the following formula:
srcC = srcC * (color / 255)
- Parameters:
surface
- the SDL_Surface structure to updater
- the red color value multiplied into blit operationsg
- the green color value multiplied into blit operationsb
- the blue color value multiplied into blit operations- Returns:
- 0 on success or a negative error code on failure; call SDL_GetError() for more information.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_GetSurfaceColorMod(SDL_Surface, ByteByReference, ByteByReference, ByteByReference)
,SDL_SetSurfaceAlphaMod(SDL_Surface, byte)
-
SDL_GetSurfaceColorMod
public static int SDL_GetSurfaceColorMod(SDL_Surface surface, com.sun.jna.ptr.ByteByReference r, com.sun.jna.ptr.ByteByReference g, com.sun.jna.ptr.ByteByReference b)
Get the additional color value multiplied into blit operations.- Parameters:
surface
- the SDL_Surface structure to queryr
- a pointer filled in with the current red color valueg
- a pointer filled in with the current green color valueb
- a pointer filled in with the current blue color value- Returns:
- 0 on success or a negative error code on failure; call SDL_GetError() for more information.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_GetSurfaceAlphaMod(SDL_Surface, ByteByReference)
,SDL_SetSurfaceColorMod(SDL_Surface, byte, byte, byte)
-
SDL_SetSurfaceAlphaMod
public static int SDL_SetSurfaceAlphaMod(SDL_Surface surface, byte alpha)
Set an additional alpha value used in blit operations.When this surface is blitted, during the blit operation the source alpha value is modulated by this alpha value according to the following formula:
srcA = srcA * (alpha / 255)
- Parameters:
surface
- the SDL_Surface structure to updatealpha
- the alpha value multiplied into blit operations- Returns:
- 0 on success or a negative error code on failure; call SDL_GetError() for more information.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_GetSurfaceAlphaMod(SDL_Surface, ByteByReference)
,SDL_SetSurfaceColorMod(SDL_Surface, byte, byte, byte)
-
SDL_GetSurfaceAlphaMod
public static int SDL_GetSurfaceAlphaMod(SDL_Surface surface, com.sun.jna.ptr.ByteByReference alpha)
Get the additional alpha value used in blit operations.- Parameters:
surface
- the SDL_Surface structure to queryalpha
- a pointer filled in with the current alpha value- Returns:
- 0 on success or a negative error code on failure; call SDL_GetError() for more information.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_GetSurfaceColorMod(SDL_Surface, ByteByReference, ByteByReference, ByteByReference)
,SDL_SetSurfaceAlphaMod(SDL_Surface, byte)
-
SDL_SetSurfaceBlendMode
public static int SDL_SetSurfaceBlendMode(SDL_Surface surface, int blendMode)
Set the blend mode used for blit operations.To copy a surface to another surface (or texture) without blending with the existing data, the blendmode of the SOURCE surface should be set to
SDL_BLENDMODE_NONE
.- Parameters:
surface
- the SDL_Surface structure to updateblendMode
- the SDL_BlendMode to use for blit blending- Returns:
- 0 on success or a negative error code on failure; call SDL_GetError() for more information.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_GetSurfaceBlendMode(SDL_Surface, SDL_BlendMode.Ref)
-
SDL_GetSurfaceBlendMode
public static int SDL_GetSurfaceBlendMode(SDL_Surface surface, SDL_BlendMode.Ref blendMode)
Get the blend mode used for blit operations.- Parameters:
surface
- the SDL_Surface structure to queryblendMode
- a pointer filled in with the current SDL_BlendMode- Returns:
- 0 on success or a negative error code on failure; call SDL_GetError() for more information.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_SetSurfaceBlendMode(SDL_Surface, int)
-
SDL_SetClipRect
public static boolean SDL_SetClipRect(SDL_Surface surface, SDL_Rect rect)
Set the clipping rectangle for a surface.When
surface
is the destination of a blit, only the area within the clip rectangle is drawn into.Note that blits are automatically clipped to the edges of the source and destination surfaces.
- Parameters:
surface
- the SDL_Surface structure to be clippedrect
- the SDL_Rect structure representing the clipping rectangle, or null to disable clipping- Returns:
- true if the rectangle intersects the surface, otherwise false and blits will be completely clipped.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_BlitSurface(SDL_Surface, SDL_Rect, SDL_Surface, SDL_Rect)
,SDL_GetClipRect(SDL_Surface, SDL_Rect)
-
SDL_GetClipRect
public static void SDL_GetClipRect(SDL_Surface surface, SDL_Rect rect)
Get the clipping rectangle for a surface.When
surface
is the destination of a blit, only the area within the clip rectangle is drawn into.- Parameters:
surface
- the SDL_Surface structure representing the surface to be clippedrect
- an SDL_Rect structure filled in with the clipping rectangle for the surface- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_BlitSurface(SDL_Surface, SDL_Rect, SDL_Surface, SDL_Rect)
,SDL_SetClipRect(SDL_Surface, SDL_Rect)
-
SDL_DuplicateSurface
public static SDL_Surface SDL_DuplicateSurface(SDL_Surface surface)
-
SDL_ConvertSurface
public static SDL_Surface SDL_ConvertSurface(SDL_Surface src, SDL_PixelFormat fmt, int flags)
Copy an existing surface to a new surface of the specified format.This function is used to optimize images for faster *repeat* blitting. This is accomplished by converting the original and storing the result as a new surface. The new, optimized surface can then be used as the source for future blits, making them faster.
- Parameters:
src
- the existing SDL_Surface structure to convertfmt
- the SDL_PixelFormat structure that the new surface is optimized forflags
- the flags are unused and should be set to 0; this is a leftover from SDL 1.2's API- Returns:
- the new SDL_Surface structure that is created or null if it fails; call SDL_GetError() for more information.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SdlPixels.SDL_AllocFormat(int)
,SDL_ConvertSurfaceFormat(SDL_Surface, int, int)
,SDL_CreateRGBSurface(int, int, int, int, int, int, int, int)
-
SDL_ConvertSurfaceFormat
public static SDL_Surface SDL_ConvertSurfaceFormat(SDL_Surface src, int pixelFormat, int flags)
Copy an existing surface to a new surface of the specified format enum.This function operates just like SDL_ConvertSurface(), but accepts an SDL_PixelFormatEnum value instead of an SDL_PixelFormat structure. As such, it might be easier to call but it doesn't have access to palette information for the destination surface, in case that would be important.
- Parameters:
src
- the existing SDL_Surface structure to convertpixelFormat
- the SDL_PixelFormatEnum that the new surface is optimized forflags
- the flags are unused and should be set to 0; this is a leftover from SDL 1.2's API- Returns:
- the new SDL_Surface structure that is created or null if it fails; call SDL_GetError() for more information.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SdlPixels.SDL_AllocFormat(int)
,SDL_ConvertSurface(SDL_Surface, SDL_PixelFormat, int)
,SDL_CreateRGBSurface(int, int, int, int, int, int, int, int)
-
SDL_ConvertPixels
public static int SDL_ConvertPixels(int width, int height, int srcFormat, com.sun.jna.Pointer src, int srcPitch, int dstFormat, com.sun.jna.Pointer dst, int dstPitch)
Copy a block of pixels of one format to another format.- Parameters:
width
- the width of the block to copy, in pixelsheight
- the height of the block to copy, in pixelssrcFormat
- an SDL_PixelFormatEnum value of thesrc
pixels formatsrc
- a pointer to the source pixelssrcPitch
- the pitch of the source pixels, in bytesdstFormat
- an SDL_PixelFormatEnum value of thedst
pixels formatdst
- a pointer to be filled in with new pixel datadstPitch
- the pitch of the destination pixels, in bytes- Returns:
- 0 on success or a negative error code on failure; call SDL_GetError() for more information.
- Since:
- This function is available since SDL 2.0.0.
-
SDL_PremultiplyAlpha
public static int SDL_PremultiplyAlpha(int width, int height, int srcFormat, com.sun.jna.Pointer src, int srcPitch, int dstFormat, com.sun.jna.Pointer dst, int dstPitch)
Premultiply the alpha on a block of pixels.This is safe to use with src == dst, but not for other overlapping areas.
This function is currently only implemented for SDL_PIXELFORMAT_ARGB8888.
- Parameters:
width
- the width of the block to convert, in pixelsheight
- the height of the block to convert, in pixelssrcFormat
- an SDL_PixelFormatEnum value of thesrc
pixels formatsrc
- a pointer to the source pixelssrcPitch
- the pitch of the source pixels, in bytesdstFormat
- an SDL_PixelFormatEnum value of thedst
pixels formatdst
- a pointer to be filled in with premultiplied pixel datadstPitch
- the pitch of the destination pixels, in bytes- Returns:
- 0 on success or a negative error code on failure; call SDL_GetError() for more information.
- Since:
- This function is available since SDL 2.0.18.
-
SDL_FillRect
public static int SDL_FillRect(SDL_Surface dst, SDL_Rect rect, int color)
Perform a fast fill of a rectangle with a specific color.color
should be a pixel of the format used by the surface, and can be generated by SDL_MapRGB() or SDL_MapRGBA(). If the color value contains an alpha component then the destination is simply filled with that alpha information, no blending takes place.If there is a clip rectangle set on the destination (set via SDL_SetClipRect()), then this function will fill based on the intersection of the clip rectangle and
rect
.- Parameters:
dst
- the SDL_Surface structure that is the drawing targetrect
- the SDL_Rect structure representing the rectangle to fill, or null to fill the entire surfacecolor
- the color to fill with- Returns:
- 0 on success or a negative error code on failure; call SDL_GetError() for more information.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_FillRects(SDL_Surface, ContiguousArrayList, int)
-
SDL_FillRects
public static int SDL_FillRects(SDL_Surface dst, ContiguousArrayList<SDL_Rect> rects, int color)
Perform a fast fill of a set of rectangles with a specific color.color
should be a pixel of the format used by the surface, and can be generated by SDL_MapRGB() or SDL_MapRGBA(). If the color value contains an alpha component then the destination is simply filled with that alpha information, no blending takes place.If there is a clip rectangle set on the destination (set via SDL_SetClipRect()), then this function will fill based on the intersection of the clip rectangle and
rect
.This is a Java-style version of a raw C-style function. Prefer this function over the raw C-style one.
- Parameters:
dst
- the SDL_Surface structure that is the drawing targetrects
- aContiguousArrayList
of SDL_Rects representing the rectangles to fill.color
- the color to fill with- Returns:
- 0 on success or a negative error code on failure; call SDL_GetError() for more information.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_FillRect(SDL_Surface, SDL_Rect, int)
-
SDL_FillRects
public static int SDL_FillRects(SDL_Surface dst, com.sun.jna.Pointer rects, int count, int color)
Perform a fast fill of a set of rectangles with a specific color.color
should be a pixel of the format used by the surface, and can be generated by SDL_MapRGB() or SDL_MapRGBA(). If the color value contains an alpha component then the destination is simply filled with that alpha information, no blending takes place.If there is a clip rectangle set on the destination (set via SDL_SetClipRect()), then this function will fill based on the intersection of the clip rectangle and
rect
.This is a raw C-style version of the function. Prefer Java-style version
SDL_FillRects(SDL_Surface, ContiguousArrayList, int)
.- Parameters:
dst
- the SDL_Surface structure that is the drawing targetrects
- an array of SDL_Rects representing the rectangles to fill.count
- the number of rectangles in the arraycolor
- the color to fill with- Returns:
- 0 on success or a negative error code on failure; call SDL_GetError() for more information.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_FillRect(SDL_Surface, SDL_Rect, int)
-
SDL_BlitSurface
public static int SDL_BlitSurface(SDL_Surface src, SDL_Rect srcRect, SDL_Surface dst, SDL_Rect dstRect)
Performs a fast blit from the source surface to the destination surface.This assumes that the source and destination rectangles are the same size. If either
srcrect
ordstrect
are null, the entire surface (src
ordst
) is copied. The final blit rectangles are saved insrcrect
anddstrect
after all clipping is performed.The blit function should not be called on a locked surface.
The blit semantics for surfaces with and without blending and colorkey are defined as follows:
RGBA->RGB: Source surface blend mode set to SDL_BLENDMODE_BLEND: alpha-blend (using the source alpha-channel and per-surface alpha) SDL_SRCCOLORKEY ignored. Source surface blend mode set to SDL_BLENDMODE_NONE: copy RGB. if SDL_SRCCOLORKEY set, only copy the pixels matching the RGB values of the source color key, ignoring alpha in the comparison. RGB->RGBA: Source surface blend mode set to SDL_BLENDMODE_BLEND: alpha-blend (using the source per-surface alpha) Source surface blend mode set to SDL_BLENDMODE_NONE: copy RGB, set destination alpha to source per-surface alpha value. both: if SDL_SRCCOLORKEY set, only copy the pixels matching the source color key. RGBA->RGBA: Source surface blend mode set to SDL_BLENDMODE_BLEND: alpha-blend (using the source alpha-channel and per-surface alpha) SDL_SRCCOLORKEY ignored. Source surface blend mode set to SDL_BLENDMODE_NONE: copy all of RGBA to the destination. if SDL_SRCCOLORKEY set, only copy the pixels matching the RGB values of the source color key, ignoring alpha in the comparison. RGB->RGB: Source surface blend mode set to SDL_BLENDMODE_BLEND: alpha-blend (using the source per-surface alpha) Source surface blend mode set to SDL_BLENDMODE_NONE: copy RGB. both: if SDL_SRCCOLORKEY set, only copy the pixels matching the source color key.
For blitting, prefer calling just this function (
SDL_BlitSurface()
) unless you know exactly how SDL blitting works internally and how to use the other blit functions.- Returns:
- 0 if the blit is successful, otherwise it returns -1.
-
SDL_UpperBlit
@Deprecated public static int SDL_UpperBlit(SDL_Surface src, SDL_Rect srcrect, SDL_Surface dst, SDL_Rect dstrect)
Deprecated.Perform a fast blit from the source surface to the destination surface.SDL_UpperBlit() has been replaced by SDL_BlitSurface(), because it has a less confusing name.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_BlitSurface(SDL_Surface, SDL_Rect, SDL_Surface, SDL_Rect)
-
SDL_LowerBlit
public static int SDL_LowerBlit(SDL_Surface src, SDL_Rect srcrect, SDL_Surface dst, SDL_Rect dstrect)
Perform low-level surface blitting only.This is a semi-private blit function and it performs low-level surface blitting, assuming the input rectangles have already been clipped.
Unless you know what you're doing, you should be using SDL_BlitSurface() instead.
- Parameters:
src
- the SDL_Surface structure to be copied fromsrcrect
- the SDL_Rect structure representing the rectangle to be copied, or null to copy the entire surfacedst
- the SDL_Surface structure that is the blit targetdstrect
- the SDL_Rect structure representing the rectangle that is copied into- Returns:
- 0 on success or a negative error code on failure; call SDL_GetError() for more information.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_BlitSurface(SDL_Surface, SDL_Rect, SDL_Surface, SDL_Rect)
-
SDL_SoftStretch
public static int SDL_SoftStretch(SDL_Surface src, SDL_Rect srcrect, SDL_Surface dst, SDL_Rect dstrect)
Perform a fast, low quality, stretch blit between two surfaces of the same format.Please use SDL_BlitScaled() instead.
- Since:
- This function is available since SDL 2.0.0.
-
SDL_SoftStretchLinear
public static int SDL_SoftStretchLinear(SDL_Surface src, SDL_Rect srcrect, SDL_Surface dst, SDL_Rect dstrect)
Perform bilinear scaling between two surfaces of the same format, 32BPP.- Since:
- This function is available since SDL 2.0.16.
-
SDL_BlitScaled
public static int SDL_BlitScaled(SDL_Surface src, SDL_Rect srcRect, SDL_Surface dst, SDL_Rect dstRect)
Perform a scaled surface copy to a destination surface.SDL_BlitScaled() is a replacement for SDL_UpperBlitScaled() with a less confusing name.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_BlitScaled(SDL_Surface, SDL_Rect, SDL_Surface, SDL_Rect)
-
SDL_UpperBlitScaled
@Deprecated public static int SDL_UpperBlitScaled(SDL_Surface src, SDL_Rect srcRect, SDL_Surface dst, SDL_Rect dstRect)
Deprecated.Perform a scaled surface copy to a destination surface.SDL_UpperBlitScaled() has been replaced by SDL_BlitScaled(), which is merely a macro for this function with a less confusing name.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_BlitScaled(SDL_Surface, SDL_Rect, SDL_Surface, SDL_Rect)
-
SDL_LowerBlitScaled
public static int SDL_LowerBlitScaled(SDL_Surface src, SDL_Rect srcRect, SDL_Surface dst, SDL_Rect dstRect)
Perform low-level surface scaled blitting only.This is a semi-private function and it performs low-level surface blitting, assuming the input rectangles have already been clipped.
- Parameters:
src
- the SDL_Surface structure to be copied fromsrcRect
- the SDL_Rect structure representing the rectangle to be copieddst
- the SDL_Surface structure that is the blit targetdstRect
- the SDL_Rect structure representing the rectangle that is copied into- Returns:
- 0 on success or a negative error code on failure; call SDL_GetError() for more information.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_BlitScaled(SDL_Surface, SDL_Rect, SDL_Surface, SDL_Rect)
-
SDL_SetYUVConversionMode
public static void SDL_SetYUVConversionMode(int mode)
Set the YUV conversion mode- Since:
- This function is available since SDL 2.0.8.
-
SDL_GetYUVConversionMode
public static int SDL_GetYUVConversionMode()
Get the YUV conversion mode- Since:
- This function is available since SDL 2.0.8.
-
SDL_GetYUVConversionModeForResolution
public static int SDL_GetYUVConversionModeForResolution(int width, int height)
Get the YUV conversion mode, returning the correct mode for the resolution when the current conversion mode is SDL_YUV_CONVERSION_AUTOMATIC- Since:
- This function is available since SDL 2.0.8.
-
-