| Point to Pixel Conversion |
|
To convert point point to pixel it is not that difficult. Here are the two formulas you can use to do the conversion. To convert pixel to point: To convert point to pixel: pixels = point * 96 / 72 Source Code: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Point to Pixel Conversion</title>
</head> <body> <form> <div> <script type="text/javascript"> function PointToPixel() { obj = document.getElementById("txtPoint"); result = document.getElementById("lblPoint"); result.value = (eval(obj.value) * 96 / 72) + "px"; }
function PixelToPoint() { obj = document.getElementById("txtPixel"); result = document.getElementById("lblPixel"); result.value = (eval(obj.value) * 72 / 96) + "pt"; } </script> <div> Pixel To Point: <input id="txtPixel" type="text" /> <input type="text" id="lblPixel" readonly="true" style="background-color:gray; color:#ffffff;" /> <input type="button" onclick="PixelToPoint()" value="Convert"/> </div> <div> Point To Pixel: <input id="txtPoint" type="text" /> <input type="text" id="lblPoint" readonly="true" style="background-color:gray; color:#ffffff;" /> <input type="button" onclick="PointToPixel()" value="Convert"/> </div> </div> </form> </body> </html>
|