Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
6957475f
U
uni-app
项目概览
DCloud
/
uni-app
2 个月 前同步成功
通知
766
Star
38709
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
8
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
8
Issue
8
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
6957475f
编写于
9月 24, 2019
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 解决 uni.canvasGetImageData 和 uni.canvasPutImageData 位置大小不正确的问题
上级
ab5f0d4c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
19 addition
and
19 deletion
+19
-19
src/core/helpers/hidpi.js
src/core/helpers/hidpi.js
+2
-4
src/core/view/components/canvas/index.vue
src/core/view/components/canvas/index.vue
+17
-15
未找到文件。
src/core/helpers/hidpi.js
浏览文件 @
6957475f
...
...
@@ -158,9 +158,7 @@ if (pixelRatio !== 1) {
}
export
function
wrapper
(
canvas
)
{
canvas
.
style
.
height
=
canvas
.
height
+
'
px
'
canvas
.
style
.
width
=
canvas
.
width
+
'
px
'
canvas
.
width
*=
pixelRatio
canvas
.
height
*=
pixelRatio
canvas
.
width
=
canvas
.
offsetWidth
*
pixelRatio
canvas
.
height
=
canvas
.
offsetHeight
*
pixelRatio
canvas
.
getContext
(
'
2d
'
).
__hidpi__
=
true
}
src/core/view/components/canvas/index.vue
浏览文件 @
6957475f
...
...
@@ -106,16 +106,8 @@ export default {
method
(
data
)
}
},
_resize
({
width
,
height
})
{
var
canvas
=
this
.
$refs
.
canvas
if
(
canvas
.
style
.
width
!==
(
width
+
'
px
'
)
||
canvas
.
style
.
height
!==
(
height
+
'
px
'
))
{
canvas
.
width
=
width
canvas
.
height
=
height
wrapper
(
canvas
)
}
_resize
()
{
wrapper
(
this
.
$refs
.
canvas
)
},
_touchmove
(
event
)
{
event
.
preventDefault
()
...
...
@@ -390,13 +382,19 @@ export default {
var
imgData
var
canvas
=
this
.
$refs
.
canvas
if
(
!
width
)
{
width
=
canvas
.
w
idth
width
=
canvas
.
offsetW
idth
}
if
(
!
height
)
{
height
=
canvas
.
h
eight
height
=
canvas
.
offsetH
eight
}
try
{
imgData
=
canvas
.
getContext
(
'
2d
'
).
getImageData
(
x
,
y
,
width
,
height
)
const
newCanvas
=
document
.
createElement
(
'
canvas
'
)
newCanvas
.
width
=
width
newCanvas
.
height
=
height
const
context
=
newCanvas
.
getContext
(
'
2d
'
)
context
.
__hidpi__
=
true
context
.
drawImageByCanvas
(
canvas
,
x
,
y
,
width
,
height
,
0
,
0
,
width
,
height
,
false
)
imgData
=
context
.
getImageData
(
0
,
0
,
width
,
height
)
}
catch
(
error
)
{
UniViewJSBridge
.
publishHandler
(
'
onCanvasMethodCallback
'
,
{
callbackId
,
...
...
@@ -428,8 +426,12 @@ export default {
if
(
!
height
)
{
height
=
Math
.
round
(
data
.
length
/
4
/
width
)
}
this
.
$refs
.
canvas
.
getContext
(
'
2d
'
).
putImageData
(
new
ImageData
(
new
Uint8ClampedArray
(
data
),
width
,
height
),
x
,
y
)
const
canvas
=
document
.
createElement
(
'
canvas
'
)
canvas
.
width
=
width
canvas
.
height
=
height
const
context
=
canvas
.
getContext
(
'
2d
'
)
context
.
putImageData
(
new
ImageData
(
new
Uint8ClampedArray
(
data
),
width
,
height
),
0
,
0
)
this
.
$refs
.
canvas
.
getContext
(
'
2d
'
).
drawImage
(
canvas
,
x
,
y
,
width
,
height
)
}
catch
(
error
)
{
UniViewJSBridge
.
publishHandler
(
'
onCanvasMethodCallback
'
,
{
callbackId
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录