qt - Preserving aspect ratio when using torch's image.display -


i have following simple script written in lua. running qlua.

require "image" input_image = image.load(arg[1]) image.display{image = input_image}

if image large qt window takes whole screen, stretches image fit screen.

i can't figure out way keep happening.

thanks!

if image large, resize down can configure "max height/max width", while preserving aspect ratio.

sample code:

maxsize = 480 -- find smaller dimension, , resize maxsize (while keeping aspect ratio) local iw = input:size(3) local ih = input:size(2) if iw < ih    input = image.scale(input, maxsize, maxsize * ih / iw) else    input = image.scale(input, maxsize * iw / ih, maxsize) end 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -