CImage:Attach
The Attach method associates a foreign image pointer with the CImage object. This permits CImage functionality to be used with the image not owned by the CImage.
bSuccess = CImage:Attach( pointer ) |
wherepointer refers to an image, not a CImage.
On success (the pointer was not nil), this method returns true.
On failure, false is returned.
Using Attach provides CImage class functionality to be used with an image owned by another class, but the CImage does not own the foreign image or make a copy of it. Use this method, for example, to work with a displayed image that is owned by an image view window, but for that purpose it is usually preferable to use the CImageView:GetImage method.
Suppose an image window exists and is Wrapped by a CImageView object named V:
I = CImage:new() |
-- create a CImage object |
p = V:GetImagePtr() |
-- return a pointer to the current displayed image |
I:Attach( p ) |
-- attach the pointer p to CImage I |
nValue = I:Val(10,20) |
-- fetch the value of the pixel at coordinate (10,20) |
I:delete() |
-- does not delete the image in V |