我正在尝试优化我正在处理的移动应用程序的地狱,我想知道占用最小内存占用的内容(我意识到这可能因浏览器而异):
从理论上讲,这应该占用最少的内存空间?
<body style="width:1000px;height:1000px;">
<div id="d" style="display:inline-block;">
<svg id="s" xmlns="http://www.w3.org/2000/svg" version="1.1" width="200px" height="200px">
<rect width="200px" height="200px" style="fill:rgb(0,0,255);"/>
</svg>
</div>
</body>
var div = document.getElementById('d');
var rect = div.getBoundingClientRect();
alert(rect.width); //200
alert(rect.height); //205 (in safari), 204.5 in other browsers
var svg = document.getElementById('s');
var rect = svg.getBBox();
alert(rect.width); //200
alert(rect.height); //200
Run Code Online (Sandbox Code Playgroud)
我想要获得父div的宽度和高度.无论出于何种原因,getBoudingClientRect给我一个不正确的高度值(205或204.5)宽度是正确的,但高度是关闭的.有任何想法吗?
我使用各种主题和灯光进行了许多测试。每次测试都显示标准的iOS相机应用质量比我自定义的基于AVFoundation的应用明显更好(颜色不褪色,聚焦更好,照明更好,颗粒感更小)。我无法解释巨大的差异。以下是使用两种方法(使用前置摄像头)拍摄的视频的屏幕截图示例。
自定义实现的代码:
let chosenCameraType = AVCaptureDevicePosition.Front
//get camera
let devices = AVCaptureDevice.devices()
for device in devices
{
if (!device.hasMediaType(AVMediaTypeVideo))
{
continue
}
if (device.position != chosenCameraType)
{
continue
}
camera = (device as? AVCaptureDevice)!
}
do
{
captureSession = AVCaptureSession()
captureSession!.sessionPreset = AVCaptureSessionPresetHigh
let video = try AVCaptureDeviceInput(device: camera) as AVCaptureDeviceInput
captureSession!.addInput(video)
let audio = try AVCaptureDeviceInput(device: AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeAudio)) as AVCaptureDeviceInput
captureSession!.addInput(audio)
fileOutput = AVCaptureMovieFileOutput()
captureSession?.addOutput(fileOutput)
captureSession!.startRunning()
let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as NSString
let name …
Run Code Online (Sandbox Code Playgroud) javascript ×2
avfoundation ×1
camera ×1
html ×1
html5 ×1
ios ×1
memory ×1
performance ×1
svg ×1
swift ×1