DrawImageRect and midhandle?

Monkey Forums/Monkey Programming/DrawImageRect and midhandle?

Supertino(Posted 2012) [#1]
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?


therevills(Posted 2012) [#2]
What about grabbing the individual images and storing them as their own image, therefore you will be able to set the handle per image?


ziggy(Posted 2012) [#3]
@therevills: Wouldn't this consume additional VRAM?


NoOdle(Posted 2012) [#4]
@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.


therevills(Posted 2012) [#5]
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).


ziggy(Posted 2012) [#6]
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.


Supertino(Posted 2012) [#7]
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.


Raz(Posted 2012) [#8]
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!


Alex(Posted 2013) [#9]
Didn't know that, thanks!

Will my grabbed reference be discarded if I discard the source?


Skn3(Posted 2013) [#10]
Nope they are their own image but just referencing the texture same texture.


Alex(Posted 2013) [#11]
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.


Gerry Quinn(Posted 2013) [#12]
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.


Jesse(Posted 2013) [#13]
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.