User Tag List

Results 1 to 9 of 9

Thread: How to proportionally adjust an image manually?

  1. #1
    Clicker Multimedia Fusion 2 DeveloperInstall Creator Pro

    Join Date
    May 2010
    Posts
    536
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How to proportionally adjust an image manually?

    Hey, folks!

    I need a little help thinking through some math (which I suck at)...

    I'm using the Surface object to display images (such as BMPs, JPGs, and PNGs). I am in the process of setting up conditions such that if the image to be displayed is larger than the screen width (or screen height, or both), to adjust the image to "best fit" the screen.

    What I am having problems with is calculating how to reduce an image proportionally. Since the Surface object doesn't offer an action to adjust size by percentage or scale, how can this be done manually? So, as a test example, if an image's width is wider than the screen's width, how would I determine what percentage to reduce the image's width (which I would then use to reduce the image's height by the same percentage)?

    Pretty simple concept, I know... But I really suck at math...

    Thanks for your help!

  2. #2
    Forum Moderator

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export ModuleInstall Creator Pro
    nivram's Avatar
    Join Date
    Jul 2006
    Location
    Bandon, Oregon
    Posts
    6,773
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    If you can get away with not using the surface object, the Picture Object will automatically adjust the photo to its size. For example:

    User clicks on active system box 1
    +String$("string")="flint"
    --->Picure Object:new picture (this will be the location of your picture)

    Marv
    ​458 TGF to CTF 2.5+ Examples and games
    http://www.castles-of-britain.com/mmf2examples.htm

  3. #3
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Transform -> Resize -> X Size * Scale, Y Size * Scale
    Where Scale is Min(Max Width*1.0/Normal Width, Max Height*1.0/Normal Height)
    Working as fast as I can on Fusion 3

  4. #4
    Forum Moderator

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export ModuleInstall Creator Pro
    nivram's Avatar
    Join Date
    Jul 2006
    Location
    Bandon, Oregon
    Posts
    6,773
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by LB View Post
    Transform -> Resize -> X Size * Scale, Y Size * Scale
    Where Scale is Min(X Size / Max X, Y Size / Max Y)

    (I think)
    LB. If no one clutches their chest about this formula, I will add it to the Tech Manual. I believe it is a new one for the manual.

    Marv
    ​458 TGF to CTF 2.5+ Examples and games
    http://www.castles-of-britain.com/mmf2examples.htm

  5. #5
    Clicker Fusion 2.5 MacFusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)Firefly 3D Module (Steam)
    Phi's Avatar
    Join Date
    Jan 2010
    Location
    England
    Posts
    1,964
    Mentioned
    25 Post(s)
    Tagged
    0 Thread(s)
    Whoa! That reminds me of my old unoptimised formula for ensuring a maths equation is calculated as a float.

    Str$(Val(CompareIntegers$( "IIF", ReverseFind(List Line Text$( "Computing list", LoopIndex("Solve")-1), ".", 0), ">", -1, List Line Text$( "Computing list", LoopIndex("Solve")-1)+("0."+RepeatCharacters$( "Rep", "0", Len(List Line Text$( "Computing list", LoopIndex("Solve")-1))-ReverseFind(List Line Text$( "Computing list", LoopIndex("Solve")-1), ".", 0))),List Line Text$( "Computing list", LoopIndex("Solve")-1))+Val(CompareIntegers$( "IIF", ReverseFind(List Line Text$( "Computing list", LoopIndex("Solve")+1), ".", 0), ">", -1, List Line Text$( "Computing list", LoopIndex("Solve")+1)+("0."+RepeatCharacters$( "Rep", "0", Len(List Line Text$( "Computing list", LoopIndex("Solve")+1))-ReverseFind(List Line Text$( "Computing list", LoopIndex("Solve")+1), ".", 0))),List Line Text$( "Computing list", LoopIndex("Solve")+1)))))

    I eventually reworked this. There was no way to make it small enough for MMF2 to accept as one expression, anyway.

    EDIT: LB, do you need +0.0 in thar?

  6. #6
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Oops, the I had the formula backwards. Fixed now. I also added *1.0 (you could always wrap Max blah in parenthesis and add 0.0 to it for efficiency)
    Working as fast as I can on Fusion 3

  7. #7
    Clicker Multimedia Fusion 2 DeveloperInstall Creator Pro

    Join Date
    May 2010
    Posts
    536
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, LB! As usual, you kick ass!

    I'm not sure I created these actions correctly. So, I have an event which states under these conditions:


    Surface object finishes loading image
    Image width >= Screen width (as specified by the Windows Control object)
    Image height < Screen height (as specified by the Windows Control object)

    then perform these Surface object actions:
    Set alterable value "Image Scale" to: Min((ScreenXSize( "Window Control" )*1.0/Width( "Surface" )), (ScreenYSize( "Window Control" )*1.0/Height( "Surface" )))
    Resize editable image to: Width: Width( "Surface" )*Image Scale( "Surface" ) Height: Height( "Surface" )*Image Scale( "Surface" )

    At run-time the image is not reduced in size. Did I do this correctly?


    Thank you again for your help!

  8. #8
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    I made a quick example:
    Attached files Attached files
    Working as fast as I can on Fusion 3

  9. #9
    Clicker Multimedia Fusion 2 DeveloperInstall Creator Pro

    Join Date
    May 2010
    Posts
    536
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, LB! You make it look so easy! (Probably because for you, it is!)

    Thanks again for being such a great teacher for MMF2!

Similar Threads

  1. Manually parse a json file
    By StingRay in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 25th September 2013, 02:47 PM
  2. How can I change orientation manually
    By renan63 in forum Android Export Module Version 2.0
    Replies: 2
    Last Post: 3rd May 2013, 12:43 PM
  3. Manually Trigger a transition on an object
    By Tuna in forum Android Export Module Version 2.0
    Replies: 14
    Last Post: 25th July 2012, 11:35 PM
  4. Manually Loop an Animation
    By soloman in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 26th November 2009, 09:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •