CImage:ScalePolyVal CImage:SetRegionVal

CImage:SetDatatype


The SetDatatype method sets or changes the pixel data type of image pixels.

Syntax

CImage:SetDatatype( datatype )

    wheredatatype is a number or string code for the data type (see Remarks).

Remarks

The datatype argument is either a numeric code or a string representing the target data type as defined in the Mira Data Types table. For example, the code 1 corresponds to data type string "byte". if a string is passed as the datatype argument, Mira tries to interpret it as a datatype name, rather than a number code.

If you want to retrieve the data type of the image, use Datatype to get the numeric code or DatatypeStr to get the string name.

Example

The following script fragment loads an image, changes its data type to "float" (32 bit real) using a data type code number, and then saves the image:

 

I = CImage:new()

-- Create a CImage

I:Open( sPath )

-- Open the image from file path sPath.

I:SetDatatype( 5 )

-- change data type to 32 bit real (code 5)

I:Save()

-- save the image

I:delete()

-- delete the CImage from memory

Alternatively, you can achieve the same result by specifying the data type string "float" as follows:   

I = CImage:new()

-- Create a CImage

I:Open( sPath )

-- Open the image from file path sPath.

I:SetDatatype( "float" )

-- change data type to 32 bit real (code 5)

I:Save()

-- save the image

I:delete()

-- delete the CImage from memory

Related Topics

CImage, Data Types, Datatype, DatatypeStr