@psdk/esc 0.2.52 → 0.2.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/args/image.d.ts +8 -8
- package/build/args/image.d.ts.map +1 -1
- package/build/args/image.js +33 -33
- package/package.json +4 -3
package/build/args/image.d.ts
CHANGED
|
@@ -5,24 +5,24 @@ import { ImageMode } from "../types/image";
|
|
|
5
5
|
* Image
|
|
6
6
|
*/
|
|
7
7
|
export declare class EImage extends BasicESCArg<EImage> {
|
|
8
|
-
private width;
|
|
9
|
-
private height;
|
|
10
8
|
private readonly compress;
|
|
11
9
|
private readonly mode;
|
|
12
10
|
private readonly image;
|
|
11
|
+
private readonly reverse;
|
|
12
|
+
private readonly threshold;
|
|
13
13
|
constructor(options: {
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* enable compress image data, default is true
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
compress?: boolean;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* enable reverse image data, default is false
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
reverse?: boolean;
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* threshold, default is 190
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
threshold?: number;
|
|
26
26
|
/**
|
|
27
27
|
* modeGraphic modes listed below:
|
|
28
28
|
* 0: NORMAL
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/args/image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AACpC,OAAO,EAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/args/image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AACpC,OAAO,EAAC,aAAa,EAAgB,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAGzC;;GAEG;AACH,qBAAa,MAAO,SAAQ,WAAW,CAAC,MAAM,CAAC;IAE7C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IACnC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAY;IACjC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoB;IAC1C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBACvB,OAAO,EAAE;QAEnB;;WAEG;QACH,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB;;WAEG;QACH,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB;;WAEG;QACH,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB;;;;;;WAMG;QACH,IAAI,CAAC,EAAE,SAAS,CAAC;QACjB;;WAEG;QACH,KAAK,EAAE,iBAAiB,CAAC;KAC1B;IASD,MAAM,IAAI,aAAa;IA0CvB,MAAM,IAAI,UAAU;CAIrB"}
|
package/build/args/image.js
CHANGED
|
@@ -1,33 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.EImage = void 0;
|
|
27
4
|
const basic_1 = require("./basic");
|
|
28
5
|
const frame_father_1 = require("@psdk/frame-father");
|
|
29
|
-
const pako = __importStar(require("pako"));
|
|
30
6
|
const image_1 = require("../types/image");
|
|
7
|
+
const pbita_1 = require("@psdk/frame-imageb/src/process/pbit/pbita");
|
|
31
8
|
/**
|
|
32
9
|
* Image
|
|
33
10
|
*/
|
|
@@ -35,25 +12,48 @@ class EImage extends basic_1.BasicESCArg {
|
|
|
35
12
|
constructor(options) {
|
|
36
13
|
var _a, _b, _c, _d;
|
|
37
14
|
super();
|
|
38
|
-
this.
|
|
39
|
-
this.
|
|
40
|
-
this.
|
|
15
|
+
this.compress = (_a = options.compress) !== null && _a !== void 0 ? _a : false;
|
|
16
|
+
this.reverse = (_b = options.reverse) !== null && _b !== void 0 ? _b : false;
|
|
17
|
+
this.threshold = (_c = options.threshold) !== null && _c !== void 0 ? _c : 190;
|
|
41
18
|
this.mode = (_d = options.mode) !== null && _d !== void 0 ? _d : image_1.ImageMode.NORMAL;
|
|
42
19
|
this.image = options.image;
|
|
43
20
|
}
|
|
44
21
|
clause() {
|
|
45
|
-
const
|
|
46
|
-
|
|
22
|
+
const processer = new pbita_1.Pbita({
|
|
23
|
+
threshold: this.threshold,
|
|
24
|
+
compress: this.compress,
|
|
25
|
+
reverse: this.reverse,
|
|
26
|
+
});
|
|
27
|
+
const info = processer.process(this.image);
|
|
28
|
+
const fimage = info.result.data;
|
|
29
|
+
const fbytes = info.result.bytes;
|
|
30
|
+
if (fimage == null) {
|
|
31
|
+
throw new Error('Wrong image data');
|
|
32
|
+
}
|
|
33
|
+
let width = fimage.width;
|
|
34
|
+
let height = fimage.height;
|
|
47
35
|
const eWidth = Math.floor((width % 8 === 0) ? (width / 8) : (width / 8 + 1));
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
if (this.compress) {
|
|
37
|
+
return frame_father_1.BinaryCommand.with(this.header())
|
|
38
|
+
.appendNumber(eWidth / 256)
|
|
39
|
+
.appendNumber(eWidth % 256)
|
|
40
|
+
.appendNumber(height / 256)
|
|
41
|
+
.appendNumber(height % 256)
|
|
42
|
+
.appendNumber((fbytes.length - 2) >> 24 & 0xff)
|
|
43
|
+
.appendNumber((fbytes.length - 2) >> 16 & 0xff)
|
|
44
|
+
.appendNumber((fbytes.length - 2) >> 8 & 0xff)
|
|
45
|
+
.appendNumber((fbytes.length - 2) & 0xff)
|
|
46
|
+
.appendU8A(fbytes.subarray(2, fbytes.length))
|
|
47
|
+
.clause();
|
|
48
|
+
}
|
|
49
|
+
return frame_father_1.BinaryCommand.with(this.header())
|
|
50
50
|
.appendNumber(this.mode)
|
|
51
51
|
.appendNumber(eWidth % 256)
|
|
52
52
|
.appendNumber(eWidth / 256)
|
|
53
53
|
.appendNumber(height % 256)
|
|
54
54
|
.appendNumber(height / 256)
|
|
55
|
-
.appendU8A(
|
|
56
|
-
|
|
55
|
+
.appendU8A(fbytes)
|
|
56
|
+
.clause();
|
|
57
57
|
}
|
|
58
58
|
header() {
|
|
59
59
|
return new Uint8Array([0x1D, 0x76, 0x30]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@psdk/esc",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.53",
|
|
4
4
|
"description": "psdk",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -45,11 +45,12 @@
|
|
|
45
45
|
"webpack-cli": "^4.9.2"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@psdk/frame-father": "0.2.
|
|
48
|
+
"@psdk/frame-father": "0.2.53",
|
|
49
|
+
"@psdk/frame-imageb": "0.2.53"
|
|
49
50
|
},
|
|
50
51
|
"files": [
|
|
51
52
|
"build",
|
|
52
53
|
"!build/browser/psdk*"
|
|
53
54
|
],
|
|
54
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "ca54986c203c50fbca520339a0bef18805f11a4a"
|
|
55
56
|
}
|