CImage:Close


The Close method deletes the image opened or created by the CImage class and frees all associated memory.

Syntax

bSuccess = CImage:Close()

where

    bSuccess is the returned success code. On success it is true, otherwise false.

  

The Close method need not be called if the destructor delete is called; however, calling Close retains the CImage object while freeing the image from memory. Typically you use new to create a CImage object, then use Open and Close to load and unload images many times before eventually calling delete to remove the CImage from memory.

Example

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

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

-- close the if block.

  --

-- do something

I:Close()

-- remove the image from memory

I:delete()

-- if not getting another image, then delete the object.

Related Topics

Open

CImage class

CImageView class