summaryrefstree
path: root/usr/bin/qml/USB/USBimage/imageHeightScale.js
blob: 8ae51c47782e988b22cef88cf0595546f82ac5a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function hscale(_width,_height,_defaultwidth,_defaultheight){
    if((_width > _defaultwidth)&&(_height < _defaultheight))
       {
               _height = _height*_defaultwidth/_width;
               _width = _defaultwidth;
       }
       else if((_height > _defaultheight)&&(_width < _defaultwidth))
       {
               _width = _width*_defaultheight/_height;
               _height = _defaultheight;
       }
       else if((_height > _defaultheight)&&(_width > _defaultwidth))
       {
           if(_defaultwidth/_width < _defaultheight/_height)
           { 
               _height = _height*_defaultwidth/_width;
               _width = _defaultwidth;
           }
           else
           {
               _width = _width*_defaultheight/_height;
               _height = _defaultheight;
           }
       }
    else
    {
        _height = _height;
        _width = _width;
    }
    return _height;
}