Non-destructive dynamic sprite resize?

Started by Knox, Tue 15/06/2010 17:31:18

Previous topic - Next topic

Knox

Hi,

Im not too sure if this makes sense but now Im at the stage of implementing something probably easy for the most of you but hard for me :P

Ok, right now my savegame saves a screenshot 320x240, but I resize it to 120x90 to fit my button in the previewGUI. I was thinking that when I click on this button, I could "restore" the 320x240 image by simply resizing it "back" to its "original" 320x240 resolution. I was wrong.

Right now it seems resizing is destructive, as in, when I restore the resized image back to its original size, its all pixelated.

Is there a way I can resize a large savegame screenshot, resize it for previewing purposes, but once clicked on, the "full-res" version gets displayed...without having to save 2 versions of the screenshot, of course :P

(ps: I guess as a work-around I might have to save a low-res and hi-res version of each savegame screenshot, right?)
--All that is necessary for evil to triumph is for good men to do nothing.

Monsieur OUXX

Yes, resizing is destructive.
Why don't you store the bigger version, but then downsize it in the last moment, just for the preview?
 

Ryan Timothy B

I haven't played with the save game screenshot much.  I would save the larger version but only downsize it when it's needed; for instance when the GUI opens or you select a save game.  Of course you'd have to store the sprite in a temporary dynamic sprite variable, and delete it once it's not visible/needed anymore.

Code: ags

DynamicSprite* shrunkenScreenShot;


Just don't forget. There is no sense in carrying a sprite in the ram for no reason if it's not being used anymore.
Code: ags

shrunkenScreenShot.Delete();

Knox

Ok so I created two dynamic sprite variables...one thats the original size and one that is shrunk down.

I got it to work like I want to!

Thanks once again guys!


ps: Is there a way to know if there is a dynamic sprite in the ram "by accident"...as in, lets say I forgot to delete it somewhere within my script?

If a sprite is carried in the ram for no reason, what happens? What can go wrong, etc...
--All that is necessary for evil to triumph is for good men to do nothing.

Charity

Games used to generate a text file if there was a memory leak with the dynamic sprites.  I think that's what you're talking about.  There was some talk of altering the circumstances under which such a file was generated, but I don't know if anything came of that.  To my knowledge, it didn't say where in the script excess sprite were being generated, but I could be wrong.  In any case, what was said was that Windows should delete them automatically when you close AGS, so it is only a real problem if you are generating a lot of them and not deleting them.  In this case you have to worry about crashes and slowdown etc.?  I haven't messed with these features in a while, so I don't recall if it is possible to generate an indefinite number of dynamic sprites without deleting/overriding them, but if that's happening, obviously it's bad.

More tech savvy people will probably have more to say.

Ryan Timothy B

Sorry, I didn't really mean that you 'had' to delete them.  But it's good practice considering AGS will save both sprites on Game saves, even though it really doesn't need to save the smaller one.  You could have longer save times, longer load times.  It will also haul that sprite around indefinitely while the game is running unless you delete it.

As I said, it may actually not even be noticeable if you didn't delete that smaller screen shot when it's not needed.  I just figure since it's a GUI that is not visible all the time, it was worth mentioning.

SMF spam blocked by CleanTalk