CImage:Class Description CImage:delete

CImage:new


The new method constructs a new instance of a CImage object. Four constructors are available.

Syntax

CImage = CImage:new()

  • Creates a new CImage with the image pointer initialized to nil.

CImage = CImage:new( CImage2 )

  • This is a copy constructor. It creates a new CImage initialized to the properties of CImage2.

CImage = CImage:new( nCols, sDataType )

  • Creates a new CImage initialized to nCols columns (pixels) with datatype sDataType. (e.g., "byte", "float", etc.).

CImage = CImage:new( nCols, nRows, sDataType )

  • Creates a new CImage initialized to nCols columns x nRows rows with datatype sDataType. (e.g., "byte", "float", etc.).

Remarks

Four overloads are provided for constructing a new CImage object; they create an empty CImage, a copy of an existing CImage, or a CImage of specified size and data type. If you pass something other than the options described above, an empty CImage is returned. Before using an empty CImage, you must use Create, Open, Copy, or CImageView:Attach or a related method to assign aimage data to it.

Example

The following script creates a CImage object and loads an image into it. Then it creates a new CImage that is a duplicate of the first one. This makes 2 images loaded into memory:

A = CImage:new()

-- create a new CImage object

A:Open( sPath )

-- load an image from a file

B = CImage:new( A )

-- create a new CImage with a copy of A

Printf("A name: %s\n", A:Path(60))

-- print the name of image A

Printf("B name: %s\n", B:Path(60))

-- print the name of image B. Same as A

A:delete()

-- delete when done

B:delete()

-- delete when done

Related Topics

CImage, Copy, Ceate, delete