小编use*_*679的帖子

JavaScript类型的内存分配

我正在尝试优化我正在处理的移动应用程序的地狱,我想知道占用最小内存占用的内容(我意识到这可能因浏览器而异):

  • 对象指针
  • 布尔文字
  • 数字文字
  • 字符串文字

从理论上讲,这应该占用最少的内存空间?

javascript memory performance

6
推荐指数
1
解决办法
5055
查看次数

getBoundingClientRect,内联SVG的高度值不正确

<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)宽度是正确的,但高度是关闭的.有任何想法吗?

http://jsfiddle.net/jTvaF/5/

html javascript html5 svg getboundingclientrect

6
推荐指数
1
解决办法
4292
查看次数

质量:自定义AVFoundation相机应用VS。iOS标准相机应用

我使用各种主题和灯光进行了许多测试。每次测试都显示标准的iOS相机应用质量比我自定义的基于AVFoundation的应用明显更好(颜色不褪色,聚焦更好,照明更好,颗粒感更小)。我无法解释巨大的差异。以下是使用两种方法(使用前置摄像头)拍摄的视频的屏幕截图示例。

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)

camera avfoundation ios swift

5
推荐指数
1
解决办法
934
查看次数