2014-10-30 32 views

回答

1

不,你不能從FabricJS直接獲取它。 爲此,您必須使用顯示器DPI進行轉換。設備的DPI一般爲96,但您也可以通過javascript獲取。對於這個下面的代碼添加到您的網頁 -

<div id='wdm_dpi_div' style='height: 1in; left: -100%; position: absolute; top: -100%; width: 1in;'></div> 

<script> 
var dpi_x = document.getElementById('wdm_dpi_div').offsetWidth; 
var dpi_y = document.getElementById('wdm_dpi_div').offsetHeight; 
// if your objects height in pixel is obj_height = 480 then 
var obj_height_in_inch = obj_height/dpi_y; 
// if your objects width in pixel is obj_width = 672 then 
var obj_width_in_inch = obj_width/dpi_x; 
</script> 

但它是更好的轉換像素由恆DPI 96

爲英寸
相關問題