CImage:delete CImage:Attach

CImage:Copy


The Copy method makes a copy of the CImage object, including its encapsulated image. Therefore the CImage should be terminated using Close or delete when you are done using it.

Syntax

I = CImage:Copy()

    On success, this method returns a new CImage object I containing an independent copy of the image. In place of CImage, use the name of the actual object to be copied (see Example).

    On failure, this method returns nil.

Example

Suppose an image file exists with a full path named sPath. The script fragment below shows the image being opened and copied:

I = CImage:new()

-- create a CImage object

bOk = I:Open(sPath)

-- open the image from path sPath.

if ( not bOk ) then

-- if not opened, then...

  Exit()

-- leave the script, etc.

end

-- end of if block

I2 = I:Copy()

-- create a new CImage named I2

  ...

-- do something

I:delete()

-- when done with I, remove it from memory

I2:delete()

-- when done with I2, remove it from memory

Related Topics

CImage, Open, Close