TextureData

TextureData class

This class contains the raw data and format definition of a texture.

Methods

constructor

NameDescription
constructor(width, height, stride, bytesPerPixel, pixelFormat, data)Constructor of TextureData

Parameters:

NameTypeDescription
widtNumbernull
heighNumbernull
stridNumbernull
bytesPerPixeNumbernull
pixelFormatPixelFormatPixelFormat
datbyte[]null

Result:


constructor_overload

NameDescription
constructor_overload(width, height, pixelFormat)Constructs a new TextureData and allocate pixel data.

Parameters:

NameTypeDescription
widtNumbernull
heighNumbernull
pixelFormatPixelFormatPixelFormat

Result:


constructor_overload$2{#constructor_overload$2}

NameDescription
constructor_overload$2()Constructor of TextureData

Result:


getData

NameDescription
getData()Raw bytes of pixel data

Result:


getWidth

NameDescription
getWidth()Number of horizontal pixels

Result:


getHeight

NameDescription
getHeight()Number of vertical pixels

Result:


getStride

NameDescription
getStride()Number of bytes of a scanline.

Result:


getBytesPerPixel

NameDescription
getBytesPerPixel()Number of bytes of a pixel

Result:


getPixelFormat

NameDescription
getPixelFormat()The pixel’s format The value of the property is PixelFormat integer constant.

Result:


fromFile

NameDescription
fromFile(fileName)Load a texture from file

Parameters:

NameTypeDescription
fileNamStringnull

Result: TextureData


save

NameDescription
save(fileName)Save texture data into image file

Parameters:

NameTypeDescription
fileNameStringThe file name of where the image will be saved.

Result: TextureData


save

NameDescription
save(fileName, format)Save texture data into image file

Parameters:

NameTypeDescription
fileNameStringThe file name of where the image will be saved.
formatStringImage format of the output file.

Result: TextureData


mapPixels

NameDescription
mapPixels(mapMode)Map all pixels for read/write

Parameters:

NameTypeDescription
mapModePixelMapModePixelMapMode

Result: PixelMapping


mapPixels

NameDescription
mapPixels(mapMode, format)Map all pixels for read/write in given pixel format

Parameters:

NameTypeDescription
mapModePixelMapModePixelMapMode
formatPixelFormatPixelFormat

Result: PixelMapping


mapPixels

NameDescription
mapPixels(rect, mapMode, format)Map pixels addressed by rect for reading/writing in given pixel format

Parameters:

NameTypeDescription
rectRectThe area of pixels to be accessed
mapModePixelMapModePixelMapMode
formatPixelFormatPixelFormat

Result: PixelMapping


transformPixelFormat

NameDescription
transformPixelFormat(pixelFormat)Transform pixel’s layout to new pixel format.

Parameters:

NameTypeDescription
pixelFormatPixelFormatPixelFormat

Result: PixelMapping