Home

Surface

Core class

Operations

New

Creates new RGB surface

New(flags:Int, width:Int, height:Int, depth:Int, Rmask:Int, Gmask:Int, Bmask:Int, Amask:Int)
Parameters
NameTypeDescription
flagsIntthe flags are unused and should be set to 0
widthIntthe width of the surface
heightIntthe height of the surface
depthIntthe depth of the surface in bits; see Remarks for details
RmaskIntthe red mask for the pixels
GmaskIntthe green mask for the pixels
BmaskIntthe blue mask for the pixels
AmaskIntthe alpha mask for the pixels

Blit

Perform a fast surface copy to a destination surface

method : public : Blit(srcrect:Rect, dst:Surface, dstrect:Rect) ~ Int
Parameters
NameTypeDescription
srcrectRectthe SDL_Rect structure representing the rectangle to be copied, or NULL to copy the entire surface
dstSurfacethe SDL_Surface structure that is the blit target
dstrectRectthe SDL_Rect structure representing the rectangle that is copied into

Return
TypeDescription
Int0 if the blit is successful or a negative error code on failure

BlitScaled

Scaled surface copy to a destination surface

method : public : BlitScaled(srcrect:Rect, dst:Surface, dstrect:Rect) ~ Int
Parameters
NameTypeDescription
srcrectRectthe SDL_Rect structure representing the rectangle to be copied, or NULL to copy the entire surface
dstSurfacethe SDL_Surface structure that is the blit target
dstrectRectthe SDL_Rect structure representing the rectangle that is copied into

Return
TypeDescription
Int0 if the blit is successful or a negative error code on failure

Convert

Copy an existing surface into a new one that is optimized for blitting to a surface of a specified pixel format

method : public : Convert(fmt:PixelFormat, flags:Int) ~ Surface
Parameters
NameTypeDescription
fmtPixelFormatPixelFormat structure that the new surface is optimized for
flagsIntflags are unused and should be set to 0

Return
TypeDescription
Surfacenew SDL_Surface structure that is created

ConvertFormat

Copy an existing surface to a new surface of the specified format

method : public : ConvertFormat(format:Int, flags:Int) ~ Surface
Parameters
NameTypeDescription
formatIntone of the enumerated values in SDL_PixelFormatEnum; see Remarks for details
flagsIntthe flags are unused and should be set to 0

Return
TypeDescription
Surfacethe new surface

CreateTexture

Create a texture from an existing surface

method : public : CreateTexture(renderer:Renderer) ~ Texture
Parameters
NameTypeDescription
rendererRendererthe rendering context

Return
TypeDescription
Texturenewly created texture

FillRect

perform a fast fill of a rectangle with a specific color

method : public : FillRect(rect:Rect, color:Int) ~ Int
Parameters
NameTypeDescription
rectRectRect structure representing the rectangle to fill, or Nil to fill the entire surface
colorIntcolor to fill with

Return
TypeDescription
Int0 on success or a negative error code on failure

Free

Frees the event

method : public : Free() ~ Nil

GetAlphaMod

Get the additional alpha value used in blit operations

method : public : GetAlphaMod(alpha:IntHolder) ~ Int
Parameters
NameTypeDescription
alphaIntHolderholder filled in with the current alpha value

Return
TypeDescription
Int0 on success or a negative error code on failure

GetBlendMode

get the blend mode used for blit operations

method : public : GetBlendMode(blendMode:IntHolder) ~ Int
Parameters
NameTypeDescription
blendModeIntHolderpointer filled in with the current BlendMode

Return
TypeDescription
Int0 on success or a negative error code on failure

GetClipRect

Get the clipping rectangle for a surface

method : public : GetClipRect(rect:Rect) ~ Nil
Parameters
NameTypeDescription
rectRectRect filled in with the clipping rectangle for the surface

GetColorKey

Get the color key (transparent pixel) for a surface

method : public : GetColorKey(key:IntHolder) ~ Int
Parameters
NameTypeDescription
keyIntHoldera holder filled in with the transparent pixel

Return
TypeDescription
Int0 on success or a negative error code on failure

GetColorMod

Get the additional color value multiplied into blit operations

method : public : GetColorMod(r:IntHolder, g:IntHolder, b:IntHolder) ~ Int
Parameters
NameTypeDescription
rIntHolderpointer filled in with the current red color value
gIntHolderpointer filled in with the current green color value
bIntHolderpointer filled in with the current blue color value

Return
TypeDescription
Int0 on success or a negative error code on failure

GetH

Get height

method : public : GetH() ~ Int
Return
TypeDescription
Intheight

GetPitch

Get length of a row of pixels in bytes

method : public : GetPitch() ~ Int
Return
TypeDescription
Intpitch

GetPixelFormat

Get pixel format

method : public : GetPixelFormat() ~ PixelFormat
Return
TypeDescription
PixelFormatpixel format

GetPixels

Get raw pixels

method : public : GetPixels() ~ PixelData
Return
TypeDescription
PixelDataraw pixels

GetW

Get width

method : public : GetW() ~ Int
Return
TypeDescription
Intwidth

IsNull

Determines if the underlying SDL C-struct is NULL

method : public : IsNull() ~ Bool
Return
TypeDescription
Booltrue if NULL, false otherwise

LoadBMP

Load a surface from a BMP file.

function : public : LoadBMP(file:String) ~ Surface
Parameters
NameTypeDescription
fileStringthe file containing a BMP image

Return
TypeDescription
Surfacenewly created texture

Lock

Set up a surface for directly accessing the pixels

method : public : Lock() ~ Int

LowerBlit

Perform low-level surface blitting only

method : public : LowerBlit(srcrect:Rect, dst:Surface, dstrect:Rect) ~ Int
Parameters
NameTypeDescription
srcrectRectthe SDL_Rect structure representing the rectangle to be copied, or NULL to copy the entire surface
dstSurfacethe SDL_Surface structure that is the blit target
dstrectRectthe SDL_Rect structure representing the rectangle that is copied into

Return
TypeDescription
Int0 if the blit is successful or a negative error code on failure

LowerBlitScaled

Perform low-level surface scaled blitting only

method : public : LowerBlitScaled(srcrect:Rect, dst:Surface, dstrect:Rect) ~ Int
Parameters
NameTypeDescription
srcrectRectthe SDL_Rect structure representing the rectangle to be copied, or NULL to copy the entire surface
dstSurfacethe SDL_Surface structure that is the blit target
dstrectRectthe SDL_Rect structure representing the rectangle that is copied into

Return
TypeDescription
Int0 if the blit is successful or a negative error code on failure

SaveBMP

save a surface to a BMP file

function : public : SaveBMP(surface:Surface, file:String) ~ Int
Parameters
NameTypeDescription
surfaceSurfaceSurface instance containing the image to be saved
fileStringfile to be saved to

Return
TypeDescription
Int0 on success or a negative error code on failure

SetAlphaMod

Set an additional alpha value used in blit operations

method : public : SetAlphaMod(alpha:Int) ~ Int
Parameters
NameTypeDescription
alphaIntalpha value multiplied into blit operations

Return
TypeDescription
Int0 on success or a negative error code on failure

SetBlendMode

set the blend mode used for blit operations

method : public : SetBlendMode(blendMode:BlendMode) ~ Int
Parameters
NameTypeDescription
blendModeBlendModeBlendMode to use for blit blending

Return
TypeDescription
Int0 on success or a negative error code on failure

SetClipRect

Set the clipping rectangle for a surface

method : public : SetClipRect(rect:Rect) ~ Bool
Parameters
NameTypeDescription
rectRectRect structure representing the clipping rectangle, or Nil to disable clipping

Return
TypeDescription
BoolReturns true if the rectangle intersects the surface, otherwise false and blits will be completely clipped

SetColorKey

Set the color key (transparent pixel) in a surface

method : public : SetColorKey(flag:Bool, key:Int) ~ Int
Parameters
NameTypeDescription
flagBooltrue to enable color key, false to disable color key
keyIntthe transparent pixel

Return
TypeDescription
Int0 on success or a negative error code on failure

SetColorMod

Set an additional color value multiplied into blit operation

method : public : SetColorMod(r:Int, g:Int, b:Int) ~ Int
Parameters
NameTypeDescription
rIntthe red color value multiplied into blit operations
gIntthe green color value multiplied into blit operations
bIntthe blue color value multiplied into blit operations

Return
TypeDescription
Int0 on success or a negative error code on failure

SetRLE

Set the RLE acceleration hint for a surface

method : public : SetRLE(flag:Int) ~ Int
Parameters
NameTypeDescription
flagInt0 to disable, non-zero to enable RLE acceleration

Return
TypeDescription
Int0 on success or a negative error code on failure

Unlock

Release a surface after directly accessing the pixels

method : public : Unlock() ~ Nil