ilx1-x-tool 1.1.2 → 1.2.2
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/README.md +107 -0
- package/dist/index.d.mts +174 -1
- package/dist/index.d.ts +174 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -16,6 +16,113 @@ import { xxx } from 'ilx1-x-tool'
|
|
|
16
16
|
|
|
17
17
|
## API 文档
|
|
18
18
|
|
|
19
|
+
### 图像数据处理工具 (imageData.ts)
|
|
20
|
+
|
|
21
|
+
#### 配置接口
|
|
22
|
+
- `IConfig` - 图像数据处理配置接口
|
|
23
|
+
- `reverseValue: number` - 反转数值 (0:反转数值)
|
|
24
|
+
- `modMode: number` - 取模方式 (0:逐行,1:逐列,2:列行,3:行列)
|
|
25
|
+
- `reverseBit: number` - 反转位序 (2:反转位序)
|
|
26
|
+
- `outputMode: number` - 输出模式 (0:十六进制数组,1:字节数组)
|
|
27
|
+
|
|
28
|
+
#### 图像处理主对象
|
|
29
|
+
- `ImageToHexArray` - 图像处理工具函数库主对象
|
|
30
|
+
|
|
31
|
+
#### 主要功能函数
|
|
32
|
+
- `generate(picData: string, thresholdData: number, config: number[]): Promise<Uint8Array>` - 生成十六进制数组
|
|
33
|
+
- `picData`: base64图像数据
|
|
34
|
+
- `thresholdData`: 阈值
|
|
35
|
+
- `config`: 配置数组
|
|
36
|
+
- 返回:十六进制数组
|
|
37
|
+
|
|
38
|
+
- `imageDataToHexArray(imageData: ImageData, threshold: number, config: number[]): Uint8Array` - ImageData 对象转 hexArray
|
|
39
|
+
- `imageData`: 图像数据对象
|
|
40
|
+
- `threshold`: 阈值
|
|
41
|
+
- `config`: 配置数组
|
|
42
|
+
- 返回:处理后的字节数组
|
|
43
|
+
|
|
44
|
+
- `colorImageSampling(pixels: Uint8ClampedArray, width: number, height: number, config: number[]): Uint8Array` - 彩色图像取模 (RGB565格式)
|
|
45
|
+
- `pixels`: 像素数组
|
|
46
|
+
- `width`: 图像宽度
|
|
47
|
+
- `height`: 图像高度
|
|
48
|
+
- `config`: 配置数组
|
|
49
|
+
- 返回:RGB565格式的字节数组
|
|
50
|
+
|
|
51
|
+
#### 取模函数
|
|
52
|
+
- `ImageSamplingRow(unpackedBuffer: number[], width: number, height: number, config: number[]): Uint8Array` - 逐行式取模 (从左到右,从上到下)
|
|
53
|
+
- `unpackedBuffer`: 解压后的像素缓冲区
|
|
54
|
+
- `width`: 图像宽度
|
|
55
|
+
- `height`: 图像高度
|
|
56
|
+
- `config`: 配置数组
|
|
57
|
+
- 返回:取模后的字节数组
|
|
58
|
+
|
|
59
|
+
- `ImageSamplingCol(unpackedBuffer: number[], width: number, height: number, config: number[]): Uint8Array` - 逐列式取模 (从上到下,从左到右)
|
|
60
|
+
- `unpackedBuffer`: 解压后的像素缓冲区
|
|
61
|
+
- `width`: 图像宽度
|
|
62
|
+
- `height`: 图像高度
|
|
63
|
+
- `config`: 配置数组
|
|
64
|
+
- 返回:取模后的字节数组
|
|
65
|
+
|
|
66
|
+
- `ImageSamplingColRow(unpackedBuffer: number[], width: number, height: number, config: number[]): Uint8Array` - 列行式取模 (先列后行)
|
|
67
|
+
- `unpackedBuffer`: 解压后的像素缓冲区
|
|
68
|
+
- `width`: 图像宽度
|
|
69
|
+
- `height`: 图像高度
|
|
70
|
+
- `config`: 配置数组
|
|
71
|
+
- 返回:取模后的字节数组
|
|
72
|
+
|
|
73
|
+
- `ImageSamplingRowCol(unpackedBuffer: number[], width: number, height: number, config: number[]): Uint8Array` - 行列式取模 (先行后列)
|
|
74
|
+
- `unpackedBuffer`: 解压后的像素缓冲区
|
|
75
|
+
- `width`: 图像宽度
|
|
76
|
+
- `height`: 图像高度
|
|
77
|
+
- `config`: 配置数组
|
|
78
|
+
- 返回:取模后的字节数组
|
|
79
|
+
|
|
80
|
+
#### 图像转换函数
|
|
81
|
+
- `base64ToImageData(base64Data: string): Promise<ImageData>` - base64 转 ImageData 对象
|
|
82
|
+
- `base64Data`: base64编码的图像数据
|
|
83
|
+
- 返回:ImageData对象
|
|
84
|
+
|
|
85
|
+
- `resizeImageWithKonva(width: number, height: number, image: HTMLImageElement, colorMode: boolean): Promise<string>` - 使用 Konva.js 缩放图像
|
|
86
|
+
- `width`: 目标宽度
|
|
87
|
+
- `height`: 目标高度
|
|
88
|
+
- `image`: 源图像对象
|
|
89
|
+
- `colorMode`: 是否转换为灰度
|
|
90
|
+
- 返回:base64编码的缩放后图像
|
|
91
|
+
|
|
92
|
+
- `resizeImageWithCanvas(width: number, height: number, image: HTMLImageElement, colorMode: boolean): Promise<string>` - 使用 Canvas API 缩放图像 (Konva不可用时的备选方案)
|
|
93
|
+
- `width`: 目标宽度
|
|
94
|
+
- `height`: 目标高度
|
|
95
|
+
- `image`: 源图像对象
|
|
96
|
+
- `colorMode`: 是否转换为灰度
|
|
97
|
+
- 返回:base64编码的缩放后图像
|
|
98
|
+
|
|
99
|
+
#### 数据格式转换函数
|
|
100
|
+
- `arrayToHex(array: Uint8Array): string` - Uint8Array 转十六进制字符串
|
|
101
|
+
- `array`: 字节数组
|
|
102
|
+
- 返回:十六进制字符串
|
|
103
|
+
|
|
104
|
+
- `hex2hex(hex: string): Array<string>` - 十六进制数据加 '0x' 前缀
|
|
105
|
+
- `hex`: 十六进制字符串
|
|
106
|
+
- 返回:带0x前缀的十六进制数组
|
|
107
|
+
|
|
108
|
+
- `generatePreview(unpackedBuffer: Uint8Array, width: number): string` - 生成取模预览 (0=白点, 1=黑点)
|
|
109
|
+
- `unpackedBuffer`: 解压后的像素缓冲区
|
|
110
|
+
- `width`: 图像宽度
|
|
111
|
+
- 返回:预览字符串
|
|
112
|
+
|
|
113
|
+
#### 辅助函数
|
|
114
|
+
- `createImageData(width: number, height: number, data: Uint8ClampedArray = null): ImageData` - 创建图像数据对象(兼容性函数)
|
|
115
|
+
- `width`: 图像宽度
|
|
116
|
+
- `height`: 图像高度
|
|
117
|
+
- `data`: 像素数据(可选)
|
|
118
|
+
- 返回:ImageData对象
|
|
119
|
+
|
|
120
|
+
- `formatHexOutput(hexArray: Uint8Array | Array<string>, format = 0, lineBreak = 16): string` - 将字节数组格式化为可读字符串
|
|
121
|
+
- `hexArray`: 十六进制数组
|
|
122
|
+
- `format`: 输出格式 (0=带0x前缀, 1=原始数组)
|
|
123
|
+
- `lineBreak`: 每行显示的字节数
|
|
124
|
+
- 返回:格式化后的字符串
|
|
125
|
+
|
|
19
126
|
### 颜色工具 (color.ts)
|
|
20
127
|
|
|
21
128
|
#### 颜色解析与转换
|
package/dist/index.d.mts
CHANGED
|
@@ -324,4 +324,177 @@ declare const enableAllLogs: () => void;
|
|
|
324
324
|
********************************************************************************/
|
|
325
325
|
declare const disableAllLogs: () => void;
|
|
326
326
|
|
|
327
|
-
|
|
327
|
+
/********************************************************************************
|
|
328
|
+
* @brief: 图像处理工具函数库主对象
|
|
329
|
+
* @param: 无
|
|
330
|
+
* @return: ImageToHexArray 对象
|
|
331
|
+
********************************************************************************/
|
|
332
|
+
declare const ImageToHexArray: {
|
|
333
|
+
/********************************************************************************
|
|
334
|
+
* @brief: 生成十六进制数组
|
|
335
|
+
* @param {string} picData - base64图像数据
|
|
336
|
+
* @param {number} thresholdData - 阈值
|
|
337
|
+
* @param {Array} config - 配置数组
|
|
338
|
+
* @return {Promise<Array|Uint8Array>} 十六进制数组
|
|
339
|
+
********************************************************************************/
|
|
340
|
+
generate: (picData: string, thresholdData: number, config: number[]) => Promise<Uint8Array>;
|
|
341
|
+
/********************************************************************************
|
|
342
|
+
* @brief: ImageData 对象转 hexArray
|
|
343
|
+
* @param {ImageData} imageData - 图像数据对象
|
|
344
|
+
* @param {number} threshold - 阈值
|
|
345
|
+
* @param {Array} config - 配置数组
|
|
346
|
+
* @return {Uint8Array} 处理后的字节数组
|
|
347
|
+
********************************************************************************/
|
|
348
|
+
imageDataToHexArray: (imageData: ImageData, threshold: number, config: number[]) => Uint8Array;
|
|
349
|
+
/********************************************************************************
|
|
350
|
+
* @brief: 彩色图像取模 (RGB565格式)
|
|
351
|
+
* @param {Uint8ClampedArray} pixels - 像素数组
|
|
352
|
+
* @param {number} width - 图像宽度
|
|
353
|
+
* @param {number} height - 图像高度
|
|
354
|
+
* @param {Array} config - 配置数组
|
|
355
|
+
* @return {Uint8Array} RGB565格式的字节数组
|
|
356
|
+
********************************************************************************/
|
|
357
|
+
colorImageSampling: (pixels: Uint8ClampedArray, width: number, height: number, config: number[]) => Uint8Array;
|
|
358
|
+
/********************************************************************************
|
|
359
|
+
* @brief: 逐行式取模 (从左到右,从上到下)
|
|
360
|
+
* @param {Array} unpackedBuffer - 解压后的像素缓冲区
|
|
361
|
+
* @param {number} width - 图像宽度
|
|
362
|
+
* @param {number} height - 图像高度
|
|
363
|
+
* @param {Array} config - 配置数组
|
|
364
|
+
* @return {Uint8Array} 取模后的字节数组
|
|
365
|
+
********************************************************************************/
|
|
366
|
+
ImageSamplingRow: (unpackedBuffer: number[], width: number, height: number, config: number[]) => Uint8Array;
|
|
367
|
+
/********************************************************************************
|
|
368
|
+
* @brief: 逐列式取模 (从上到下,从左到右)
|
|
369
|
+
* @param {Array} unpackedBuffer - 解压后的像素缓冲区
|
|
370
|
+
* @param {number} width - 图像宽度
|
|
371
|
+
* @param {number} height - 图像高度
|
|
372
|
+
* @param {Array} config - 配置数组
|
|
373
|
+
* @return {Uint8Array} 取模后的字节数组
|
|
374
|
+
********************************************************************************/
|
|
375
|
+
ImageSamplingCol: (unpackedBuffer: number[], width: number, height: number, config: number[]) => Uint8Array;
|
|
376
|
+
/********************************************************************************
|
|
377
|
+
* @brief: 列行式取模 (先列后行)
|
|
378
|
+
* @param {Array} unpackedBuffer - 解压后的像素缓冲区
|
|
379
|
+
* @param {number} width - 图像宽度
|
|
380
|
+
* @param {number} height - 图像高度
|
|
381
|
+
* @param {Array} config - 配置数组
|
|
382
|
+
* @return {Uint8Array} 取模后的字节数组
|
|
383
|
+
********************************************************************************/
|
|
384
|
+
ImageSamplingColRow: (unpackedBuffer: number[], width: number, height: number, config: number[]) => Uint8Array;
|
|
385
|
+
/********************************************************************************
|
|
386
|
+
* @brief: 行列式取模 (先行后列)
|
|
387
|
+
* @param {Array} unpackedBuffer - 解压后的像素缓冲区
|
|
388
|
+
* @param {number} width - 图像宽度
|
|
389
|
+
* @param {number} height - 图像高度
|
|
390
|
+
* @param {Array} config - 配置数组
|
|
391
|
+
* @return {Uint8Array} 取模后的字节数组
|
|
392
|
+
********************************************************************************/
|
|
393
|
+
ImageSamplingRowCol: (unpackedBuffer: number[], width: number, height: number, config: number[]) => Uint8Array;
|
|
394
|
+
/********************************************************************************
|
|
395
|
+
* @brief: base64 转 ImageData 对象
|
|
396
|
+
* @param {string} base64Data - base64编码的图像数据
|
|
397
|
+
* @return {Promise<ImageData>} ImageData对象
|
|
398
|
+
********************************************************************************/
|
|
399
|
+
base64ToImageData: (base64Data: string) => Promise<ImageData>;
|
|
400
|
+
/********************************************************************************
|
|
401
|
+
* @brief: 使用 Konva.js 缩放图像
|
|
402
|
+
* @param {number} width - 目标宽度
|
|
403
|
+
* @param {number} height - 目标高度
|
|
404
|
+
* @param {HTMLImageElement} image - 源图像对象
|
|
405
|
+
* @param {boolean} colorMode - 是否转换为灰度
|
|
406
|
+
* @return {Promise<string>} base64编码的缩放后图像
|
|
407
|
+
********************************************************************************/
|
|
408
|
+
resizeImageWithKonva: (width: number, height: number, image: HTMLImageElement, colorMode: boolean) => Promise<string>;
|
|
409
|
+
/********************************************************************************
|
|
410
|
+
* @brief: 使用 Canvas API 缩放图像 (Konva不可用时的备选方案)
|
|
411
|
+
* @param {number} width - 目标宽度
|
|
412
|
+
* @param {number} height - 目标高度
|
|
413
|
+
* @param {HTMLImageElement} image - 源图像对象
|
|
414
|
+
* @param {boolean} colorMode - 是否转换为灰度
|
|
415
|
+
* @return {Promise<string>} base64编码的缩放后图像
|
|
416
|
+
********************************************************************************/
|
|
417
|
+
resizeImageWithCanvas: (width: any, height: any, image: any, colorMode: any) => Promise<unknown>;
|
|
418
|
+
/********************************************************************************
|
|
419
|
+
* @brief: Uint8Array 转十六进制字符串
|
|
420
|
+
* @param {Uint8Array} array - 字节数组
|
|
421
|
+
* @return {string} 十六进制字符串
|
|
422
|
+
********************************************************************************/
|
|
423
|
+
arrayToHex: (array: any) => string;
|
|
424
|
+
/********************************************************************************
|
|
425
|
+
* @brief: 十六进制数据加 '0x' 前缀
|
|
426
|
+
* @param {string} hex - 十六进制字符串
|
|
427
|
+
* @return {Array<string>} 带0x前缀的十六进制数组
|
|
428
|
+
********************************************************************************/
|
|
429
|
+
hex2hex: (hex: string) => Array<string>;
|
|
430
|
+
/********************************************************************************
|
|
431
|
+
* @brief: 生成取模预览 (0=白点, 1=黑点)
|
|
432
|
+
* @param {Uint8Array} unpackedBuffer - 解压后的像素缓冲区
|
|
433
|
+
* @param {number} width - 图像宽度
|
|
434
|
+
* @return {string} 预览字符串
|
|
435
|
+
********************************************************************************/
|
|
436
|
+
generatePreview: (unpackedBuffer: Uint8Array, width: number) => string;
|
|
437
|
+
/********************************************************************************
|
|
438
|
+
* @brief: 创建图像数据对象(兼容性函数)
|
|
439
|
+
* @param {number} width - 图像宽度
|
|
440
|
+
* @param {number} height - 图像高度
|
|
441
|
+
* @param {Uint8ClampedArray} data - 像素数据
|
|
442
|
+
* @return {ImageData} ImageData对象
|
|
443
|
+
********************************************************************************/
|
|
444
|
+
createImageData: (width: number, height: number, data?: Uint8ClampedArray) => ImageData;
|
|
445
|
+
/********************************************************************************
|
|
446
|
+
* @brief: 将字节数组格式化为可读字符串
|
|
447
|
+
* @param {Uint8Array|Array} hexArray - 十六进制数组
|
|
448
|
+
* @param {number} format - 输出格式 (0=带0x前缀, 1=原始数组)
|
|
449
|
+
* @param {number} lineBreak - 每行显示的字节数
|
|
450
|
+
* @return {string} 格式化后的字符串
|
|
451
|
+
********************************************************************************/
|
|
452
|
+
formatHexOutput: (hexArray: Uint8Array | Array<string>, format?: number, lineBreak?: number) => string;
|
|
453
|
+
/********************************************************************************
|
|
454
|
+
* @brief: 计算输出字节数
|
|
455
|
+
* @param {Uint8Array|Array} hexArray - 十六进制数组
|
|
456
|
+
* @return {Object} 包含字节数和KB数的对象
|
|
457
|
+
********************************************************************************/
|
|
458
|
+
calculateOutputSize: (hexArray: Uint8Array | Array<string>) => {
|
|
459
|
+
bytes: number;
|
|
460
|
+
kilobytes: number;
|
|
461
|
+
formatted: string;
|
|
462
|
+
};
|
|
463
|
+
/********************************************************************************
|
|
464
|
+
* @brief: 获取取模方式描述
|
|
465
|
+
* @param {number} mode - 取模方式代码
|
|
466
|
+
* @return {string} 取模方式描述
|
|
467
|
+
********************************************************************************/
|
|
468
|
+
getSamplingModeDescription: (mode: number) => string;
|
|
469
|
+
/********************************************************************************
|
|
470
|
+
* @brief: 获取配置数组的默认值
|
|
471
|
+
* @param: 无
|
|
472
|
+
* @return {Array} 默认配置数组
|
|
473
|
+
********************************************************************************/
|
|
474
|
+
getDefaultConfig: () => number[];
|
|
475
|
+
};
|
|
476
|
+
/********************************************************************************
|
|
477
|
+
* @brief: 为了方便使用,单独导出每个函数
|
|
478
|
+
* @param: 无
|
|
479
|
+
* @return: 函数引用
|
|
480
|
+
********************************************************************************/
|
|
481
|
+
declare const generate: any;
|
|
482
|
+
declare const imageDataToHexArray: any;
|
|
483
|
+
declare const colorImageSampling: any;
|
|
484
|
+
declare const ImageSamplingRow: any;
|
|
485
|
+
declare const ImageSamplingCol: any;
|
|
486
|
+
declare const ImageSamplingColRow: any;
|
|
487
|
+
declare const ImageSamplingRowCol: any;
|
|
488
|
+
declare const base64ToImageData: any;
|
|
489
|
+
declare const resizeImageWithKonva: any;
|
|
490
|
+
declare const resizeImageWithCanvas: any;
|
|
491
|
+
declare const arrayToHex: any;
|
|
492
|
+
declare const hex2hex: any;
|
|
493
|
+
declare const generatePreview: any;
|
|
494
|
+
declare const createImageData: any;
|
|
495
|
+
declare const formatHexOutput: any;
|
|
496
|
+
declare const calculateOutputSize: any;
|
|
497
|
+
declare const getSamplingModeDescription: any;
|
|
498
|
+
declare const getDefaultConfig: any;
|
|
499
|
+
|
|
500
|
+
export { type ConsoleType, Endianness, type Hex, ImageSamplingCol, ImageSamplingColRow, ImageSamplingRow, ImageSamplingRowCol, ImageToHexArray, type LoggerConfig, type ParsedColor, type ParsedHSL, type ParsedHSLA, type ParsedHSV, type ParsedRGB, type ParsedRGBA, type Result, arrayToHex, asciiArrToNum, base64ToImageData, bits16ToNum, bytesToNum, calculateOutputSize, colorImageSampling, compressJsonGzip, createImageData, debug, decompressJsonGzip, disableAllLogs, enableAllLogs, error, errorResult, formatHexOutput, generate, generatePreview, getDefaultConfig, getHIDCodeMapStr, getHIDCodeMapStrNum, getSamplingModeDescription, hex2hex, hidKeyCode, hslToHsv, hslToRgb, hsvToHsl, imageDataToHexArray, info, isImageValid, isShowPopover, log, numToAsciiArr, numToBits16, numToBytes, parseColorString, resetLoggerConfig, resizeImageWithCanvas, resizeImageWithKonva, rgbToHsl, setLoggerConfig, successResult, warn };
|
package/dist/index.d.ts
CHANGED
|
@@ -324,4 +324,177 @@ declare const enableAllLogs: () => void;
|
|
|
324
324
|
********************************************************************************/
|
|
325
325
|
declare const disableAllLogs: () => void;
|
|
326
326
|
|
|
327
|
-
|
|
327
|
+
/********************************************************************************
|
|
328
|
+
* @brief: 图像处理工具函数库主对象
|
|
329
|
+
* @param: 无
|
|
330
|
+
* @return: ImageToHexArray 对象
|
|
331
|
+
********************************************************************************/
|
|
332
|
+
declare const ImageToHexArray: {
|
|
333
|
+
/********************************************************************************
|
|
334
|
+
* @brief: 生成十六进制数组
|
|
335
|
+
* @param {string} picData - base64图像数据
|
|
336
|
+
* @param {number} thresholdData - 阈值
|
|
337
|
+
* @param {Array} config - 配置数组
|
|
338
|
+
* @return {Promise<Array|Uint8Array>} 十六进制数组
|
|
339
|
+
********************************************************************************/
|
|
340
|
+
generate: (picData: string, thresholdData: number, config: number[]) => Promise<Uint8Array>;
|
|
341
|
+
/********************************************************************************
|
|
342
|
+
* @brief: ImageData 对象转 hexArray
|
|
343
|
+
* @param {ImageData} imageData - 图像数据对象
|
|
344
|
+
* @param {number} threshold - 阈值
|
|
345
|
+
* @param {Array} config - 配置数组
|
|
346
|
+
* @return {Uint8Array} 处理后的字节数组
|
|
347
|
+
********************************************************************************/
|
|
348
|
+
imageDataToHexArray: (imageData: ImageData, threshold: number, config: number[]) => Uint8Array;
|
|
349
|
+
/********************************************************************************
|
|
350
|
+
* @brief: 彩色图像取模 (RGB565格式)
|
|
351
|
+
* @param {Uint8ClampedArray} pixels - 像素数组
|
|
352
|
+
* @param {number} width - 图像宽度
|
|
353
|
+
* @param {number} height - 图像高度
|
|
354
|
+
* @param {Array} config - 配置数组
|
|
355
|
+
* @return {Uint8Array} RGB565格式的字节数组
|
|
356
|
+
********************************************************************************/
|
|
357
|
+
colorImageSampling: (pixels: Uint8ClampedArray, width: number, height: number, config: number[]) => Uint8Array;
|
|
358
|
+
/********************************************************************************
|
|
359
|
+
* @brief: 逐行式取模 (从左到右,从上到下)
|
|
360
|
+
* @param {Array} unpackedBuffer - 解压后的像素缓冲区
|
|
361
|
+
* @param {number} width - 图像宽度
|
|
362
|
+
* @param {number} height - 图像高度
|
|
363
|
+
* @param {Array} config - 配置数组
|
|
364
|
+
* @return {Uint8Array} 取模后的字节数组
|
|
365
|
+
********************************************************************************/
|
|
366
|
+
ImageSamplingRow: (unpackedBuffer: number[], width: number, height: number, config: number[]) => Uint8Array;
|
|
367
|
+
/********************************************************************************
|
|
368
|
+
* @brief: 逐列式取模 (从上到下,从左到右)
|
|
369
|
+
* @param {Array} unpackedBuffer - 解压后的像素缓冲区
|
|
370
|
+
* @param {number} width - 图像宽度
|
|
371
|
+
* @param {number} height - 图像高度
|
|
372
|
+
* @param {Array} config - 配置数组
|
|
373
|
+
* @return {Uint8Array} 取模后的字节数组
|
|
374
|
+
********************************************************************************/
|
|
375
|
+
ImageSamplingCol: (unpackedBuffer: number[], width: number, height: number, config: number[]) => Uint8Array;
|
|
376
|
+
/********************************************************************************
|
|
377
|
+
* @brief: 列行式取模 (先列后行)
|
|
378
|
+
* @param {Array} unpackedBuffer - 解压后的像素缓冲区
|
|
379
|
+
* @param {number} width - 图像宽度
|
|
380
|
+
* @param {number} height - 图像高度
|
|
381
|
+
* @param {Array} config - 配置数组
|
|
382
|
+
* @return {Uint8Array} 取模后的字节数组
|
|
383
|
+
********************************************************************************/
|
|
384
|
+
ImageSamplingColRow: (unpackedBuffer: number[], width: number, height: number, config: number[]) => Uint8Array;
|
|
385
|
+
/********************************************************************************
|
|
386
|
+
* @brief: 行列式取模 (先行后列)
|
|
387
|
+
* @param {Array} unpackedBuffer - 解压后的像素缓冲区
|
|
388
|
+
* @param {number} width - 图像宽度
|
|
389
|
+
* @param {number} height - 图像高度
|
|
390
|
+
* @param {Array} config - 配置数组
|
|
391
|
+
* @return {Uint8Array} 取模后的字节数组
|
|
392
|
+
********************************************************************************/
|
|
393
|
+
ImageSamplingRowCol: (unpackedBuffer: number[], width: number, height: number, config: number[]) => Uint8Array;
|
|
394
|
+
/********************************************************************************
|
|
395
|
+
* @brief: base64 转 ImageData 对象
|
|
396
|
+
* @param {string} base64Data - base64编码的图像数据
|
|
397
|
+
* @return {Promise<ImageData>} ImageData对象
|
|
398
|
+
********************************************************************************/
|
|
399
|
+
base64ToImageData: (base64Data: string) => Promise<ImageData>;
|
|
400
|
+
/********************************************************************************
|
|
401
|
+
* @brief: 使用 Konva.js 缩放图像
|
|
402
|
+
* @param {number} width - 目标宽度
|
|
403
|
+
* @param {number} height - 目标高度
|
|
404
|
+
* @param {HTMLImageElement} image - 源图像对象
|
|
405
|
+
* @param {boolean} colorMode - 是否转换为灰度
|
|
406
|
+
* @return {Promise<string>} base64编码的缩放后图像
|
|
407
|
+
********************************************************************************/
|
|
408
|
+
resizeImageWithKonva: (width: number, height: number, image: HTMLImageElement, colorMode: boolean) => Promise<string>;
|
|
409
|
+
/********************************************************************************
|
|
410
|
+
* @brief: 使用 Canvas API 缩放图像 (Konva不可用时的备选方案)
|
|
411
|
+
* @param {number} width - 目标宽度
|
|
412
|
+
* @param {number} height - 目标高度
|
|
413
|
+
* @param {HTMLImageElement} image - 源图像对象
|
|
414
|
+
* @param {boolean} colorMode - 是否转换为灰度
|
|
415
|
+
* @return {Promise<string>} base64编码的缩放后图像
|
|
416
|
+
********************************************************************************/
|
|
417
|
+
resizeImageWithCanvas: (width: any, height: any, image: any, colorMode: any) => Promise<unknown>;
|
|
418
|
+
/********************************************************************************
|
|
419
|
+
* @brief: Uint8Array 转十六进制字符串
|
|
420
|
+
* @param {Uint8Array} array - 字节数组
|
|
421
|
+
* @return {string} 十六进制字符串
|
|
422
|
+
********************************************************************************/
|
|
423
|
+
arrayToHex: (array: any) => string;
|
|
424
|
+
/********************************************************************************
|
|
425
|
+
* @brief: 十六进制数据加 '0x' 前缀
|
|
426
|
+
* @param {string} hex - 十六进制字符串
|
|
427
|
+
* @return {Array<string>} 带0x前缀的十六进制数组
|
|
428
|
+
********************************************************************************/
|
|
429
|
+
hex2hex: (hex: string) => Array<string>;
|
|
430
|
+
/********************************************************************************
|
|
431
|
+
* @brief: 生成取模预览 (0=白点, 1=黑点)
|
|
432
|
+
* @param {Uint8Array} unpackedBuffer - 解压后的像素缓冲区
|
|
433
|
+
* @param {number} width - 图像宽度
|
|
434
|
+
* @return {string} 预览字符串
|
|
435
|
+
********************************************************************************/
|
|
436
|
+
generatePreview: (unpackedBuffer: Uint8Array, width: number) => string;
|
|
437
|
+
/********************************************************************************
|
|
438
|
+
* @brief: 创建图像数据对象(兼容性函数)
|
|
439
|
+
* @param {number} width - 图像宽度
|
|
440
|
+
* @param {number} height - 图像高度
|
|
441
|
+
* @param {Uint8ClampedArray} data - 像素数据
|
|
442
|
+
* @return {ImageData} ImageData对象
|
|
443
|
+
********************************************************************************/
|
|
444
|
+
createImageData: (width: number, height: number, data?: Uint8ClampedArray) => ImageData;
|
|
445
|
+
/********************************************************************************
|
|
446
|
+
* @brief: 将字节数组格式化为可读字符串
|
|
447
|
+
* @param {Uint8Array|Array} hexArray - 十六进制数组
|
|
448
|
+
* @param {number} format - 输出格式 (0=带0x前缀, 1=原始数组)
|
|
449
|
+
* @param {number} lineBreak - 每行显示的字节数
|
|
450
|
+
* @return {string} 格式化后的字符串
|
|
451
|
+
********************************************************************************/
|
|
452
|
+
formatHexOutput: (hexArray: Uint8Array | Array<string>, format?: number, lineBreak?: number) => string;
|
|
453
|
+
/********************************************************************************
|
|
454
|
+
* @brief: 计算输出字节数
|
|
455
|
+
* @param {Uint8Array|Array} hexArray - 十六进制数组
|
|
456
|
+
* @return {Object} 包含字节数和KB数的对象
|
|
457
|
+
********************************************************************************/
|
|
458
|
+
calculateOutputSize: (hexArray: Uint8Array | Array<string>) => {
|
|
459
|
+
bytes: number;
|
|
460
|
+
kilobytes: number;
|
|
461
|
+
formatted: string;
|
|
462
|
+
};
|
|
463
|
+
/********************************************************************************
|
|
464
|
+
* @brief: 获取取模方式描述
|
|
465
|
+
* @param {number} mode - 取模方式代码
|
|
466
|
+
* @return {string} 取模方式描述
|
|
467
|
+
********************************************************************************/
|
|
468
|
+
getSamplingModeDescription: (mode: number) => string;
|
|
469
|
+
/********************************************************************************
|
|
470
|
+
* @brief: 获取配置数组的默认值
|
|
471
|
+
* @param: 无
|
|
472
|
+
* @return {Array} 默认配置数组
|
|
473
|
+
********************************************************************************/
|
|
474
|
+
getDefaultConfig: () => number[];
|
|
475
|
+
};
|
|
476
|
+
/********************************************************************************
|
|
477
|
+
* @brief: 为了方便使用,单独导出每个函数
|
|
478
|
+
* @param: 无
|
|
479
|
+
* @return: 函数引用
|
|
480
|
+
********************************************************************************/
|
|
481
|
+
declare const generate: any;
|
|
482
|
+
declare const imageDataToHexArray: any;
|
|
483
|
+
declare const colorImageSampling: any;
|
|
484
|
+
declare const ImageSamplingRow: any;
|
|
485
|
+
declare const ImageSamplingCol: any;
|
|
486
|
+
declare const ImageSamplingColRow: any;
|
|
487
|
+
declare const ImageSamplingRowCol: any;
|
|
488
|
+
declare const base64ToImageData: any;
|
|
489
|
+
declare const resizeImageWithKonva: any;
|
|
490
|
+
declare const resizeImageWithCanvas: any;
|
|
491
|
+
declare const arrayToHex: any;
|
|
492
|
+
declare const hex2hex: any;
|
|
493
|
+
declare const generatePreview: any;
|
|
494
|
+
declare const createImageData: any;
|
|
495
|
+
declare const formatHexOutput: any;
|
|
496
|
+
declare const calculateOutputSize: any;
|
|
497
|
+
declare const getSamplingModeDescription: any;
|
|
498
|
+
declare const getDefaultConfig: any;
|
|
499
|
+
|
|
500
|
+
export { type ConsoleType, Endianness, type Hex, ImageSamplingCol, ImageSamplingColRow, ImageSamplingRow, ImageSamplingRowCol, ImageToHexArray, type LoggerConfig, type ParsedColor, type ParsedHSL, type ParsedHSLA, type ParsedHSV, type ParsedRGB, type ParsedRGBA, type Result, arrayToHex, asciiArrToNum, base64ToImageData, bits16ToNum, bytesToNum, calculateOutputSize, colorImageSampling, compressJsonGzip, createImageData, debug, decompressJsonGzip, disableAllLogs, enableAllLogs, error, errorResult, formatHexOutput, generate, generatePreview, getDefaultConfig, getHIDCodeMapStr, getHIDCodeMapStrNum, getSamplingModeDescription, hex2hex, hidKeyCode, hslToHsv, hslToRgb, hsvToHsl, imageDataToHexArray, info, isImageValid, isShowPopover, log, numToAsciiArr, numToBits16, numToBytes, parseColorString, resetLoggerConfig, resizeImageWithCanvas, resizeImageWithKonva, rgbToHsl, setLoggerConfig, successResult, warn };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
var b=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var F=(e,r)=>{for(var n in r)b(e,n,{get:r[n],enumerable:!0})},P=(e,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of C(r))!A.call(e,s)&&s!==n&&b(e,s,{get:()=>r[s],enumerable:!(o=T(r,s))||o.enumerable});return e};var R=e=>P(b({},"__esModule",{value:!0}),e);var ie={};F(ie,{Endianness:()=>w,asciiArrToNum:()=>J,bits16ToNum:()=>z,bytesToNum:()=>U,compressJsonGzip:()=>D,debug:()=>se,decompressJsonGzip:()=>N,disableAllLogs:()=>te,enableAllLogs:()=>ae,error:()=>oe,errorResult:()=>O,getHIDCodeMapStr:()=>B,getHIDCodeMapStrNum:()=>I,hidKeyCode:()=>E,hslToHsv:()=>Z,hslToRgb:()=>Q,hsvToHsl:()=>Y,info:()=>re,isImageValid:()=>_,isShowPopover:()=>G,log:()=>ee,numToAsciiArr:()=>W,numToBits16:()=>V,numToBytes:()=>$,parseColorString:()=>j,resetLoggerConfig:()=>de,rgbToHsl:()=>X,setLoggerConfig:()=>S,successResult:()=>H,warn:()=>ne});module.exports=R(ie);var E=[{key:0,word:"a",dec:"4",hex:"04",kind:1,value:4,aliases:["A"]},{key:2,word:"b",dec:"5",hex:"05",kind:1,value:5,aliases:["B"]},{key:4,word:"c",dec:"6",hex:"06",kind:1,value:6,aliases:["C"]},{key:6,word:"d",dec:"7",hex:"07",kind:1,value:7,aliases:["D"]},{key:8,word:"e",dec:"8",hex:"08",kind:1,value:8,aliases:["E"]},{key:10,word:"f",dec:"9",hex:"09",kind:1,value:9,aliases:["F"]},{key:12,word:"g",dec:"10",hex:"0A",kind:1,value:10,aliases:["G"]},{key:14,word:"h",dec:"11",hex:"0B",kind:1,value:11,aliases:["H"]},{key:16,word:"i",dec:"12",hex:"0C",kind:1,value:12,aliases:["I"]},{key:18,word:"j",dec:"13",hex:"0D",kind:1,value:13,aliases:["J"]},{key:20,word:"k",dec:"14",hex:"0E",kind:1,value:14,aliases:["K"]},{key:22,word:"l",dec:"15",hex:"0F",kind:1,value:15,aliases:["L"]},{key:24,word:"m",dec:"16",hex:"10",kind:1,value:16,aliases:["M"]},{key:26,word:"n",dec:"17",hex:"11",kind:1,value:17,aliases:["N"]},{key:28,word:"o",dec:"18",hex:"12",kind:1,value:18,aliases:["O"]},{key:30,word:"p",dec:"19",hex:"13",kind:1,value:19,aliases:["P"]},{key:32,word:"q",dec:"20",hex:"14",kind:1,value:20,aliases:["Q"]},{key:34,word:"r",dec:"21",hex:"15",kind:1,value:21,aliases:["R"]},{key:36,word:"s",dec:"22",hex:"16",kind:1,value:22,aliases:["S"]},{key:38,word:"t",dec:"23",hex:"17",kind:1,value:23,aliases:["T"]},{key:40,word:"u",dec:"24",hex:"18",kind:1,value:24,aliases:["U"]},{key:42,word:"v",dec:"25",hex:"19",kind:1,value:25,aliases:["V"]},{key:44,word:"w",dec:"26",hex:"1A",kind:1,value:26,aliases:["W"]},{key:46,word:"x",dec:"27",hex:"1B",kind:1,value:27,aliases:["X"]},{key:48,word:"y",dec:"28",hex:"1C",kind:1,value:28,aliases:["Y"]},{key:50,word:"z",dec:"29",hex:"1D",kind:1,value:29,aliases:["Z"]},{key:52,word:"1",dec:"30",hex:"1E",kind:1,value:30,aliases:["!","1!"]},{key:54,word:"2",dec:"31",hex:"1F",kind:1,value:31,aliases:["@","2@"]},{key:56,word:"3",dec:"32",hex:"20",kind:1,value:32,aliases:["#","3#"]},{key:58,word:"4",dec:"33",hex:"21",kind:1,value:33,aliases:["$","4$"]},{key:60,word:"5",dec:"34",hex:"22",kind:1,value:34,aliases:["%","5%"]},{key:62,word:"6",dec:"35",hex:"23",kind:1,value:35,aliases:["^","6^"]},{key:64,word:"7",dec:"36",hex:"24",kind:1,value:36,aliases:["&","7&"]},{key:66,word:"8",dec:"37",hex:"25",kind:1,value:37,aliases:["*","8*"]},{key:68,word:"9",dec:"38",hex:"26",kind:1,value:38,aliases:["(","9("]},{key:70,word:"0",dec:"39",hex:"27",kind:1,value:39,aliases:[")","0)"]},{key:77,word:"-",dec:"45",hex:"2D",kind:1,value:45,aliases:["_","-_"]},{key:79,word:"=",dec:"46",hex:"2E",kind:1,value:46,aliases:["+","=+"]},{key:81,word:"[",dec:"47",hex:"2F",kind:1,value:47,aliases:["{","[{"]},{key:83,word:"]",dec:"48",hex:"30",kind:1,value:48,aliases:["}","}]"]},{key:85,word:"\\",dec:"49",hex:"31",kind:1,value:49,aliases:["|","\\|"]},{key:87,word:"`",dec:"50",hex:"32",kind:1,value:50,aliases:["~","`~"]},{key:89,word:";",dec:"51",hex:"33",kind:1,value:51,aliases:[":",";:"]},{key:91,word:"'",dec:"52",hex:"34",kind:1,value:52,aliases:['"',`'"`]},{key:95,word:",",dec:"54",hex:"36",kind:1,value:54,aliases:["<",",<"]},{key:97,word:".",dec:"55",hex:"37",kind:1,value:55,aliases:[">",".>"]},{key:99,word:"/",dec:"56",hex:"38",kind:1,value:56,aliases:["?","/?"]},{key:72,word:"Enter",dec:"40",hex:"28",kind:1,value:40},{key:73,word:"Escape",dec:"41",hex:"29",kind:1,value:41},{key:74,word:"Backspace",dec:"42",hex:"2A",kind:1,value:42},{key:75,word:"Tab",dec:"43",hex:"2B",kind:1,value:43},{key:76,word:" ",dec:"44",hex:"2C",kind:1,value:44},{key:101,word:"CapsLock",dec:"57",hex:"39",kind:1,value:57},{key:102,word:"F1",dec:"58",hex:"3A",kind:1,value:58},{key:103,word:"F2",dec:"59",hex:"3B",kind:1,value:59},{key:104,word:"F3",dec:"60",hex:"3C",kind:1,value:60},{key:105,word:"F4",dec:"61",hex:"3D",kind:1,value:61},{key:106,word:"F5",dec:"62",hex:"3E",kind:1,value:62},{key:107,word:"F6",dec:"63",hex:"3F",kind:1,value:63},{key:108,word:"F7",dec:"64",hex:"40",kind:1,value:64},{key:109,word:"F8",dec:"65",hex:"41",kind:1,value:65},{key:110,word:"F9",dec:"66",hex:"42",kind:1,value:66},{key:111,word:"F10",dec:"67",hex:"43",kind:1,value:67},{key:112,word:"F11",dec:"68",hex:"44",kind:1,value:68},{key:113,word:"F12",dec:"69",hex:"45",kind:1,value:69},{key:114,word:"PrintScreen",dec:"70",hex:"46",kind:1,value:70},{key:115,word:"ScrollLock",dec:"71",hex:"47",kind:1,value:71},{key:116,word:"Pause",dec:"72",hex:"48",kind:1,value:72},{key:117,word:"Insert",dec:"73",hex:"49",kind:1,value:73},{key:118,word:"Home",dec:"74",hex:"4A",kind:1,value:74},{key:119,word:"PageUp",dec:"75",hex:"4B",kind:1,value:75},{key:120,word:"DeleteForward",dec:"76",hex:"4C",kind:1,value:76},{key:121,word:"End",dec:"77",hex:"4D",kind:1,value:77},{key:122,word:"PageDown",dec:"78",hex:"4E",kind:1,value:78},{key:123,word:"ArrowRight",dec:"79",hex:"4F",kind:1,value:79},{key:124,word:"ArrowLeft",dec:"80",hex:"50",kind:1,value:80},{key:125,word:"ArrowDown",dec:"81",hex:"51",kind:1,value:81},{key:126,word:"ArrowUp",dec:"82",hex:"52",kind:1,value:82},{key:127,word:"NumLock",dec:"83",hex:"53",kind:1,value:83},{key:128,word:"Clear",dec:"83",hex:"53",kind:1,value:83},{key:160,word:"F13",dec:"104",hex:"68",kind:0,value:104},{key:161,word:"F14",dec:"105",hex:"69",kind:0,value:105},{key:162,word:"F15",dec:"106",hex:"6A",kind:0,value:106},{key:163,word:"F16",dec:"107",hex:"6B",kind:0,value:107},{key:164,word:"LeftControl",dec:"224",hex:"E0",kind:0,value:224},{key:165,word:"LeftShift",dec:"225",hex:"E1",kind:0,value:225},{key:166,word:"LeftAlt",dec:"226",hex:"E2",kind:0,value:226},{key:167,word:"LeftGUI",dec:"227",hex:"E3",kind:0,value:227},{key:168,word:"RightControl",dec:"228",hex:"E4",kind:0,value:228},{key:169,word:"RightShift",dec:"229",hex:"E5",kind:0,value:229},{key:170,word:"RightAlt",dec:"230",hex:"E6",kind:0,value:230},{key:171,word:"RightGUI",dec:"231",hex:"E7",kind:0,value:231}],B=()=>E.reduce((e,r)=>(e.set(r.word,r),r.aliases&&r.aliases.length>0&&r.aliases.forEach(n=>{e.set(n,r)}),e),new Map),I=()=>E.reduce((e,r)=>e.set(r.value,r),new Map);var m=require("fflate"),D=e=>{let r=JSON.stringify(e),n=new TextEncoder().encode(r),o=new Uint8Array((0,m.gzipSync)(n));return new Blob([o],{type:"application/gzip"})},N=async e=>{let r=await e.arrayBuffer(),n=(0,m.gunzipSync)(new Uint8Array(r)),o=new TextDecoder().decode(n);return JSON.parse(o)};function G(e){let r=document.getElementById(e);return r&&window.getComputedStyle(r).display!=="none"&&r.getAttribute("aria-hidden")!=="true"}function _(e){return new Promise(r=>{let n=new Image;n.src=typeof e=="string"?e:URL.createObjectURL(e),n.onload=()=>r(!0),n.onerror=()=>r(!1)})}function H(e=null,r="",n=0){return{success:!0,code:n,message:r,data:e}}function O(e,r=-1,n=null){return{success:!1,code:r,message:e,data:n}}var w={LITTLE:"little",BIG:"big"},$=(e,r,n=w.BIG)=>{if(!Number.isInteger(r)||r<=0)throw new Error("Byte count must be a positive integer.");let o=e>>>0,s=new Array(r);for(let d=0;d<r;d++){let a=n===w.LITTLE?d*8:(r-1-d)*8;s[d]=o>>a&255}return s},U=(e,r=w.BIG)=>{let n=0;if(r===w.LITTLE)for(let o=0;o<e.length;o++)n|=(e[o]&255)<<o*8;else for(let o=0;o<e.length;o++)n|=(e[o]&255)<<(e.length-1-o)*8;return n},V=(e,r=w.BIG)=>{let n=e&65535;return r===w.LITTLE?[n&255,n>>8&255]:[n>>8&255,n&255]},z=(e,r=w.BIG)=>{if(e.length!==2)throw new Error("Input array must have exactly 2 elements");return r===w.LITTLE?e[1]<<8|e[0]:e[0]<<8|e[1]},W=e=>Math.abs(e).toString().split("").map(r=>r.charCodeAt(0)),J=e=>Number(String.fromCharCode(...e));var i=(e,r,n)=>Math.min(Math.max(e,r),n);function j(e){let r=t=>{let c=t.endsWith("%"),u=parseFloat(t.replace("%",""));return c?Math.round(i(u/100,0,1)*255):i(Math.round(u),0,255)},n=t=>{let c=t.endsWith("%"),u=parseFloat(t.replace("%",""));return i(c?u/100:u,0,1)},o=t=>{if(!t.endsWith("%"))return 0;let c=parseFloat(t.replace("%",""));return i(c/100,0,1)},s=/^rgb\(\s*(\d+(\.\d+)?%?)\s*,\s*(\d+(\.\d+)?%?)\s*,\s*(\d+(\.\d+)?%?)\s*\)$/i,d=e.match(s);if(d){let[,t,,c,,u]=d;return{type:"rgb",r:r(t),g:r(c),b:r(u)}}let a=/^rgba\(\s*(\d+(\.\d+)?%?)\s*,\s*(\d+(\.\d+)?%?)\s*,\s*(\d+(\.\d+)?%?)\s*,\s*(\d+(\.\d+)?%?)\s*\)$/i,x=e.match(a);if(x){let[,t,,c,,u,,g]=x;return{type:"rgba",r:r(t),g:r(c),b:r(u),a:n(g)}}let y=/^hsv\(\s*(\d+(\.\d+)?)\s*,\s*(\d+(\.\d+)?%)\s*,\s*(\d+(\.\d+)?%)\s*\)$/i,l=e.match(y);if(l){let[,t,,c,,u]=l;return{type:"hsv",h:i(parseFloat(t),0,360),s:o(c),v:o(u)}}let v=/^hsl\(\s*(\d+(\.\d+)?)\s*,\s*(\d+(\.\d+)?%)\s*,\s*(\d+(\.\d+)?%)\s*\)$/i,f=e.match(v);if(f){let[,t,,c,,u]=f;return{type:"hsl",h:i(parseFloat(t),0,360),s:o(c),l:o(u)}}let k=/^hsla\(\s*(\d+(\.\d+)?)\s*,\s*(\d+(\.\d+)?%)\s*,\s*(\d+(\.\d+)?%)\s*,\s*(\d+(\.\d+)?%?)\s*\)$/i,L=e.match(k);if(L){let[,t,,c,,u,,g]=L;return{type:"hsla",h:i(parseFloat(t),0,360),s:o(c),l:o(u),a:n(g)}}return null}function Q(e){let r=i(e.h,0,360)/360,n=i(e.s,0,1),o=i(e.l,0,1),s=0,d=0,a=0;if(n===0)s=d=a=o;else{let x=(v,f,k)=>(k<0&&(k+=1),k>1&&(k-=1),k<.16666666666666666?v+(f-v)*6*k:k<.5?f:k<.6666666666666666?v+(f-v)*(.6666666666666666-k)*6:v),y=o<.5?o*(1+n):o+n-o*n,l=2*o-y;s=x(l,y,r+1/3),d=x(l,y,r),a=x(l,y,r-1/3)}return{type:"rgb",r:Math.round(s*255),g:Math.round(d*255),b:Math.round(a*255)}}function X(e){let r=i(e.r,0,255)/255,n=i(e.g,0,255)/255,o=i(e.b,0,255)/255,s=Math.max(r,n,o),d=Math.min(r,n,o),a=s-d,x=(s+d)/2,y=0;a!==0&&(y=a/(1-Math.abs(2*x-1)));let l=0;if(a!==0){switch(s){case r:l=(n-o)/a%6;break;case n:l=(o-r)/a+2;break;case o:l=(r-n)/a+4;break}l=Math.round(l*60),l<0&&(l+=360)}return{type:"hsl",h:i(l,0,360),s:i(y,0,1),l:i(x,0,1)}}function Y(e){let{h:r,s:n,v:o}=e,s;n===0?s=o:s=(2-n)*o/2,s=Math.max(0,Math.min(1,s));let d;return s===0||s===1?d=0:(d=n*o/(1-Math.abs(2*s-1)),d=Math.max(0,Math.min(1,d))),{type:"hsl",h:Math.max(0,Math.min(360,r)),s:d,l:s}}function Z(e){let{h:r,s:n,l:o}=e,s=o+n*Math.min(o,1-o),d=Math.max(0,Math.min(1,s)),a;return d===0?a=0:(a=2*(1-o/d),a=Math.max(0,Math.min(1,a))),{type:"hsv",h:Math.max(0,Math.min(360,r)),s:a,v:d}}var q=typeof window<"u",K=()=>typeof process<"u"&&process.env?.NODE_ENV?process.env.NODE_ENV==="development":q&&window.__ENV__?.MODE?window.__ENV__.MODE==="development":!0,M={enable:K(),reserveTypes:["error"],prefix:"[iLx1-tool]"},h={...M},p=e=>h.enable?!0:h.reserveTypes.includes(e),ee=(...e)=>{p("log")&&console.log(`${h.prefix} [LOG]`,...e)},re=(...e)=>{p("info")&&console.info(`${h.prefix} [INFO]`,...e)},ne=(...e)=>{p("warn")&&console.warn(`${h.prefix} [WARN]`,...e)},oe=(...e)=>{p("error")&&console.error(`${h.prefix} [ERROR]`,...e)},se=(...e)=>{p("debug")&&console.debug(`${h.prefix} [DEBUG]`,...e)},S=e=>{h={...h,...e}},de=()=>{h={...M}},ae=()=>{S({enable:!0,reserveTypes:["log","info","warn","error","debug"]})},te=()=>{S({enable:!1,reserveTypes:[]})};0&&(module.exports={Endianness,asciiArrToNum,bits16ToNum,bytesToNum,compressJsonGzip,debug,decompressJsonGzip,disableAllLogs,enableAllLogs,error,errorResult,getHIDCodeMapStr,getHIDCodeMapStrNum,hidKeyCode,hslToHsv,hslToRgb,hsvToHsl,info,isImageValid,isShowPopover,log,numToAsciiArr,numToBits16,numToBytes,parseColorString,resetLoggerConfig,rgbToHsl,setLoggerConfig,successResult,warn});
|
|
1
|
+
var D=Object.create;var S=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var U=(e,n)=>{for(var t in n)S(e,t,{get:n[t],enumerable:!0})},A=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of L(n))!F.call(e,o)&&o!==t&&S(e,o,{get:()=>n[o],enumerable:!(r=R(n,o))||r.enumerable});return e};var H=(e,n,t)=>(t=e!=null?D(P(e)):{},A(n||!e||!e.__esModule?S(t,"default",{value:e,enumerable:!0}):t,e)),O=e=>A(S({},"__esModule",{value:!0}),e);var Re={};U(Re,{Endianness:()=>w,ImageSamplingCol:()=>pe,ImageSamplingColRow:()=>ye,ImageSamplingRow:()=>xe,ImageSamplingRowCol:()=>ke,ImageToHexArray:()=>l,arrayToHex:()=>Se,asciiArrToNum:()=>X,base64ToImageData:()=>we,bits16ToNum:()=>Q,bytesToNum:()=>J,calculateOutputSize:()=>Ae,colorImageSampling:()=>fe,compressJsonGzip:()=>G,createImageData:()=>Ee,debug:()=>le,decompressJsonGzip:()=>_,disableAllLogs:()=>me,enableAllLogs:()=>ue,error:()=>de,errorResult:()=>W,formatHexOutput:()=>Me,generate:()=>ge,generatePreview:()=>Ce,getDefaultConfig:()=>De,getHIDCodeMapStr:()=>N,getHIDCodeMapStrNum:()=>B,getSamplingModeDescription:()=>Te,hex2hex:()=>Ie,hidKeyCode:()=>E,hslToHsv:()=>te,hslToRgb:()=>Z,hsvToHsl:()=>ne,imageDataToHexArray:()=>he,info:()=>se,isImageValid:()=>z,isShowPopover:()=>V,log:()=>ae,numToAsciiArr:()=>q,numToBits16:()=>K,numToBytes:()=>j,parseColorString:()=>Y,resetLoggerConfig:()=>ce,resizeImageWithCanvas:()=>ve,resizeImageWithKonva:()=>be,rgbToHsl:()=>ee,setLoggerConfig:()=>M,successResult:()=>$,warn:()=>ie});module.exports=O(Re);var E=[{key:0,word:"a",dec:"4",hex:"04",kind:1,value:4,aliases:["A"]},{key:2,word:"b",dec:"5",hex:"05",kind:1,value:5,aliases:["B"]},{key:4,word:"c",dec:"6",hex:"06",kind:1,value:6,aliases:["C"]},{key:6,word:"d",dec:"7",hex:"07",kind:1,value:7,aliases:["D"]},{key:8,word:"e",dec:"8",hex:"08",kind:1,value:8,aliases:["E"]},{key:10,word:"f",dec:"9",hex:"09",kind:1,value:9,aliases:["F"]},{key:12,word:"g",dec:"10",hex:"0A",kind:1,value:10,aliases:["G"]},{key:14,word:"h",dec:"11",hex:"0B",kind:1,value:11,aliases:["H"]},{key:16,word:"i",dec:"12",hex:"0C",kind:1,value:12,aliases:["I"]},{key:18,word:"j",dec:"13",hex:"0D",kind:1,value:13,aliases:["J"]},{key:20,word:"k",dec:"14",hex:"0E",kind:1,value:14,aliases:["K"]},{key:22,word:"l",dec:"15",hex:"0F",kind:1,value:15,aliases:["L"]},{key:24,word:"m",dec:"16",hex:"10",kind:1,value:16,aliases:["M"]},{key:26,word:"n",dec:"17",hex:"11",kind:1,value:17,aliases:["N"]},{key:28,word:"o",dec:"18",hex:"12",kind:1,value:18,aliases:["O"]},{key:30,word:"p",dec:"19",hex:"13",kind:1,value:19,aliases:["P"]},{key:32,word:"q",dec:"20",hex:"14",kind:1,value:20,aliases:["Q"]},{key:34,word:"r",dec:"21",hex:"15",kind:1,value:21,aliases:["R"]},{key:36,word:"s",dec:"22",hex:"16",kind:1,value:22,aliases:["S"]},{key:38,word:"t",dec:"23",hex:"17",kind:1,value:23,aliases:["T"]},{key:40,word:"u",dec:"24",hex:"18",kind:1,value:24,aliases:["U"]},{key:42,word:"v",dec:"25",hex:"19",kind:1,value:25,aliases:["V"]},{key:44,word:"w",dec:"26",hex:"1A",kind:1,value:26,aliases:["W"]},{key:46,word:"x",dec:"27",hex:"1B",kind:1,value:27,aliases:["X"]},{key:48,word:"y",dec:"28",hex:"1C",kind:1,value:28,aliases:["Y"]},{key:50,word:"z",dec:"29",hex:"1D",kind:1,value:29,aliases:["Z"]},{key:52,word:"1",dec:"30",hex:"1E",kind:1,value:30,aliases:["!","1!"]},{key:54,word:"2",dec:"31",hex:"1F",kind:1,value:31,aliases:["@","2@"]},{key:56,word:"3",dec:"32",hex:"20",kind:1,value:32,aliases:["#","3#"]},{key:58,word:"4",dec:"33",hex:"21",kind:1,value:33,aliases:["$","4$"]},{key:60,word:"5",dec:"34",hex:"22",kind:1,value:34,aliases:["%","5%"]},{key:62,word:"6",dec:"35",hex:"23",kind:1,value:35,aliases:["^","6^"]},{key:64,word:"7",dec:"36",hex:"24",kind:1,value:36,aliases:["&","7&"]},{key:66,word:"8",dec:"37",hex:"25",kind:1,value:37,aliases:["*","8*"]},{key:68,word:"9",dec:"38",hex:"26",kind:1,value:38,aliases:["(","9("]},{key:70,word:"0",dec:"39",hex:"27",kind:1,value:39,aliases:[")","0)"]},{key:77,word:"-",dec:"45",hex:"2D",kind:1,value:45,aliases:["_","-_"]},{key:79,word:"=",dec:"46",hex:"2E",kind:1,value:46,aliases:["+","=+"]},{key:81,word:"[",dec:"47",hex:"2F",kind:1,value:47,aliases:["{","[{"]},{key:83,word:"]",dec:"48",hex:"30",kind:1,value:48,aliases:["}","}]"]},{key:85,word:"\\",dec:"49",hex:"31",kind:1,value:49,aliases:["|","\\|"]},{key:87,word:"`",dec:"50",hex:"32",kind:1,value:50,aliases:["~","`~"]},{key:89,word:";",dec:"51",hex:"33",kind:1,value:51,aliases:[":",";:"]},{key:91,word:"'",dec:"52",hex:"34",kind:1,value:52,aliases:['"',`'"`]},{key:95,word:",",dec:"54",hex:"36",kind:1,value:54,aliases:["<",",<"]},{key:97,word:".",dec:"55",hex:"37",kind:1,value:55,aliases:[">",".>"]},{key:99,word:"/",dec:"56",hex:"38",kind:1,value:56,aliases:["?","/?"]},{key:72,word:"Enter",dec:"40",hex:"28",kind:1,value:40},{key:73,word:"Escape",dec:"41",hex:"29",kind:1,value:41},{key:74,word:"Backspace",dec:"42",hex:"2A",kind:1,value:42},{key:75,word:"Tab",dec:"43",hex:"2B",kind:1,value:43},{key:76,word:" ",dec:"44",hex:"2C",kind:1,value:44},{key:101,word:"CapsLock",dec:"57",hex:"39",kind:1,value:57},{key:102,word:"F1",dec:"58",hex:"3A",kind:1,value:58},{key:103,word:"F2",dec:"59",hex:"3B",kind:1,value:59},{key:104,word:"F3",dec:"60",hex:"3C",kind:1,value:60},{key:105,word:"F4",dec:"61",hex:"3D",kind:1,value:61},{key:106,word:"F5",dec:"62",hex:"3E",kind:1,value:62},{key:107,word:"F6",dec:"63",hex:"3F",kind:1,value:63},{key:108,word:"F7",dec:"64",hex:"40",kind:1,value:64},{key:109,word:"F8",dec:"65",hex:"41",kind:1,value:65},{key:110,word:"F9",dec:"66",hex:"42",kind:1,value:66},{key:111,word:"F10",dec:"67",hex:"43",kind:1,value:67},{key:112,word:"F11",dec:"68",hex:"44",kind:1,value:68},{key:113,word:"F12",dec:"69",hex:"45",kind:1,value:69},{key:114,word:"PrintScreen",dec:"70",hex:"46",kind:1,value:70},{key:115,word:"ScrollLock",dec:"71",hex:"47",kind:1,value:71},{key:116,word:"Pause",dec:"72",hex:"48",kind:1,value:72},{key:117,word:"Insert",dec:"73",hex:"49",kind:1,value:73},{key:118,word:"Home",dec:"74",hex:"4A",kind:1,value:74},{key:119,word:"PageUp",dec:"75",hex:"4B",kind:1,value:75},{key:120,word:"DeleteForward",dec:"76",hex:"4C",kind:1,value:76},{key:121,word:"End",dec:"77",hex:"4D",kind:1,value:77},{key:122,word:"PageDown",dec:"78",hex:"4E",kind:1,value:78},{key:123,word:"ArrowRight",dec:"79",hex:"4F",kind:1,value:79},{key:124,word:"ArrowLeft",dec:"80",hex:"50",kind:1,value:80},{key:125,word:"ArrowDown",dec:"81",hex:"51",kind:1,value:81},{key:126,word:"ArrowUp",dec:"82",hex:"52",kind:1,value:82},{key:127,word:"NumLock",dec:"83",hex:"53",kind:1,value:83},{key:128,word:"Clear",dec:"83",hex:"53",kind:1,value:83},{key:160,word:"F13",dec:"104",hex:"68",kind:0,value:104},{key:161,word:"F14",dec:"105",hex:"69",kind:0,value:105},{key:162,word:"F15",dec:"106",hex:"6A",kind:0,value:106},{key:163,word:"F16",dec:"107",hex:"6B",kind:0,value:107},{key:164,word:"LeftControl",dec:"224",hex:"E0",kind:0,value:224},{key:165,word:"LeftShift",dec:"225",hex:"E1",kind:0,value:225},{key:166,word:"LeftAlt",dec:"226",hex:"E2",kind:0,value:226},{key:167,word:"LeftGUI",dec:"227",hex:"E3",kind:0,value:227},{key:168,word:"RightControl",dec:"228",hex:"E4",kind:0,value:228},{key:169,word:"RightShift",dec:"229",hex:"E5",kind:0,value:229},{key:170,word:"RightAlt",dec:"230",hex:"E6",kind:0,value:230},{key:171,word:"RightGUI",dec:"231",hex:"E7",kind:0,value:231}],N=()=>E.reduce((e,n)=>(e.set(n.word,n),n.aliases&&n.aliases.length>0&&n.aliases.forEach(t=>{e.set(t,n)}),e),new Map),B=()=>E.reduce((e,n)=>e.set(n.value,n),new Map);var I=require("fflate"),G=e=>{let n=JSON.stringify(e),t=new TextEncoder().encode(n),r=new Uint8Array((0,I.gzipSync)(t));return new Blob([r],{type:"application/gzip"})},_=async e=>{let n=await e.arrayBuffer(),t=(0,I.gunzipSync)(new Uint8Array(n)),r=new TextDecoder().decode(t);return JSON.parse(r)};function V(e){let n=document.getElementById(e);return n&&window.getComputedStyle(n).display!=="none"&&n.getAttribute("aria-hidden")!=="true"}function z(e){return new Promise(n=>{let t=new Image;t.src=typeof e=="string"?e:URL.createObjectURL(e),t.onload=()=>n(!0),t.onerror=()=>n(!1)})}function $(e=null,n="",t=0){return{success:!0,code:t,message:n,data:e}}function W(e,n=-1,t=null){return{success:!1,code:n,message:e,data:t}}var w={LITTLE:"little",BIG:"big"},j=(e,n,t=w.BIG)=>{if(!Number.isInteger(n)||n<=0)throw new Error("Byte count must be a positive integer.");let r=e>>>0,o=new Array(n);for(let a=0;a<n;a++){let s=t===w.LITTLE?a*8:(n-1-a)*8;o[a]=r>>s&255}return o},J=(e,n=w.BIG)=>{let t=0;if(n===w.LITTLE)for(let r=0;r<e.length;r++)t|=(e[r]&255)<<r*8;else for(let r=0;r<e.length;r++)t|=(e[r]&255)<<(e.length-1-r)*8;return t},K=(e,n=w.BIG)=>{let t=e&65535;return n===w.LITTLE?[t&255,t>>8&255]:[t>>8&255,t&255]},Q=(e,n=w.BIG)=>{if(e.length!==2)throw new Error("Input array must have exactly 2 elements");return n===w.LITTLE?e[1]<<8|e[0]:e[0]<<8|e[1]},q=e=>Math.abs(e).toString().split("").map(n=>n.charCodeAt(0)),X=e=>Number(String.fromCharCode(...e));var x=(e,n,t)=>Math.min(Math.max(e,n),t);function Y(e){let n=f=>{let p=f.endsWith("%"),y=parseFloat(f.replace("%",""));return p?Math.round(x(y/100,0,1)*255):x(Math.round(y),0,255)},t=f=>{let p=f.endsWith("%"),y=parseFloat(f.replace("%",""));return x(p?y/100:y,0,1)},r=f=>{if(!f.endsWith("%"))return 0;let p=parseFloat(f.replace("%",""));return x(p/100,0,1)},o=/^rgb\(\s*(\d+(\.\d+)?%?)\s*,\s*(\d+(\.\d+)?%?)\s*,\s*(\d+(\.\d+)?%?)\s*\)$/i,a=e.match(o);if(a){let[,f,,p,,y]=a;return{type:"rgb",r:n(f),g:n(p),b:n(y)}}let s=/^rgba\(\s*(\d+(\.\d+)?%?)\s*,\s*(\d+(\.\d+)?%?)\s*,\s*(\d+(\.\d+)?%?)\s*,\s*(\d+(\.\d+)?%?)\s*\)$/i,u=e.match(s);if(u){let[,f,,p,,y,,C]=u;return{type:"rgba",r:n(f),g:n(p),b:n(y),a:t(C)}}let m=/^hsv\(\s*(\d+(\.\d+)?)\s*,\s*(\d+(\.\d+)?%)\s*,\s*(\d+(\.\d+)?%)\s*\)$/i,i=e.match(m);if(i){let[,f,,p,,y]=i;return{type:"hsv",h:x(parseFloat(f),0,360),s:r(p),v:r(y)}}let d=/^hsl\(\s*(\d+(\.\d+)?)\s*,\s*(\d+(\.\d+)?%)\s*,\s*(\d+(\.\d+)?%)\s*\)$/i,c=e.match(d);if(c){let[,f,,p,,y]=c;return{type:"hsl",h:x(parseFloat(f),0,360),s:r(p),l:r(y)}}let g=/^hsla\(\s*(\d+(\.\d+)?)\s*,\s*(\d+(\.\d+)?%)\s*,\s*(\d+(\.\d+)?%)\s*,\s*(\d+(\.\d+)?%?)\s*\)$/i,h=e.match(g);if(h){let[,f,,p,,y,,C]=h;return{type:"hsla",h:x(parseFloat(f),0,360),s:r(p),l:r(y),a:t(C)}}return null}function Z(e){let n=x(e.h,0,360)/360,t=x(e.s,0,1),r=x(e.l,0,1),o=0,a=0,s=0;if(t===0)o=a=s=r;else{let u=(d,c,g)=>(g<0&&(g+=1),g>1&&(g-=1),g<.16666666666666666?d+(c-d)*6*g:g<.5?c:g<.6666666666666666?d+(c-d)*(.6666666666666666-g)*6:d),m=r<.5?r*(1+t):r+t-r*t,i=2*r-m;o=u(i,m,n+1/3),a=u(i,m,n),s=u(i,m,n-1/3)}return{type:"rgb",r:Math.round(o*255),g:Math.round(a*255),b:Math.round(s*255)}}function ee(e){let n=x(e.r,0,255)/255,t=x(e.g,0,255)/255,r=x(e.b,0,255)/255,o=Math.max(n,t,r),a=Math.min(n,t,r),s=o-a,u=(o+a)/2,m=0;s!==0&&(m=s/(1-Math.abs(2*u-1)));let i=0;if(s!==0){switch(o){case n:i=(t-r)/s%6;break;case t:i=(r-n)/s+2;break;case r:i=(n-t)/s+4;break}i=Math.round(i*60),i<0&&(i+=360)}return{type:"hsl",h:x(i,0,360),s:x(m,0,1),l:x(u,0,1)}}function ne(e){let{h:n,s:t,v:r}=e,o;t===0?o=r:o=(2-t)*r/2,o=Math.max(0,Math.min(1,o));let a;return o===0||o===1?a=0:(a=t*r/(1-Math.abs(2*o-1)),a=Math.max(0,Math.min(1,a))),{type:"hsl",h:Math.max(0,Math.min(360,n)),s:a,l:o}}function te(e){let{h:n,s:t,l:r}=e,o=r+t*Math.min(r,1-r),a=Math.max(0,Math.min(1,o)),s;return a===0?s=0:(s=2*(1-r/a),s=Math.max(0,Math.min(1,s))),{type:"hsv",h:Math.max(0,Math.min(360,n)),s,v:a}}var re=typeof window<"u",oe=()=>typeof process<"u"&&process.env?.NODE_ENV?process.env.NODE_ENV==="development":re&&window.__ENV__?.MODE?window.__ENV__.MODE==="development":!0,T={enable:oe(),reserveTypes:["error"],prefix:"[iLx1-tool]"},k={...T},v=e=>k.enable?!0:k.reserveTypes.includes(e),ae=(...e)=>{v("log")&&console.log(`${k.prefix} [LOG]`,...e)},se=(...e)=>{v("info")&&console.info(`${k.prefix} [INFO]`,...e)},ie=(...e)=>{v("warn")&&console.warn(`${k.prefix} [WARN]`,...e)},de=(...e)=>{v("error")&&console.error(`${k.prefix} [ERROR]`,...e)},le=(...e)=>{v("debug")&&console.debug(`${k.prefix} [DEBUG]`,...e)},M=e=>{k={...k,...e}},ce=()=>{k={...T}},ue=()=>{M({enable:!0,reserveTypes:["log","info","warn","error","debug"]})},me=()=>{M({enable:!1,reserveTypes:[]})};var b=H(require("konva")),l={generate:async function(e,n,t){try{let r=await this.base64ToImageData(e),o=this.imageDataToHexArray(r,n,t);return t[3]===0?this.hex2hex(this.arrayToHex(o)):o}catch(r){throw console.error("\u751F\u6210\u5341\u516D\u8FDB\u5236\u6570\u7EC4\u65F6\u51FA\u9519:",r),r}},imageDataToHexArray:function(e,n,t){let r=e.data,o=e.height,a=e.width,s=r.length;if(t[4]==1){let u=[];for(let c=0;c<s;c+=4){let h=r[c]*.299+r[c+1]*.587+r[c+2]*.114>n?1:0;u[c/4]=h}let i=t[1],d;switch(i){case 0:d=this.ImageSamplingRow;break;case 1:d=this.ImageSamplingCol;break;case 2:d=this.ImageSamplingColRow;break;case 3:d=this.ImageSamplingRowCol;break;default:d=this.ImageSamplingRow}if(typeof d!="function")throw new Error(`\u53D6\u6A21\u51FD\u6570\u672A\u5B9A\u4E49\uFF0CsamplingMode: ${i}`);return d.call(this,u,a,o,t)}else return this.colorImageSampling(r,a,o,t)},colorImageSampling:function(e,n,t,r){let o=new Uint8Array(n*t*2),a=0,s=0;for(;a<o.length&&s<e.length;){let u=e[s],m=e[s+1],i=e[s+2],d=u>>3&31,c=m>>2&63,g=i>>3&31,h=d<<11|c<<5|g;o[a]=h>>8&255,o[a+1]=h&255,(r[0]==0||r[2]==1)&&(o[a]=~o[a]&255,o[a+1]=~o[a+1]&255),a+=2,s+=4}return o},ImageSamplingRow:function(e,n,t,r){let o=Math.ceil(n/8),a=new Uint8Array(o*t);for(let s=0;s<e.length;s++){let u=s%n,i=Math.floor(s/n),d=u%8,c=1<<d;r[2]!=0&&(c=1<<7-d);let g=i*o+Math.floor(u/8),h=e[s];r[0]!==0&&(h=h===0?1:0),h===0?a[g]|=c:a[g]&=~c}return a},ImageSamplingCol:function(e,n,t,r){let o=Math.ceil(t/8),a=new Uint8Array(o*n);for(let s=0;s<e.length;s++){let u=s%n,m=Math.floor(s/n),i=u,d=m%8,c=1<<d;r[2]!=0&&(c=1<<7-d);let g=i*o+Math.floor(m/8),h=e[s];r[0]!==0&&(h=h===0?1:0),h===0?a[g]|=c:a[g]&=~c}return a},ImageSamplingColRow:function(e,n,t,r){let o=Math.ceil(t/8),a=new Uint8Array(o*n);for(let s=0;s<e.length;s++){let u=s%n,m=Math.floor(s/n),i=Math.floor(m/8),d=m%8,c=1<<d;r[2]!=0&&(c=1<<7-d);let g=u+i*n,h=e[s];r[0]!==0&&(h=h===0?1:0),h===0?a[g]|=c:a[g]&=~c}return a},ImageSamplingRowCol:function(e,n,t,r){let o=Math.ceil(n/8),a=new Uint8Array(o*t);for(let s=0;s<e.length;s++){let u=s%n,m=Math.floor(s/n),i=Math.floor(u/8),d=u%8,c=1<<d;r[2]!=0&&(c=1<<7-d);let g=i*t+m,h=e[s];r[0]!==0&&(h=h===0?1:0),h===0?a[g]|=c:a[g]&=~c}return a},base64ToImageData:function(e){return new Promise((n,t)=>{let r=new Image;r.crossOrigin="anonymous",r.src=e,r.onload=()=>{try{let o=document.createElement("canvas");o.width=r.width,o.height=r.height;let a=o.getContext("2d");a.drawImage(r,0,0);let s=a.getImageData(0,0,o.width,o.height);n(s)}catch(o){t(new Error(`\u8F6C\u6362\u56FE\u50CF\u6570\u636E\u5931\u8D25: ${o.message}`))}},r.onerror=()=>{t(new Error("\u52A0\u8F7D\u56FE\u50CF\u5931\u8D25"))},r.src=e})},resizeImageWithKonva:async function(e,n,t,r){if(e===0||n===0)throw new Error("\u5BBD\u5EA6\u548C\u9AD8\u5EA6\u4E0D\u80FD\u4E3A0");if(!t)throw new Error("\u56FE\u50CF\u5BF9\u8C61\u4E0D\u80FD\u4E3A\u7A7A");return new Promise(o=>{if(typeof b.default>"u"){this.resizeImageWithCanvas(e,n,t,r).then(o).catch(()=>{let i=document.createElement("canvas");i.width=t.width,i.height=t.height,i.getContext("2d").drawImage(t,0,0),o(i.toDataURL("image/png"))});return}let a=new b.default.Stage({container:document.createElement("div"),width:e,height:n}),s=new b.default.Layer;a.add(s);let u=new b.default.Image({image:t,width:e,height:n});r&&u.filters([b.default.Filters.Grayscale]),s.add(u),s.batchDraw();let m=a.toDataURL({mimeType:"image/png",quality:1,pixelRatio:1});a.destroy(),o(m)})},resizeImageWithCanvas:async function(e,n,t,r){return new Promise(o=>{let a=document.createElement("canvas");a.width=e,a.height=n;let s=a.getContext("2d");if(s.imageSmoothingEnabled=!0,s.imageSmoothingQuality="high",s.drawImage(t,0,0,e,n),r){let m=s.getImageData(0,0,e,n),i=m.data;for(let d=0;d<i.length;d+=4){let c=i[d]*.299+i[d+1]*.587+i[d+2]*.114;i[d]=i[d+1]=i[d+2]=c}s.putImageData(m,0,0)}let u=a.toDataURL("image/png");o(u)})},arrayToHex:function(e){return!e||e.length===0?"":Array.from(e).map(n=>Number(n).toString(16).padStart(2,"0")).join("")},hex2hex:function(e){if(!e||e.length===0)return[];let n=[];for(let t=0;t<e.length;t+=2)n.push("0x"+e.substring(t,t+2));return n},generatePreview:function(e,n){if(!e||e.length===0)return"";let t="";for(let r=0;r<e.length;r++)t+=e[r]===0?"0":"1",(r+1)%n===0&&(t+=`
|
|
2
|
+
`);return t},createImageData:function(e,n,t=null){let r=document.createElement("canvas");r.width=e,r.height=n;let o=r.getContext("2d");if(t){let a=o.createImageData(e,n);return a.data.set(t),a}else return o.createImageData(e,n)},formatHexOutput:function(e,n=0,t=16){if(!e||e.length===0)return"\u65E0\u6570\u636E";let r="";if(n===0&&Array.isArray(e))for(let o=0;o<e.length;o++)r+=e[o]+", ",(o+1)%t===0&&(r+=`
|
|
3
|
+
`);else if(e instanceof Uint8Array)for(let o=0;o<e.length;o++)r+=e[o].toString(16).padStart(2,"0")+" ",(o+1)%t===0&&(r+=`
|
|
4
|
+
`);else r=e.toString();return r},calculateOutputSize:function(e){let n=0;(Array.isArray(e)||e instanceof Uint8Array)&&(n=e.length);let t=n/1024;return{bytes:n,kilobytes:t,formatted:`${n} \u5B57\u8282 (${t.toFixed(2)} KB)`}},getSamplingModeDescription:function(e){return{0:"\u9010\u884C\u5F0F (\u4ECE\u5DE6\u5230\u53F3\uFF0C\u4ECE\u4E0A\u5230\u4E0B)",1:"\u9010\u5217\u5F0F (\u4ECE\u4E0A\u5230\u4E0B\uFF0C\u4ECE\u5DE6\u5230\u53F3)",2:"\u5217\u884C\u5F0F (\u5148\u5217\u540E\u884C)",3:"\u884C\u5217\u5F0F (\u5148\u884C\u540E\u5217)"}[e]||"\u672A\u77E5\u53D6\u6A21\u65B9\u5F0F"},getDefaultConfig:function(){return[0,0,0,0,1]}},ge=l.generate.bind(l),he=l.imageDataToHexArray.bind(l),fe=l.colorImageSampling.bind(l),xe=l.ImageSamplingRow.bind(l),pe=l.ImageSamplingCol.bind(l),ye=l.ImageSamplingColRow.bind(l),ke=l.ImageSamplingRowCol.bind(l),we=l.base64ToImageData.bind(l),be=l.resizeImageWithKonva.bind(l),ve=l.resizeImageWithCanvas.bind(l),Se=l.arrayToHex.bind(l),Ie=l.hex2hex.bind(l),Ce=l.generatePreview.bind(l),Ee=l.createImageData.bind(l),Me=l.formatHexOutput.bind(l),Ae=l.calculateOutputSize.bind(l),Te=l.getSamplingModeDescription.bind(l),De=l.getDefaultConfig.bind(l);0&&(module.exports={Endianness,ImageSamplingCol,ImageSamplingColRow,ImageSamplingRow,ImageSamplingRowCol,ImageToHexArray,arrayToHex,asciiArrToNum,base64ToImageData,bits16ToNum,bytesToNum,calculateOutputSize,colorImageSampling,compressJsonGzip,createImageData,debug,decompressJsonGzip,disableAllLogs,enableAllLogs,error,errorResult,formatHexOutput,generate,generatePreview,getDefaultConfig,getHIDCodeMapStr,getHIDCodeMapStrNum,getSamplingModeDescription,hex2hex,hidKeyCode,hslToHsv,hslToRgb,hsvToHsl,imageDataToHexArray,info,isImageValid,isShowPopover,log,numToAsciiArr,numToBits16,numToBytes,parseColorString,resetLoggerConfig,resizeImageWithCanvas,resizeImageWithKonva,rgbToHsl,setLoggerConfig,successResult,warn});
|
|
2
5
|
//# sourceMappingURL=index.js.map
|