# sdl2.ext.surface - Creating and Manipulating Software Surfaces

This module provides methods for working with `SDL_Surface` objects.

Currently, the only function provided by this module is `subsurface()`, which allows the creation of a new surface from a subsection of a larger one.

sdl2.ext.surface.subsurface(surface, area)

  Creates a new `SDL_Surface` from a part of another surface.

  Surfaces created with this function will share pixel data with the original surface, meaning that any modifications to one surface will result in modifications to the other.

  Warning

  Because subsurfaces share pixel data with their parent surface, they cannot be used after the parent surface is freed. Doing so will almost certainly result in a segfault.

  Parameters:

    - surface (`SDL_Surface`) – The parent surface from which new sub-surface should be created.

    - area (`SDL_Rect`, tuple) – The `(x, y, w, h)` subset of the parent surface to use for the new surface, where `x, y` are the pixel coordinates of the top-left corner of the rectangle and `w, h` are its width and height (in pixels). Can also be specified as an `SDL_Rect`.

  Returns:

    The newly-created subsurface.

  Return type:

    `SDL_Surface`