Static variables
Static methods
staticcreateRenderTarget(width:Int, height:Int, ?format:TextureFormat, depthStencil:DepthStencilFormat = DepthStencilFormat.NoDepthAndStencil, antiAliasingSamples:Int = 1):Image
staticfromBytes3D(bytes:Bytes, width:Int, height:Int, depth:Int, ?format:TextureFormat, ?usage:Usage):Image
Variables
read onlyrealHeight:Int
Very old GPUs only supported power of two texture-heights. When an Image is created on such a GPU, Kha automatically increases its size to a power of two and realHeight returns this new, internal size. Knowing the real size is important for calculating texture-coordinates correctly but all of this is irrelevant unless you really want to support very very old GPUs.
read onlyrealWidth:Int
Very old GPUs only supported power of two texture-widths. When an Image is created on such a GPU, Kha automatically increases its size to a power of two and realWidth returns this new, internal size. Knowing the real size is important for calculating texture-coordinates correctly but all of this is irrelevant unless you really want to support very very old GPUs.
Methods
at(x:Int, y:Int):Color
Returns the color of a pixel identified by its x/y-coordinates. This only works for images for which the readable flag is set to true because by default images only exist in video-memory. To load images which are readable use a line ala project.addAssets('Assets/image.png', { readable: true }); in your khafile. For reading the content of render-targets use getPixels() instead.
getPixels():Bytes
Returns the content of an image. This only works if the image is a render-target and it is very slow because data will be copied from video-memory to main-memory. This is useful for making screenshots but please avoid using it for regular rendering. For reading the content of images which are not render-targets use at() instead.
lock(level:Int = 0):Bytes
Returns a writable Bytes object. Once unlock() is called the content of the Bytes object is written into the image. This can not be used to read the current content of an image - for this use at() or getPixels() instead.