Class SdlSurface


  • public final class SdlSurface
    extends Object
    Definitions from file SDL_surface.h

    SDL_Surface management functions.

    • 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. 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 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 0
        width - the width of the surface
        height - the height of the surface
        depth - the depth of the surface in bits
        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
        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 0
        width - the width of the surface
        height - the height of the surface
        depth - the depth of the surface in bits
        format - 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 data
        width - the width of the surface
        height - the height of the surface
        depth - the depth of the surface in bits
        pitch - the pitch of the surface 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
        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 data
        width - the width of the surface
        height - the height of the surface
        depth - the depth of the surface in bits
        pitch - the pitch of the surface in bytes
        format - 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_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 update
        palette - 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 in surface.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 surface
        freesrc - 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 saved
        dst - a data stream to save to
        freedst - 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 optimize
        flag - 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 enabled

        It 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 update
        flag - true to enable color key, false to disable color key
        key - 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_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 query
        key - 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 update
        r - the red color value multiplied into blit operations
        g - the green color value multiplied into blit operations
        b - 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 query
        r - a pointer filled in with the current red color value
        g - a pointer filled in with the current green color value
        b - 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 update
        alpha - 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_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 update
        blendMode - 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 query
        blendMode - 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 clipped
        rect - 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_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 convert
        fmt - the SDL_PixelFormat structure that the new surface is optimized for
        flags - 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 convert
        pixelFormat - the SDL_PixelFormatEnum that the new surface is optimized for
        flags - 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 pixels
        height - the height of the block to copy, in pixels
        srcFormat - an SDL_PixelFormatEnum value of the src pixels format
        src - a pointer to the source pixels
        srcPitch - the pitch of the source pixels, in bytes
        dstFormat - an SDL_PixelFormatEnum value of the dst pixels format
        dst - a pointer to be filled in with new pixel data
        dstPitch - 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 pixels
        height - the height of the block to convert, in pixels
        srcFormat - an SDL_PixelFormatEnum value of the src pixels format
        src - a pointer to the source pixels
        srcPitch - the pitch of the source pixels, in bytes
        dstFormat - an SDL_PixelFormatEnum value of the dst pixels format
        dst - a pointer to be filled in with premultiplied pixel data
        dstPitch - 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 target
        rect - the SDL_Rect structure representing the rectangle to fill, or null to fill the entire surface
        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_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 target
        rects - a ContiguousArrayList 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 target
        rects - an array of SDL_Rects representing the rectangles to fill.
        count - the number of rectangles in the array
        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_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 or dstrect are null, the entire surface (src or dst) is copied. The final blit rectangles are saved in srcrect and dstrect 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_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 from
        srcrect - the SDL_Rect structure representing the rectangle to be copied, or null to copy the entire surface
        dst - the SDL_Surface structure that is the blit target
        dstrect - 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_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 from
        srcRect - the SDL_Rect structure representing the rectangle to be copied
        dst - the SDL_Surface structure that is the blit target
        dstRect - 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.