Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ImageHtmlFormat = [[
- <html>
- <head>
- <style>
- .container {
- width: 100%%;
- height: 100%%;
- overflow: hidden;
- }
- .container > img {
- position: relative;
- }
- body {
- margin: 0;
- }
- </style>
- <script type="text/javascript">
- function onLoad()
- {
- var img = document.getElementById("img");
- var iw = img.width;
- var ih = img.height;
- var fw = window.innerWidth;
- var fh = window.innerHeight;
- var mode = %d; // mode 0 - FILL, mode 1 - FIT
- var scale = Math.max(fw / iw, fh / ih);
- if (mode != 0)
- {
- scale = Math.min(fw / iw, fh / ih);
- }
- var sw = scale * iw;
- var sh = scale * ih;
- img.style.width = sw + "px";
- img.style.height = sh + "px";
- img.style.left = ((fw - sw) / 2) + "px";
- img.style.top = ((fh - sh) / 2) + "px";
- }
- </script>
- </head>
- <body>
- <div class="container">
- <img id="img" src="%s" onLoad="onLoad();"/>
- </div>
- </body>
- </html>]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement