' ------------------------------------------------------------------------------------ ' SmoothZoom.vbs ' This script allows fine zooming of a picture. ' It should be assigned to the + and - keys on the numerical keypad. ' The pressed key is tested in the script, so one script is sufficient for both zoom ' in and zoom out. ' ------------------------------------------------------------------------------------ Option Explicit const VK_ADD = &h6B const VK_SUBTRACT = &h6D dim fs, zM, zD, newW, newH, oldZ, oldXo, oldYo set fs = app.GetFullScreenView ' First, check if we are really in full-screen mode if not fs Is Nothing then ' If the zoom is constrained (picture size adapted to fit the screen), switch to normal mode if (fs.nDisplayMode and &hff) = DM_FITIMAGE then fs.nDisplayMode = (fs.nDisplayMode and &hffffff00) or DM_NORMAL oldZ = fs.zoomMultiplier / fs.zoomDivisor oldXo = fs.xOrg oldYo = fs.yOrg if fs.zoomMultiplier = 1 then fs.zoomMultiplier = 100 fs.zoomDivisor = 100 * fs.zoomDivisor end if if fs.zoomDivisor = 1 then fs.zoomDivisor = 100 fs.zoomMultiplier = 100 * fs.zoomMultiplier end if if (app.lLastKeyPressed and &hff) = VK_ADD then fs.zoomMultiplier = CLng(101 * fs.zoomMultiplier / 100) else fs.zoomDivisor = CLng(101 * fs.zoomDivisor / 100) end if zD = fs.zoomDivisor zM = fs.zoomMultiplier ' Compute the size of the picture on the screen newW = CLng( zM * fs.pic.w / zD ) newH = CLng( zM * fs.pic.h / zD ) ' If picture is smaller than the screen, center it ' if larger, adapt the offset to the new zoom factor if newW < fs.w then fs.xOrg = -(fs.w - CLng( zM * fs.pic.w / zD)) / 2 else if oldXo < 0 then oldXo = 0 fs.xOrg = CLng( zM * oldXo / zD / oldZ ) end if if newH < fs.h then fs.yOrg = -(fs.h - CLng( zM * fs.pic.h / zD)) / 2 else if oldYo < 0 then oldYo = 0 fs.yOrg = CLng( zM * oldYo / zD / oldZ ) end if ' Redraw the screen fs.redraw 'app.StatusBarText = zM end if