@pixzle/core 0.0.19 → 0.0.21
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/dist/block-operations.cjs +146 -0
- package/dist/block-operations.d.cts +56 -0
- package/dist/block-operations.d.ts +55 -0
- package/dist/block-operations.d.ts.map +1 -0
- package/dist/block-operations.js +147 -0
- package/dist/block-operations.js.map +1 -0
- package/dist/block-utils.cjs +86 -0
- package/dist/block-utils.d.cts +47 -0
- package/dist/block-utils.d.ts +48 -0
- package/dist/block-utils.d.ts.map +1 -0
- package/dist/block-utils.js +94 -0
- package/dist/block-utils.js.map +1 -0
- package/dist/constants.cjs +11 -0
- package/dist/constants.d.cts +8 -0
- package/dist/constants.d.ts +7 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +11 -0
- package/dist/constants.js.map +1 -0
- package/dist/helpers.cjs +101 -0
- package/dist/helpers.d.cts +45 -0
- package/dist/helpers.d.ts +44 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +101 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.cjs +27 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/types.cjs +3 -0
- package/dist/types.d.cts +65 -0
- package/dist/types.d.ts +63 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/validators.cjs +48 -0
- package/dist/validators.d.cts +16 -0
- package/dist/validators.d.ts +15 -0
- package/dist/validators.d.ts.map +1 -0
- package/dist/validators.js +48 -0
- package/dist/validators.js.map +1 -0
- package/package.json +6 -21
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractBlock = extractBlock;
|
|
4
|
+
exports.placeBlock = placeBlock;
|
|
5
|
+
exports.splitImageToBlocks = splitImageToBlocks;
|
|
6
|
+
exports.blocksToImageBuffer = blocksToImageBuffer;
|
|
7
|
+
const block_utils_1 = require("./block-utils");
|
|
8
|
+
/**
|
|
9
|
+
* Extract a block from an image buffer
|
|
10
|
+
* @param buffer Source image buffer (RGBA format)
|
|
11
|
+
* @param imageWidth Image width in pixels
|
|
12
|
+
* @param imageHeight Image height in pixels (optional, defaults to calculated height)
|
|
13
|
+
* @param startX Block top-left X coordinate
|
|
14
|
+
* @param startY Block top-left Y coordinate
|
|
15
|
+
* @param blockSize Maximum block size
|
|
16
|
+
* @returns Block buffer containing pixel data
|
|
17
|
+
*/
|
|
18
|
+
function extractBlock(buffer, imageWidth, imageHeight, startX, startY, blockSize) {
|
|
19
|
+
// Calculate actual block dimensions considering image boundaries
|
|
20
|
+
const blockWidth = Math.min(blockSize, imageWidth - startX);
|
|
21
|
+
const blockHeight = imageHeight !== undefined
|
|
22
|
+
? Math.min(blockSize, imageHeight - startY)
|
|
23
|
+
: blockSize;
|
|
24
|
+
const blockData = [];
|
|
25
|
+
// Extract pixel data row by row
|
|
26
|
+
for (let y = 0; y < blockHeight; y++) {
|
|
27
|
+
for (let x = 0; x < blockWidth; x++) {
|
|
28
|
+
const pixelX = startX + x;
|
|
29
|
+
const pixelY = startY + y;
|
|
30
|
+
const pixelIndex = (pixelY * imageWidth + pixelX) * block_utils_1.RGBA_CHANNELS;
|
|
31
|
+
// Copy RGBA channels
|
|
32
|
+
for (let channel = 0; channel < block_utils_1.RGBA_CHANNELS; channel++) {
|
|
33
|
+
blockData.push(buffer[pixelIndex + channel] || 0);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return new Uint8Array(blockData);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Place block data at the specified position in the target image buffer
|
|
41
|
+
* @param targetBuffer Target image buffer to place the block into
|
|
42
|
+
* @param blockData Block data to place
|
|
43
|
+
* @param targetWidth Target image width in pixels
|
|
44
|
+
* @param destX Destination X coordinate
|
|
45
|
+
* @param destY Destination Y coordinate
|
|
46
|
+
* @param blockSize Standard block size
|
|
47
|
+
* @param blockWidth Actual block width (optional, defaults to blockSize)
|
|
48
|
+
* @param blockHeight Actual block height (optional, defaults to blockSize)
|
|
49
|
+
*/
|
|
50
|
+
function placeBlock(targetBuffer, blockData, targetWidth, destX, destY, blockSize, blockWidth, blockHeight) {
|
|
51
|
+
const actualWidth = blockWidth ?? blockSize;
|
|
52
|
+
const actualHeight = blockHeight ?? blockSize;
|
|
53
|
+
// Place pixels row by row
|
|
54
|
+
for (let y = 0; y < actualHeight; y++) {
|
|
55
|
+
for (let x = 0; x < actualWidth; x++) {
|
|
56
|
+
const sourceIndex = (y * actualWidth + x) * block_utils_1.RGBA_CHANNELS;
|
|
57
|
+
const targetIndex = ((destY + y) * targetWidth + (destX + x)) * block_utils_1.RGBA_CHANNELS;
|
|
58
|
+
// Ensure we don't write beyond buffer bounds
|
|
59
|
+
if (targetIndex + block_utils_1.RGBA_CHANNELS <= targetBuffer.length) {
|
|
60
|
+
// Copy RGBA channels
|
|
61
|
+
for (let channel = 0; channel < block_utils_1.RGBA_CHANNELS; channel++) {
|
|
62
|
+
targetBuffer[targetIndex + channel] =
|
|
63
|
+
blockData[sourceIndex + channel];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Calculate actual block dimensions at edge positions
|
|
71
|
+
* @param position Block position (x or y)
|
|
72
|
+
* @param blockSize Standard block size
|
|
73
|
+
* @param imageSize Image dimension (width or height)
|
|
74
|
+
* @param blockCount Total block count in that dimension
|
|
75
|
+
* @returns Actual block dimension
|
|
76
|
+
*/
|
|
77
|
+
function calculateActualBlockSize(position, blockSize, imageSize, blockCount) {
|
|
78
|
+
const isEdgeBlock = position === blockCount - 1;
|
|
79
|
+
return isEdgeBlock ? imageSize - position * blockSize : blockSize;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Calculate block dimensions considering edge cases
|
|
83
|
+
* @param position Block position
|
|
84
|
+
* @param blockSize Standard block size
|
|
85
|
+
* @param imageWidth Image width
|
|
86
|
+
* @param imageHeight Image height
|
|
87
|
+
* @param blockCounts Block counts
|
|
88
|
+
* @returns Block dimensions
|
|
89
|
+
*/
|
|
90
|
+
function calculateBlockDimensions(position, blockSize, imageWidth, imageHeight, blockCounts) {
|
|
91
|
+
return {
|
|
92
|
+
width: calculateActualBlockSize(position.x, blockSize, imageWidth, blockCounts.blockCountX),
|
|
93
|
+
height: calculateActualBlockSize(position.y, blockSize, imageHeight, blockCounts.blockCountY),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Split an RGBA image buffer into an array of blocks
|
|
98
|
+
* @param buffer Source image buffer (RGBA format)
|
|
99
|
+
* @param width Image width in pixels
|
|
100
|
+
* @param height Image height in pixels
|
|
101
|
+
* @param blockSize Block size in pixels
|
|
102
|
+
* @returns Array of block buffers
|
|
103
|
+
*/
|
|
104
|
+
function splitImageToBlocks(buffer, width, height, blockSize) {
|
|
105
|
+
const blocks = [];
|
|
106
|
+
const blockCounts = (0, block_utils_1.calculateBlockCounts)(width, height, blockSize);
|
|
107
|
+
// Process blocks row by row, left to right
|
|
108
|
+
for (let blockY = 0; blockY < blockCounts.blockCountY; blockY++) {
|
|
109
|
+
for (let blockX = 0; blockX < blockCounts.blockCountX; blockX++) {
|
|
110
|
+
const startX = blockX * blockSize;
|
|
111
|
+
const startY = blockY * blockSize;
|
|
112
|
+
const block = extractBlock(buffer, width, height, startX, startY, blockSize);
|
|
113
|
+
blocks.push(block);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return blocks;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Reconstruct an RGBA image buffer from an array of blocks
|
|
120
|
+
* @param blocks Array of block buffers
|
|
121
|
+
* @param width Target image width in pixels
|
|
122
|
+
* @param height Target image height in pixels
|
|
123
|
+
* @param blockSize Block size in pixels
|
|
124
|
+
* @returns Reconstructed image buffer
|
|
125
|
+
*/
|
|
126
|
+
function blocksToImageBuffer(blocks, width, height, blockSize) {
|
|
127
|
+
const imageBuffer = new Uint8Array(width * height * block_utils_1.RGBA_CHANNELS);
|
|
128
|
+
const blockCounts = (0, block_utils_1.calculateBlockCounts)(width, height, blockSize);
|
|
129
|
+
let blockIndex = 0;
|
|
130
|
+
// Place blocks row by row, left to right
|
|
131
|
+
for (let blockY = 0; blockY < blockCounts.blockCountY; blockY++) {
|
|
132
|
+
for (let blockX = 0; blockX < blockCounts.blockCountX; blockX++) {
|
|
133
|
+
if (blockIndex >= blocks.length) {
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
const position = { x: blockX, y: blockY };
|
|
137
|
+
const dimensions = calculateBlockDimensions(position, blockSize, width, height, blockCounts);
|
|
138
|
+
const destX = blockX * blockSize;
|
|
139
|
+
const destY = blockY * blockSize;
|
|
140
|
+
placeBlock(imageBuffer, blocks[blockIndex], width, destX, destY, blockSize, dimensions.width, dimensions.height);
|
|
141
|
+
blockIndex++;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return imageBuffer;
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=block-operations.js.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Position of a block in the image grid
|
|
3
|
+
*/
|
|
4
|
+
export interface BlockPosition {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Dimensions of a block
|
|
10
|
+
*/
|
|
11
|
+
export interface BlockDimensions {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Extract a block from an image buffer
|
|
17
|
+
* @param buffer Source image buffer (RGBA format)
|
|
18
|
+
* @param imageWidth Image width in pixels
|
|
19
|
+
* @param imageHeight Image height in pixels (optional, defaults to calculated height)
|
|
20
|
+
* @param startX Block top-left X coordinate
|
|
21
|
+
* @param startY Block top-left Y coordinate
|
|
22
|
+
* @param blockSize Maximum block size
|
|
23
|
+
* @returns Block buffer containing pixel data
|
|
24
|
+
*/
|
|
25
|
+
export declare function extractBlock(buffer: Uint8Array, imageWidth: number, imageHeight: number | undefined, startX: number, startY: number, blockSize: number): Uint8Array;
|
|
26
|
+
/**
|
|
27
|
+
* Place block data at the specified position in the target image buffer
|
|
28
|
+
* @param targetBuffer Target image buffer to place the block into
|
|
29
|
+
* @param blockData Block data to place
|
|
30
|
+
* @param targetWidth Target image width in pixels
|
|
31
|
+
* @param destX Destination X coordinate
|
|
32
|
+
* @param destY Destination Y coordinate
|
|
33
|
+
* @param blockSize Standard block size
|
|
34
|
+
* @param blockWidth Actual block width (optional, defaults to blockSize)
|
|
35
|
+
* @param blockHeight Actual block height (optional, defaults to blockSize)
|
|
36
|
+
*/
|
|
37
|
+
export declare function placeBlock(targetBuffer: Uint8Array, blockData: Uint8Array, targetWidth: number, destX: number, destY: number, blockSize: number, blockWidth?: number, blockHeight?: number): void;
|
|
38
|
+
/**
|
|
39
|
+
* Split an RGBA image buffer into an array of blocks
|
|
40
|
+
* @param buffer Source image buffer (RGBA format)
|
|
41
|
+
* @param width Image width in pixels
|
|
42
|
+
* @param height Image height in pixels
|
|
43
|
+
* @param blockSize Block size in pixels
|
|
44
|
+
* @returns Array of block buffers
|
|
45
|
+
*/
|
|
46
|
+
export declare function splitImageToBlocks(buffer: Uint8Array, width: number, height: number, blockSize: number): Uint8Array[];
|
|
47
|
+
/**
|
|
48
|
+
* Reconstruct an RGBA image buffer from an array of blocks
|
|
49
|
+
* @param blocks Array of block buffers
|
|
50
|
+
* @param width Target image width in pixels
|
|
51
|
+
* @param height Target image height in pixels
|
|
52
|
+
* @param blockSize Block size in pixels
|
|
53
|
+
* @returns Reconstructed image buffer
|
|
54
|
+
*/
|
|
55
|
+
export declare function blocksToImageBuffer(blocks: Uint8Array[], width: number, height: number, blockSize: number): Uint8Array;
|
|
56
|
+
//# sourceMappingURL=block-operations.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Position of a block in the image grid
|
|
3
|
+
*/
|
|
4
|
+
export interface BlockPosition {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Dimensions of a block
|
|
10
|
+
*/
|
|
11
|
+
export interface BlockDimensions {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Extract a block from an image buffer
|
|
17
|
+
* @param buffer Source image buffer (RGBA format)
|
|
18
|
+
* @param imageWidth Image width in pixels
|
|
19
|
+
* @param imageHeight Image height in pixels (optional, defaults to calculated height)
|
|
20
|
+
* @param startX Block top-left X coordinate
|
|
21
|
+
* @param startY Block top-left Y coordinate
|
|
22
|
+
* @param blockSize Maximum block size
|
|
23
|
+
* @returns Block buffer containing pixel data
|
|
24
|
+
*/
|
|
25
|
+
export declare function extractBlock(buffer: Uint8Array, imageWidth: number, imageHeight: number | undefined, startX: number, startY: number, blockSize: number): Uint8Array;
|
|
26
|
+
/**
|
|
27
|
+
* Place block data at the specified position in the target image buffer
|
|
28
|
+
* @param targetBuffer Target image buffer to place the block into
|
|
29
|
+
* @param blockData Block data to place
|
|
30
|
+
* @param targetWidth Target image width in pixels
|
|
31
|
+
* @param destX Destination X coordinate
|
|
32
|
+
* @param destY Destination Y coordinate
|
|
33
|
+
* @param blockSize Standard block size
|
|
34
|
+
* @param blockWidth Actual block width (optional, defaults to blockSize)
|
|
35
|
+
* @param blockHeight Actual block height (optional, defaults to blockSize)
|
|
36
|
+
*/
|
|
37
|
+
export declare function placeBlock(targetBuffer: Uint8Array, blockData: Uint8Array, targetWidth: number, destX: number, destY: number, blockSize: number, blockWidth?: number, blockHeight?: number): void;
|
|
38
|
+
/**
|
|
39
|
+
* Split an RGBA image buffer into an array of blocks
|
|
40
|
+
* @param buffer Source image buffer (RGBA format)
|
|
41
|
+
* @param width Image width in pixels
|
|
42
|
+
* @param height Image height in pixels
|
|
43
|
+
* @param blockSize Block size in pixels
|
|
44
|
+
* @returns Array of block buffers
|
|
45
|
+
*/
|
|
46
|
+
export declare function splitImageToBlocks(buffer: Uint8Array, width: number, height: number, blockSize: number): Uint8Array[];
|
|
47
|
+
/**
|
|
48
|
+
* Reconstruct an RGBA image buffer from an array of blocks
|
|
49
|
+
* @param blocks Array of block buffers
|
|
50
|
+
* @param width Target image width in pixels
|
|
51
|
+
* @param height Target image height in pixels
|
|
52
|
+
* @param blockSize Block size in pixels
|
|
53
|
+
* @returns Reconstructed image buffer
|
|
54
|
+
*/
|
|
55
|
+
export declare function blocksToImageBuffer(blocks: Uint8Array[], width: number, height: number, blockSize: number): Uint8Array;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block-operations.d.ts","sourceRoot":"","sources":["../src/block-operations.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,UAAU,EAClB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,UAAU,CAyBZ;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CACxB,YAAY,EAAE,UAAU,EACxB,SAAS,EAAE,UAAU,EACrB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,MAAM,EACnB,WAAW,CAAC,EAAE,MAAM,GACnB,IAAI,CAqBN;AAoDD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,UAAU,EAAE,CAwBd;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,UAAU,EAAE,EACpB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,UAAU,CAyCZ"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractBlock = extractBlock;
|
|
4
|
+
exports.placeBlock = placeBlock;
|
|
5
|
+
exports.splitImageToBlocks = splitImageToBlocks;
|
|
6
|
+
exports.blocksToImageBuffer = blocksToImageBuffer;
|
|
7
|
+
const block_utils_1 = require("./block-utils");
|
|
8
|
+
/**
|
|
9
|
+
* Extract a block from an image buffer
|
|
10
|
+
* @param buffer Source image buffer (RGBA format)
|
|
11
|
+
* @param imageWidth Image width in pixels
|
|
12
|
+
* @param imageHeight Image height in pixels (optional, defaults to calculated height)
|
|
13
|
+
* @param startX Block top-left X coordinate
|
|
14
|
+
* @param startY Block top-left Y coordinate
|
|
15
|
+
* @param blockSize Maximum block size
|
|
16
|
+
* @returns Block buffer containing pixel data
|
|
17
|
+
*/
|
|
18
|
+
function extractBlock(buffer, imageWidth, imageHeight, startX, startY, blockSize) {
|
|
19
|
+
// Calculate actual block dimensions considering image boundaries
|
|
20
|
+
const blockWidth = Math.min(blockSize, imageWidth - startX);
|
|
21
|
+
const blockHeight = imageHeight !== undefined
|
|
22
|
+
? Math.min(blockSize, imageHeight - startY)
|
|
23
|
+
: blockSize;
|
|
24
|
+
const blockData = new Uint8Array(blockSize * blockSize * block_utils_1.RGBA_CHANNELS);
|
|
25
|
+
// Extract pixel data row by row
|
|
26
|
+
for (let y = 0; y < blockHeight; y++) {
|
|
27
|
+
for (let x = 0; x < blockWidth; x++) {
|
|
28
|
+
const pixelX = startX + x;
|
|
29
|
+
const pixelY = startY + y;
|
|
30
|
+
const pixelIndex = (pixelY * imageWidth + pixelX) * block_utils_1.RGBA_CHANNELS;
|
|
31
|
+
const blockIndex = (y * blockSize + x) * block_utils_1.RGBA_CHANNELS;
|
|
32
|
+
// Copy RGBA channels
|
|
33
|
+
for (let channel = 0; channel < block_utils_1.RGBA_CHANNELS; channel++) {
|
|
34
|
+
blockData[blockIndex + channel] = buffer[pixelIndex + channel] || 0;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return blockData;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Place block data at the specified position in the target image buffer
|
|
42
|
+
* @param targetBuffer Target image buffer to place the block into
|
|
43
|
+
* @param blockData Block data to place
|
|
44
|
+
* @param targetWidth Target image width in pixels
|
|
45
|
+
* @param destX Destination X coordinate
|
|
46
|
+
* @param destY Destination Y coordinate
|
|
47
|
+
* @param blockSize Standard block size
|
|
48
|
+
* @param blockWidth Actual block width (optional, defaults to blockSize)
|
|
49
|
+
* @param blockHeight Actual block height (optional, defaults to blockSize)
|
|
50
|
+
*/
|
|
51
|
+
function placeBlock(targetBuffer, blockData, targetWidth, destX, destY, blockSize, blockWidth, blockHeight) {
|
|
52
|
+
const actualWidth = blockWidth ?? blockSize;
|
|
53
|
+
const actualHeight = blockHeight ?? blockSize;
|
|
54
|
+
// Place pixels row by row
|
|
55
|
+
for (let y = 0; y < actualHeight; y++) {
|
|
56
|
+
for (let x = 0; x < actualWidth; x++) {
|
|
57
|
+
const sourceIndex = (y * blockSize + x) * block_utils_1.RGBA_CHANNELS;
|
|
58
|
+
const targetIndex = ((destY + y) * targetWidth + (destX + x)) * block_utils_1.RGBA_CHANNELS;
|
|
59
|
+
// Ensure we don't write beyond buffer bounds
|
|
60
|
+
if (targetIndex + block_utils_1.RGBA_CHANNELS <= targetBuffer.length) {
|
|
61
|
+
// Copy RGBA channels
|
|
62
|
+
for (let channel = 0; channel < block_utils_1.RGBA_CHANNELS; channel++) {
|
|
63
|
+
targetBuffer[targetIndex + channel] =
|
|
64
|
+
blockData[sourceIndex + channel];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Calculate actual block dimensions at edge positions
|
|
72
|
+
* @param position Block position (x or y)
|
|
73
|
+
* @param blockSize Standard block size
|
|
74
|
+
* @param imageSize Image dimension (width or height)
|
|
75
|
+
* @param blockCount Total block count in that dimension
|
|
76
|
+
* @returns Actual block dimension
|
|
77
|
+
*/
|
|
78
|
+
function calculateActualBlockSize(position, blockSize, imageSize, blockCount) {
|
|
79
|
+
const isEdgeBlock = position === blockCount - 1;
|
|
80
|
+
return isEdgeBlock ? imageSize - position * blockSize : blockSize;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Calculate block dimensions considering edge cases
|
|
84
|
+
* @param position Block position
|
|
85
|
+
* @param blockSize Standard block size
|
|
86
|
+
* @param imageWidth Image width
|
|
87
|
+
* @param imageHeight Image height
|
|
88
|
+
* @param blockCounts Block counts
|
|
89
|
+
* @returns Block dimensions
|
|
90
|
+
*/
|
|
91
|
+
function calculateBlockDimensions(position, blockSize, imageWidth, imageHeight, blockCounts) {
|
|
92
|
+
return {
|
|
93
|
+
width: calculateActualBlockSize(position.x, blockSize, imageWidth, blockCounts.blockCountX),
|
|
94
|
+
height: calculateActualBlockSize(position.y, blockSize, imageHeight, blockCounts.blockCountY),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Split an RGBA image buffer into an array of blocks
|
|
99
|
+
* @param buffer Source image buffer (RGBA format)
|
|
100
|
+
* @param width Image width in pixels
|
|
101
|
+
* @param height Image height in pixels
|
|
102
|
+
* @param blockSize Block size in pixels
|
|
103
|
+
* @returns Array of block buffers
|
|
104
|
+
*/
|
|
105
|
+
function splitImageToBlocks(buffer, width, height, blockSize) {
|
|
106
|
+
const blocks = [];
|
|
107
|
+
const blockCounts = (0, block_utils_1.calculateBlockCounts)(width, height, blockSize);
|
|
108
|
+
// Process blocks row by row, left to right
|
|
109
|
+
for (let blockY = 0; blockY < blockCounts.blockCountY; blockY++) {
|
|
110
|
+
for (let blockX = 0; blockX < blockCounts.blockCountX; blockX++) {
|
|
111
|
+
const startX = blockX * blockSize;
|
|
112
|
+
const startY = blockY * blockSize;
|
|
113
|
+
const block = extractBlock(buffer, width, height, startX, startY, blockSize);
|
|
114
|
+
blocks.push(block);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return blocks;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Reconstruct an RGBA image buffer from an array of blocks
|
|
121
|
+
* @param blocks Array of block buffers
|
|
122
|
+
* @param width Target image width in pixels
|
|
123
|
+
* @param height Target image height in pixels
|
|
124
|
+
* @param blockSize Block size in pixels
|
|
125
|
+
* @returns Reconstructed image buffer
|
|
126
|
+
*/
|
|
127
|
+
function blocksToImageBuffer(blocks, width, height, blockSize) {
|
|
128
|
+
const imageBuffer = new Uint8Array(width * height * block_utils_1.RGBA_CHANNELS);
|
|
129
|
+
const blockCounts = (0, block_utils_1.calculateBlockCounts)(width, height, blockSize);
|
|
130
|
+
let blockIndex = 0;
|
|
131
|
+
// Place blocks row by row, left to right
|
|
132
|
+
for (let blockY = 0; blockY < blockCounts.blockCountY; blockY++) {
|
|
133
|
+
for (let blockX = 0; blockX < blockCounts.blockCountX; blockX++) {
|
|
134
|
+
if (blockIndex >= blocks.length) {
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
const position = { x: blockX, y: blockY };
|
|
138
|
+
const dimensions = calculateBlockDimensions(position, blockSize, width, height, blockCounts);
|
|
139
|
+
const destX = blockX * blockSize;
|
|
140
|
+
const destY = blockY * blockSize;
|
|
141
|
+
placeBlock(imageBuffer, blocks[blockIndex], width, destX, destY, blockSize, dimensions.width, dimensions.height);
|
|
142
|
+
blockIndex++;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return imageBuffer;
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=block-operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block-operations.js","sourceRoot":"","sources":["../src/block-operations.ts"],"names":[],"mappings":";;AAgCA,oCAiCC;AAaD,gCA8BC;AA4DD,gDA6BC;AAUD,kDA8CC;AA7PD,+CAIuB;AAkBvB;;;;;;;;;GASG;AACH,SAAgB,YAAY,CAC1B,MAAkB,EAClB,UAAkB,EAClB,WAA+B,EAC/B,MAAc,EACd,MAAc,EACd,SAAiB;IAEjB,iEAAiE;IACjE,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,UAAU,GAAG,MAAM,CAAC,CAAC;IAC5D,MAAM,WAAW,GACf,WAAW,KAAK,SAAS;QACvB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,WAAW,GAAG,MAAM,CAAC;QAC3C,CAAC,CAAC,SAAS,CAAC;IAEhB,MAAM,SAAS,GAAG,IAAI,UAAU,CAAC,SAAS,GAAG,SAAS,GAAG,2BAAa,CAAC,CAAC;IAExE,gCAAgC;IAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;YACpC,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC;YAC1B,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC;YAC1B,MAAM,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,CAAC,UAAU,CAAC,EAClB,KAAK,EACL,KAAK,EACL,KAAK,EACL,SAAS,EACT,UAAU,CAAC,KAAK,EAChB,UAAU,CAAC,MAAM,CAClB,CAAC;YAEF,UAAU,EAAE,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RGBA_CHANNELS = void 0;
|
|
4
|
+
exports.calculateBlockCounts = calculateBlockCounts;
|
|
5
|
+
exports.calculateBlockRange = calculateBlockRange;
|
|
6
|
+
exports.calculateBlockCountsForCrossImages = calculateBlockCountsForCrossImages;
|
|
7
|
+
exports.calculateBlockCountsPerImage = calculateBlockCountsPerImage;
|
|
8
|
+
exports.calculateTotalBlocks = calculateTotalBlocks;
|
|
9
|
+
/**
|
|
10
|
+
* Number of channels in RGBA format
|
|
11
|
+
*/
|
|
12
|
+
exports.RGBA_CHANNELS = 4;
|
|
13
|
+
/**
|
|
14
|
+
* Calculate block counts for width and height
|
|
15
|
+
* @param width Image width
|
|
16
|
+
* @param height Image height
|
|
17
|
+
* @param blockSize Block size
|
|
18
|
+
* @returns Object with blockCountX and blockCountY
|
|
19
|
+
*/
|
|
20
|
+
function calculateBlockCounts(width, height, blockSize) {
|
|
21
|
+
return {
|
|
22
|
+
blockCountX: Math.ceil(width / blockSize),
|
|
23
|
+
blockCountY: Math.ceil(height / blockSize),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Calculate the range of blocks for a specific image index
|
|
28
|
+
* @param blockCounts Array of block counts per image
|
|
29
|
+
* @param targetIndex Target image index
|
|
30
|
+
* @returns Object with start and end indices
|
|
31
|
+
*/
|
|
32
|
+
function calculateBlockRange(blockCounts, targetIndex) {
|
|
33
|
+
const start = blockCounts
|
|
34
|
+
.slice(0, targetIndex)
|
|
35
|
+
.reduce((sum, count) => sum + count, 0);
|
|
36
|
+
const end = start + blockCounts[targetIndex];
|
|
37
|
+
return { start, end };
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Calculate how many blocks each fragment should contain for cross-image shuffling
|
|
41
|
+
* @param totalBlocks Total number of blocks to distribute
|
|
42
|
+
* @param fragmentCount Number of fragments to create
|
|
43
|
+
* @returns Array of block counts for each fragment
|
|
44
|
+
*/
|
|
45
|
+
function calculateBlockCountsForCrossImages(totalBlocks, fragmentCount) {
|
|
46
|
+
if (fragmentCount <= 0) {
|
|
47
|
+
throw new Error("Fragment count must be greater than 0");
|
|
48
|
+
}
|
|
49
|
+
if (totalBlocks <= 0) {
|
|
50
|
+
return new Array(fragmentCount).fill(0);
|
|
51
|
+
}
|
|
52
|
+
const baseBlocksPerFragment = Math.ceil(totalBlocks / fragmentCount);
|
|
53
|
+
const fragmentBlockCounts = [];
|
|
54
|
+
let remainingBlocks = totalBlocks;
|
|
55
|
+
// Distribute blocks, ensuring no fragment gets more blocks than available
|
|
56
|
+
for (let i = 0; i < fragmentCount; i++) {
|
|
57
|
+
const blocksForThisFragment = Math.min(baseBlocksPerFragment, remainingBlocks);
|
|
58
|
+
fragmentBlockCounts.push(blocksForThisFragment);
|
|
59
|
+
remainingBlocks -= blocksForThisFragment;
|
|
60
|
+
// If no blocks remain, fill remaining fragments with 0
|
|
61
|
+
if (remainingBlocks <= 0) {
|
|
62
|
+
for (let j = i + 1; j < fragmentCount; j++) {
|
|
63
|
+
fragmentBlockCounts.push(0);
|
|
64
|
+
}
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return fragmentBlockCounts;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Calculate block counts for each image
|
|
72
|
+
* @param images Array of ImageInfo objects
|
|
73
|
+
* @returns Array of block counts per image (x * y)
|
|
74
|
+
*/
|
|
75
|
+
function calculateBlockCountsPerImage(images) {
|
|
76
|
+
return images.map((info) => info.x * info.y);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Calculate total number of blocks from images
|
|
80
|
+
* @param images Array of ImageInfo objects
|
|
81
|
+
* @returns Total block count
|
|
82
|
+
*/
|
|
83
|
+
function calculateTotalBlocks(images) {
|
|
84
|
+
return images.reduce((total, image) => total + image.x * image.y, 0);
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=block-utils.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ImageInfo } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Number of channels in RGBA format
|
|
4
|
+
*/
|
|
5
|
+
export declare const RGBA_CHANNELS = 4;
|
|
6
|
+
export interface BlockCounts {
|
|
7
|
+
blockCountX: number;
|
|
8
|
+
blockCountY: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Calculate block counts for width and height
|
|
12
|
+
* @param width Image width
|
|
13
|
+
* @param height Image height
|
|
14
|
+
* @param blockSize Block size
|
|
15
|
+
* @returns Object with blockCountX and blockCountY
|
|
16
|
+
*/
|
|
17
|
+
export declare function calculateBlockCounts(width: number, height: number, blockSize: number): BlockCounts;
|
|
18
|
+
/**
|
|
19
|
+
* Calculate the range of blocks for a specific image index
|
|
20
|
+
* @param blockCounts Array of block counts per image
|
|
21
|
+
* @param targetIndex Target image index
|
|
22
|
+
* @returns Object with start and end indices
|
|
23
|
+
*/
|
|
24
|
+
export declare function calculateBlockRange(blockCounts: number[], targetIndex: number): {
|
|
25
|
+
start: number;
|
|
26
|
+
end: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Calculate how many blocks each fragment should contain for cross-image shuffling
|
|
30
|
+
* @param totalBlocks Total number of blocks to distribute
|
|
31
|
+
* @param fragmentCount Number of fragments to create
|
|
32
|
+
* @returns Array of block counts for each fragment
|
|
33
|
+
*/
|
|
34
|
+
export declare function calculateBlockCountsForCrossImages(totalBlocks: number, fragmentCount: number): number[];
|
|
35
|
+
/**
|
|
36
|
+
* Calculate block counts for each image
|
|
37
|
+
* @param images Array of ImageInfo objects
|
|
38
|
+
* @returns Array of block counts per image (x * y)
|
|
39
|
+
*/
|
|
40
|
+
export declare function calculateBlockCountsPerImage(images: ImageInfo[]): number[];
|
|
41
|
+
/**
|
|
42
|
+
* Calculate total number of blocks from images
|
|
43
|
+
* @param images Array of ImageInfo objects
|
|
44
|
+
* @returns Total block count
|
|
45
|
+
*/
|
|
46
|
+
export declare function calculateTotalBlocks(images: ImageInfo[]): number;
|
|
47
|
+
//# sourceMappingURL=block-utils.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ImageInfo } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Number of channels in RGBA format
|
|
4
|
+
*/
|
|
5
|
+
export declare const RGBA_CHANNELS = 4;
|
|
6
|
+
export interface BlockCounts {
|
|
7
|
+
blockCountX: number;
|
|
8
|
+
blockCountY: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Calculate block counts for width and height
|
|
12
|
+
* @param width Image width
|
|
13
|
+
* @param height Image height
|
|
14
|
+
* @param blockSize Block size
|
|
15
|
+
* @returns Object with blockCountX and blockCountY
|
|
16
|
+
*/
|
|
17
|
+
export declare function calculateBlockCounts(width: number, height: number, blockSize: number): BlockCounts;
|
|
18
|
+
/**
|
|
19
|
+
* Calculate the range of blocks for a specific image index
|
|
20
|
+
* @param blockCounts Array of block counts per image
|
|
21
|
+
* @param targetIndex Target image index
|
|
22
|
+
* @returns Object with start and end indices
|
|
23
|
+
*/
|
|
24
|
+
export declare function calculateBlockRange(blockCounts: number[], targetIndex: number): {
|
|
25
|
+
start: number;
|
|
26
|
+
end: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Calculate how many blocks each fragment should contain for cross-image shuffling
|
|
30
|
+
* @param totalBlocks Total number of blocks to distribute
|
|
31
|
+
* @param fragmentCount Number of fragments to create
|
|
32
|
+
* @returns Array of block counts for each fragment
|
|
33
|
+
*/
|
|
34
|
+
export declare function calculateBlockCountsForCrossImages(totalBlocks: number, fragmentCount: number): number[];
|
|
35
|
+
/**
|
|
36
|
+
* Calculate block counts for each image
|
|
37
|
+
* @param images Array of ImageInfo objects
|
|
38
|
+
* @param blockSize Block size
|
|
39
|
+
* @returns Array of block counts per image (x * y)
|
|
40
|
+
*/
|
|
41
|
+
export declare function calculateBlockCountsPerImage(images: ImageInfo[], blockSize: number): number[];
|
|
42
|
+
/**
|
|
43
|
+
* Calculate total number of blocks from images
|
|
44
|
+
* @param images Array of ImageInfo objects
|
|
45
|
+
* @param blockSize Block size
|
|
46
|
+
* @returns Total block count
|
|
47
|
+
*/
|
|
48
|
+
export declare function calculateTotalBlocks(images: ImageInfo[], blockSize: number): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block-utils.d.ts","sourceRoot":"","sources":["../src/block-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC;;GAEG;AACH,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,WAAW,CAKb;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,EAAE,EACrB,WAAW,EAAE,MAAM,GAClB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAOhC;AAED;;;;;GAKG;AACH,wBAAgB,kCAAkC,CAChD,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,GACpB,MAAM,EAAE,CAgCV;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,CAE1E;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAEhE"}
|