Creating and saving an image from sprite?

For questions about using Classic.

Post » Mon Feb 09, 2009 6:11 pm

Basically say i have two sprites, one is on top of the other, i want to make an image out of them together and save it, is it possible in construct? I know you can do it in the old mmf but not sure how to do it here?

I haven't found any way to have two sprites merged together or to have an image created from a certain area, one of those two would be excellent to have!
B
3
S
2
G
5
Posts: 301
Reputation: 2,302

Post » Mon Feb 09, 2009 7:13 pm

You can paste sprites into a canvas object but you can't save to a file. Unless there's some other method for doing that.
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Mon Feb 09, 2009 7:20 pm

Well i tried paste sprite into canvas, then image manipulator copies from canvas, then saves into a new image.

Image is always blank.
B
3
S
2
G
5
Posts: 301
Reputation: 2,302

Post » Mon Feb 09, 2009 8:25 pm

[quote="liamdawe":16x2oi7e]Well i tried paste sprite into canvas, then image manipulator copies from canvas, then saves into a new image.

Image is always blank.[/quote:16x2oi7e]

There needs to be time between pasting the object into the canvas, copying the canvas to the image manipulator, and then saving the image. So you could do something like this with the function object:
[code:16x2oi7e]
1. +Stuff happens:
-Canvas: Paste Sprite into Canvas
-Function: Call function "Copy" after 100ms.

2. +On function "Copy"
-ImageManipulator: Copy image from Canvas
-Function: Call function "Save" after 100ms.

3. +On function "Save"
-ImageManipulator: Save PNG image to "c:\stuff.png"
[/code:16x2oi7e]
I don't think the ImageManipulator is able to process the images as fast as is needed to copy from the canvas and then save the image all in one event, so this is necessary. Hope that helps. :)
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Post » Mon Feb 09, 2009 8:36 pm

You where completely right, that is annoying heh.
B
3
S
2
G
5
Posts: 301
Reputation: 2,302

Post » Mon Feb 09, 2009 8:44 pm

Events aren't run while the GPU is drawing necessarily, so if you copy from a canvas directly after instructing it to draw, it won't have drawn yet, and you'll get a blank image.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Mon Feb 09, 2009 8:49 pm

Well it doesn't seem to work at all now, heres a shot of what i'm doing:
B
3
S
2
G
5
Posts: 301
Reputation: 2,302

Post » Mon Feb 09, 2009 8:50 pm

The delay is needed after copying to canvas, not after copying to image manipulator.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Mon Feb 09, 2009 8:55 pm

Ah ha thank you my man, you saved me dude.
B
3
S
2
G
5
Posts: 301
Reputation: 2,302

Post » Mon Feb 09, 2009 9:13 pm

Possibly a bug though:
Canvas is sized 20x20 and a sprite is sized 20x20 no resizing done afterwards yet the canvas is largely bigger than the sprite?
B
3
S
2
G
5
Posts: 301
Reputation: 2,302

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest