Skip to content

Commit

Permalink
Fixed: Android 4.5 以下 JPEGEncoder 不起作用
Browse files Browse the repository at this point in the history
  • Loading branch information
wxt2005 committed May 31, 2015
1 parent 6199fb0 commit 2f93ba0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dist/lrz.mobile.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/lrz.pc.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@
</footer>

<script src="../lib/mobileFix.mini.js?v=ab833c8"></script>
<script src="../lib/exif.js?v=c65d9ea"></script>
<script src="../lrz.js?v=a36e904"></script>
<script src="index.js?v=1aae8b1"></script>
<script src="../lib/exif.js?v=b26c6d5"></script>
<script src="../lrz.js?v=a18ef30"></script>
<script src="index.js?v=27300bb"></script>
</body>
</html>
3 changes: 1 addition & 2 deletions src/lrz.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,12 @@
ctx.drawImage(img, 0, 0, resize.w, resize.h);
}

if (ua.os.family === 'Android' && ua.os.version < 4.5) {
if (ua.os.family === 'Android' && ua.os.version.slice(0, 3) < 4.5) {
var encoder = new JPEGEncoder();
results.base64 = encoder.encode(ctx.getImageData(0, 0, canvas.width, canvas.height), that.defaults.quality * 100);
} else {
results.base64 = canvas.toDataURL('image/jpeg', that.defaults.quality);
}
results.base64 = canvas.toDataURL('image/jpeg', that.defaults.quality);

// 执行回调
_callback(results);
Expand Down

0 comments on commit 2f93ba0

Please sign in to comment.