Hi,
I have a Img that will change depending on what object is selected in a grid. so i change the "src" of the img object i have added to a HLayout.
This works, but i cannot seem to get it to scale evenly.
I have tried lots of things, adding it to a canvas with with and height, adding it directly, and playing with various values for with, height and imagestyle.
I am hoping this is super easy and that you can point me in the right direction :)
To be clear, with the canvas sized below, i want the image to be scaled so that when it's larger, it scaled down so that it's longest side is 200, and the shorter side is scaled down evenly.
example: an image that's 300px X 400px should become 150 X 200.
code:
Thankful for help!
I have a Img that will change depending on what object is selected in a grid. so i change the "src" of the img object i have added to a HLayout.
This works, but i cannot seem to get it to scale evenly.
I have tried lots of things, adding it to a canvas with with and height, adding it directly, and playing with various values for with, height and imagestyle.
I am hoping this is super easy and that you can point me in the right direction :)
To be clear, with the canvas sized below, i want the image to be scaled so that when it's larger, it scaled down so that it's longest side is 200, and the shorter side is scaled down evenly.
example: an image that's 300px X 400px should become 150 X 200.
code:
Code:
Canvas canvas = new Canvas(); canvas.setHeight(200); canvas.setWidth(200); image = new Img((String)null);//will set the src later in click-events image.setWidth("100%");//have tried with fixed width, not setting height and vice versa image.setHeight("auto");//last thing i tried, didn't work either canvas.addChild(image);//have also tried adding the img directly to the layout hLayout.addMember(canvas)
Comment