attachlist_image CImage:AttachFromList

new_image


The new_image function is a non-class version of the CImage:new method which creates and returns a new CImage object. After creating a new image, you must use the Create, Open, or Copy method from the CImage class or attach it from the CImageView class. Note that the object can also be created using the CImage:new method.

Syntax

CImage = new_image()

CImage = new_image( CImage_old )

bullet.gif    This is a copy constructor. It creates a new CImage initialized to the properties of CImage_old

CImage = new_image( tbl )

bullet.gif    tbl is a lua array (simple 1-dimensional lua table) -- see Tables and Arrays - Overview.

bullet.gif    All methods return a new CImage object on success.

bullet.gif    On failure, nil is returned.

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 = new_image()

-- create a new CImage object

A:Open( sPath )

-- load an image from a file

B = new_image( 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

The following script creates a 1-dimensional CImage object from a lua array initialized to 1 million Gaussian deviates (noise). Then the mean and standard deviation of the image are calculated and printed:

tbl = gaussdev(1000000)

-- create an array of 1 millian Gaussian deviates

I = new_image( tbl )

-- create a new CImage with a copy of A

m,s = meansdev( I )

-- calculate the mean and standard deviation

Printf("m=%lg, s=%lg\n", m, s)

-- print the results

Related Topics

CImage class

Copy

Create

new

delete

Math Operators

arraytoimage

Tables and Arrays - Overview.

 

 

 


Mira Pro x64 Script User's Guide, v.8.73 Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.