- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我以前使用 Chrome,但我需要使用 Firefox 测试我的插件。我正在 try catch 视频元素并将其绘制到 Canvas 上。在 Chrome 中,一切正常,但在 Firefox 中,我遇到了这个烦人的错误,我还无法修复。
IndexSizeError: Index or size is negative or greater than the allowed amount
我正在使用以下代码行将视频 $("#video")[0]
绘制到 Canvas $("#output")[0]。 getContext('2d')
:
outputCtx.drawImage(video, 0,0, video.width, video.height, 0, 0, 1815, 1358);
我会收到有关 video.width 和 video.height 值的错误。我制作了一个在 Chrome 中运行良好但在 Firefox 中出现错误的 JSFiddle:http://jsfiddle.net/ronnyrr/KD2bu/
最佳答案
尝试改用这些属性:
outputCtx.drawImage(video, 0,0, video.videoWidth, video.videoWeight,
0, 0, 1815, 1358);
源矩形必须始终在源位图中。当其中一个参数超出或为 0 或负数时,会出现错误消息。
在 Firefox 中,宽度可能无法反射(reflect)实际的视频大小。因此尝试 videoWidth/Height 属性,或者在最坏的情况下将它们结合起来:
outputCtx.drawImage(video, 0,0,
video.videoWidth||video.width,
video.videoHeight||video.height,
0, 0, 1815, 1358);
希望这对您有所帮助!
关于javascript - Firefox drawImage tot Canvas 错误 : IndexSizeError: Index or size is negative or greater than the allowed amount,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22985452/
我记得从 C 天起我们就被鼓励使用 i > -1 代替 i >= 0 因为性能。 这是否仍然适用于 C# .NET 世界?在当今的编译器中使用其中一种对性能有何影响?即编译器是否足够聪明,可以为您优化
比较小于/大于比小于/大于或等于计算性能更好吗? 凭直觉,人们可能会认为小于/大于稍微好一些。 编译器可以使用一些技巧来使比较看起来相同吗? 编译器可以消除例如小于或等于与小于通过将界限增加一来实现,
所以我想知道是否有一种方法可以实现双倍大于,如下所示: if(x > y > z) { ... } 然后我看到了这个 Expression for "more than x and less than
有些人写 std::nth_element(v.begin(), v.begin()+1, v.end(), std::greater{}); 还有一些是这样写的 std::nth_element(v
这个问题在这里已经有了答案: Speed of Comparison operators (6 个答案) 关闭 5 年前。 我有点好奇这些比较操作在幕后是如何工作的,因为我正在尝试尽可能地优化我的代
此代码有效: #include #include #include #include using namespace std; int main(){ priority_queue,g
我想显示以小时、分钟和秒为单位的时间长度,其中有些时间长度大于 24 小时。目前我正在尝试这个: $timeLength = new DateTime(); $timeLength->setTime(
在我看来,它们是一样的。但在 Visual Studio 2015 中,它们肯定是不同的。 //Ok, work properly multiset > ms1; ms1.insert(10); ms
假设我有两个符号 x,y=symbols('x y') 我的目的是告诉Sympy,x总是大于y(x> y)。有什么办法可以做到这一点? 最佳答案 无法直接执行此操作。 assumptions modu
这个问题在这里已经有了答案: Javascript string/integer comparisons (9 个回答) 关闭 6 年前。 在尝试确定一个值是否大于另一个值时,我遇到了一个奇怪的 J
我正在处理一个查询,我想在其中显示即将到来的日期的数量。即使日期大于当前日期,以下查询也会返回 0。请帮我解决这个问题。 SELECT (case when b.booked_date > cast
这是我的代码 #include #include #include #include using namespace std; /* struct greater {template
我有一个包含一百万个整数的数组,因为我正在试验并行快速排序。有时我有以下奇怪的行为: 为了检查数组是否排序正确,我在排序后输入了以下代码: for(int j=0; j array_parallel
template struct greater : binary_function { bool operator() (const T& x, const T& y) const {
我在使用基本 MySQL 查询时遇到了一个令人费解的问题。 这是我的 table : id | rating 1 | 1317.17 2 | 1280.59 3 | 995.12 4 | 97
我有如下数据集: table_a Product_Name Product_Orders game_296 1 game_298
我有几个疑问,其中大部分是: select * from Blah where col > 0 和 select * from Blah where date > current_date 由于它们都
我从列 A 的第 1 行输入了数值至IA .我想创建一个循环,将一个单元格与其之前的单元格进行比较(又名单元格 B1 到 A1 或单元格 F 到 E )。让我们使用 B1和 A1作为例子。它查看单元格
我知道 std::greater 是如何工作的。但是,当我阅读自 C++14 以来 std::greater 的 API 时,它的默认类型为 void。因此,如果我们不将任何模板参数传递给更大的它默认
有没有办法通过指定“日期大于 xxxxx”过滤器来返回 OData 中的一系列记录...但使用之前从 OData 源获取的日期? 用例:假设我想要构建一个网页来显示最近完成的在线订单的列表。这就是我的
我是一名优秀的程序员,十分优秀!