Graphics

 View Only
Expand all | Collapse all

Maintaining Aspect Ratio of Images Using Visual Logic

  • 1.  Maintaining Aspect Ratio of Images Using Visual Logic

    Posted 02-13-2018 16:56
    Hello,

    Does anyone have a good example of a visual logic code that maintains the aspect ratios of images without the blurred edges while creating a maximum height and width of what the images can be? Thanks in advance.


  • 2.  RE: Maintaining Aspect Ratio of Images Using Visual Logic

    Posted 02-14-2018 01:53
    You shouldn't need visual logic to do this.. Just set the checkbox to maintain aspect on the quad, and on the "texture coords" tab, set the Mode to "Border". Border mode will fill the outside with transparency instead of repeating the edge pixels. Depending on which version of software you have, newer versions have more options for the "maintain aspect ratio" modes.

    #XPression


  • 3.  RE: Maintaining Aspect Ratio of Images Using Visual Logic

    Posted 26 days ago

    Have you ever found a solution to do this with the material face of a slab? I would assume it would require scripting...



    ------------------------------
    Jackson Roush
    XPression Designer and Programmer
    Mercedes Benz Stadium
    Atlanta United States
    ------------------------------



  • 4.  RE: Maintaining Aspect Ratio of Images Using Visual Logic

    Ross Staff
    Posted 25 days ago

    The hard bit is reading the original sizes of the image so you can do the calculation I think.



    ------------------------------
    Simon Redmile
    Senior Graphic Programmer & Designer
    Ross Video
    Bristol United Kingdom
    ------------------------------



  • 5.  RE: Maintaining Aspect Ratio of Images Using Visual Logic

    Posted 25 days ago

    What would the scripting look like using the GetDimensions method? I would assume once you pull in the values, you would assign those to a text object to be able to make adjustments in visual logic with texture coordinates.



    ------------------------------
    Jackson Roush
    XPression Designer and Programmer
    Mercedes Benz Stadium
    Atlanta United States
    ------------------------------



  • 6.  RE: Maintaining Aspect Ratio of Images Using Visual Logic

    Ross Staff
    Posted 25 days ago

    I have never done it but that sounds like the right idea.  Out of interest I just did the first bit for you to see if it works as you would hope. 

    dim slab as xpSlabObject
    dim mat as xpMaterial
    dim textWidth, textHeight as xpTextObject
     
    dim width, height as long
     
     
    self.GetObjectByName("mySlab", slab)
    slab.GetMaterial(0, mat)
    mat.GetDimensions(width, height)
     
     
    self.GetObjectByName("matWidth", textWidth)
    self.GetObjectByName("matHeight", textHeight)
     
    textWidth.Text = width
    textHeight.Text = height

    so the next stage would be to scale these accordingly. 

    I have to finish working on something so I need to get back to that so perhaps you can take it from here.

    Otherwise I'll come back a bit later. 



    ------------------------------
    Simon Redmile
    Senior Graphic Programmer & Designer
    Ross Video
    Bristol United Kingdom
    ------------------------------



  • 7.  RE: Maintaining Aspect Ratio of Images Using Visual Logic

    Posted 23 days ago

    That code worked to pull the width and height values of the material. I then used those 2 numbers to calculate the aspect ratio and attempted to use visual logic to create a greater than/equal or less than 1 statement. Where if the aspect ratio was greater than or equal to 1, the ratio would be divided by 2 to get TextCordX and TextCordY would stay as 1. The inverse was done for less than 1, where TextCordY was ratio doubled and TextCordX was 1. However, in visual logic the ratio number that was calculated would not go through to the multiply and divide blocks and was getting stuck. Feels like I am just on the edge of figuring this out...



    ------------------------------
    Jackson Roush
    XPression Designer and Programmer
    Mercedes Benz Stadium
    Atlanta United States
    ------------------------------



  • 8.  RE: Maintaining Aspect Ratio of Images Using Visual Logic

    Ross Staff
    Posted 22 days ago

    Are you connecting it to the correct point of the multi / divide blocks?



    ------------------------------
    Simon Redmile
    Senior Graphic Programmer & Designer
    Ross Video
    Bristol United Kingdom
    ------------------------------



  • 9.  RE: Maintaining Aspect Ratio of Images Using Visual Logic

    Posted 19 days ago


    ------------------------------
    Jackson Roush
    XPression Designer and Programmer
    Mercedes Benz Stadium
    Atlanta United States
    ------------------------------



  • 10.  RE: Maintaining Aspect Ratio of Images Using Visual Logic

    Ross Staff
    Posted 19 days ago

    Those text blocks are showing as blank.



    ------------------------------
    Simon Redmile
    Senior Graphic Programmer & Designer
    Ross Video
    Bristol United Kingdom
    ------------------------------



  • 11.  RE: Maintaining Aspect Ratio of Images Using Visual Logic

    Posted 19 days ago

    Text blocks are showing up blank on layout mode but not on sequencer mode. Scripting is for events: OnOnline and OnPreviewRender. As far as scripting all the math on VB to adjust the texture coordinates, I have never really done math on there so not quite sure how I would do that. I would assume that it requires text values to be integers instead.



    ------------------------------
    Jackson Roush
    XPression Designer and Programmer
    Mercedes Benz Stadium
    Atlanta United States
    ------------------------------



  • 12.  RE: Maintaining Aspect Ratio of Images Using Visual Logic

    Posted 19 days ago

    If you are using VB to get sizes and ratio, just do the rest of the math in VB. It is much more succinct and easier to debug.

    Do all the math in one place, not two. Trust me. Do not scatter your coding.



    ------------------------------
    Azathoth
    Son of Cthulhu
    ------------------------------