DrawImageRect and midhandle?
Monkey Forums/Monkey Programming/DrawImageRect and midhandle?
| ||
Any body think of a neat way to change the handle of an image drawn using DrawImageRect so the image can rotated around it's center rather then top left? Got a big image atlas full of buttons and other stuff - some need to be mid handled some not. With a single image I would simply; image = loadimage("blah.png",1,image.midhandle) Any ideas? |
| ||
What about grabbing the individual images and storing them as their own image, therefore you will be able to set the handle per image? |
| ||
@therevills: Wouldn't this consume additional VRAM? |
| ||
@ziggy: from what I remember, it is essentially the same thing, they both reference the same texture and coords. This is how I solved the problem of loading sprite sheets with rotated frames. |
| ||
I believe that is correct Noodle, from my understanding a grabbed image and its source image share the same surface texture in Mojo (in other words Mojo creates a new Image object that references the original surface). |
| ||
therevills: I didn't know that! That's very useful! EDIT: Can't find any GrabImage command. How's it called? EDIT2: Forget it I've just found it is a method of any Image instance. |
| ||
Ah yes I also thought grabimage created a new bitmap, a hang over my my blitzmax days maybe. TBH grab image makes the whole thing easier so that's a plus. |
| ||
Euuuugh, I wish I had read the documentation better and/or not made assumptions Using grabimage for sub images / animations would've really made my life a hell of a lot easier on just about everything I've done! |
| ||
Didn't know that, thanks! Will my grabbed reference be discarded if I discard the source? |
| ||
Nope they are their own image but just referencing the texture same texture. |
| ||
Thanks, I tested GrabImage a little. When I discard source, reference is not working. However, the error is not the same as there's no image at all. So, I assume I need to discard references fist, then discard the source. |
| ||
I guess when you start discarding stuff, you can no longer completely rely on GC to be safe. So you have to memory-manage anything connected to the discarded item. |
| ||
Mark mentioned on a thread that when you create an image with GrabImage. the new image has a link to the original image and therefore the original image will not be garbage collected. |