Skip to content

Commit 75d2ca0

Browse files
优化VT中截取瓦片的算法。
1 parent c1b9894 commit 75d2ca0

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

examples-test/base/commonTools.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
var fs = require('fs'),
2-
PNG = require('pngjs').PNG;
1+
var fs = require('fs');
2+
var path = require('path');
33
var getPixels = require("get-pixels");
44
var assert = require('assert');
5-
var path = require('path');
65
var images = require('images');
76

87
var commonTools = ({
@@ -92,13 +91,8 @@ var commonTools = ({
9291
* function: get a tile with certain range from the screenshot
9392
* */
9493
getTileFromScreenshot: function (sourceImagePath, offsetX, offsetY, width, height, tilePath) {
95-
var dst = new PNG({width: width, height: height});
96-
fs.createReadStream(sourceImagePath)
97-
.pipe(new PNG())
98-
.on('parsed', function () {
99-
this.bitblt(dst, offsetX, offsetY, width, height, 0, 0);
100-
dst.pack().pipe(fs.createWriteStream(tilePath));
101-
});
94+
images(images(sourceImagePath), offsetX, offsetY, width, height)
95+
.save(tilePath);
10296
},
10397

10498
/*

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
"mapv": "2.0.14",
7474
"nightwatch": "^0.9.5",
7575
"openlayers": "4.2.0",
76-
"pngjs": "^3.2.0",
7776
"selenium-server": "^2.53.1",
7877
"shelljs": "^0.7.6",
7978
"style-loader": "^0.13.1",

0 commit comments

Comments
 (0)