sf.Image Class Reference

sf.Image is the low-level class for loading and manipulating images.
Default constructor : sf.Image()
Other constructors : sf.Image(Width=0, Height=0, Color=sf.Color.Black) or sf.Image(Width, Height, Data).
Copy constructor : sf.Image(Copy) where Copy is a sf.Image instance.

Static methods

GetValidTextureSize(Size)
Get a valid texture size according to hardware support. Returns valid nearest size (greater than or equal to specified size).
    Size     : Size to convert

Methods

Bind()
Bind the image for rendering.
Copy(Source, DestX, DestY, SourceRect = sf.IntRect(0,0,0,0))
Copy pixels from another image onto this one. This function does a slow pixel copy and should only be used at initialization time.
    Source : Source image to copy
    DestX : X coordinate of the destination position
    DestY : Y coordinate of the destination position
    SourceRect : Sub-rectangle of the source image to copy (empty by default - entire image)
    ApplyAlpha : Should the copy take in account the source transparency? (false by default)
CopyScreen(Window, SourceRect)
Create the image from the current contents of the given window. Return True if copy was successful.
    Window : Window to capture
    SourceRect : Sub-rectangle of the screen to copy (empty by default - entire image)
Create(Width=0, Height=0, Color=sf.Color.Black)
Create an empty image.
    Width     : Image width
    Height     : Image height
    Col     : Image color (black by default)
CreateMaskFromColor(Color)
Create transparency mask from a specified colorkey.
GetHeight()
Return the height of the image.
GetPixel(X, Y)
Get a pixel from the image.
GetPixels()
Get a string representing the array of pixels (8 bits integers RGBA). String length is GetWidth() x GetHeight() x 4. This string becomes invalid if you reload or resize the image.
GetTexCoords(Rect, Adjust=True)
Convert a subrect expressed in pixels, into float texture coordinates. Returns texture coordinates corresponding to the sub-rectangle (sf.FloatRect instance)
    Rect     : Sub-rectangle of image to convert
    Adjust     : Pass true to apply the half-texel adjustment
GetWidth()
Return the width of the image.
LoadFromFile(Path)
Load the surface from a file.
LoadFromMemory(Data)
Load the image from a file in memory.
LoadFromPixels(Width, Height, Data)
Load the image directly from a string of pixels.
SaveToFile(Path)
Save the content of the image to a file.
SetPixel(X, Y, Col)
Change the color of a pixel.
    X : X coordinate of pixel in the image
    Y : Y coordinate of pixel in the image
    Col : New color for pixel (X, Y)
SetSmooth(Smooth)
Enable or disable image smooth filter.