What does GrabImage exactly do(SOLVED)

Monkey Forums/Monkey Programming/What does GrabImage exactly do(SOLVED)

nachiketaom(Posted 2016) [#1]
How to use GrabImage(x, y, w, h)?

It says that GrabImage will create a new image by 'grabbing' a rectangular region of the current image. However, I want to understand three things:

1. Where do we specify which base image to use? (we are not specifying any image whose specified rectangular area is to be grabbed, CURRENT IMAGE means what)

2. Does it make place for another image in the RAM, or does it simply stores the coordinates on specified image. (Storing the image again is expensive)

3. How do i delete the image I have loaded when I want to clear the memory of it? Or is it just like 'remove the reference and the Garbage Collector will remove it'?

HEY I JUST FOUND THE ANSWER...
1. First we have to load an image into the memory, (say) originalTexture. Then we have to do originalTexture.GrabImage...
2. Yes, MonkeyX stores the Grabbed Images in the RAM. In order to avoid duplicates, always load the originalTexture above as a local image, so it will be removed after the method in which you grab the images off it. Thus only the grabbed images will be saved
3. I feel it is the same way you delete class instances that you delete images. Just remove the reference and it will be Garbage-Collected. Please correct me if I am wrong here.


Gerry Quinn(Posted 2016) [#2]
I don't think that's the answer.

As I understand matters, the original image stays in VRAM, and the grabbed image just has a position and rectangle on that original.

So if you load one large original image and grab some images off it, there is still only the large image in memory, and it will stay until the original and all grabbed images are discarded.