pixel-data-js 0.32.0 → 0.33.0
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/index.prod.cjs +51 -27
- package/dist/index.prod.cjs.map +1 -1
- package/dist/index.prod.d.ts +13 -4
- package/dist/index.prod.js +50 -27
- package/dist/index.prod.js.map +1 -1
- package/package.json +1 -1
- package/src/ImageData/copyImageData.ts +4 -2
- package/src/ImageData/extractImageData.ts +1 -2
- package/src/ImageData/extractImageDataBuffer.ts +2 -4
- package/src/ImageData/writeImageData.ts +4 -5
- package/src/ImageData/writeImageDataBuffer.ts +2 -4
- package/src/PixelData/extractPixelDataBuffer.ts +2 -4
- package/src/PixelData/fillPixelData.ts +1 -2
- package/src/PixelData/fillPixelDataFast.ts +1 -2
- package/src/PixelData/writePixelData.ts +55 -0
- package/src/index.ts +1 -0
package/dist/index.prod.d.ts
CHANGED
|
@@ -1268,7 +1268,7 @@ declare const mutatorInvert: (writer: PixelWriter<any>, deps?: Deps) => {
|
|
|
1268
1268
|
invert(opts?: PixelMutateOptions): boolean;
|
|
1269
1269
|
};
|
|
1270
1270
|
|
|
1271
|
-
declare function copyImageData(
|
|
1271
|
+
declare function copyImageData(source: ImageDataLike): ImageData;
|
|
1272
1272
|
declare function copyImageDataLike({ data, width, height }: ImageDataLike): ImageDataLike;
|
|
1273
1273
|
|
|
1274
1274
|
/**
|
|
@@ -1426,14 +1426,14 @@ declare function uInt32ArrayToImageData(data: Uint32Array, width: number, height
|
|
|
1426
1426
|
declare function uInt32ArrayToImageDataLike(data: Uint32Array, width: number, height: number): ImageDataLike;
|
|
1427
1427
|
|
|
1428
1428
|
/**
|
|
1429
|
-
* Writes image data from a source to a target
|
|
1429
|
+
* Writes image data from a source to a target.
|
|
1430
1430
|
*
|
|
1431
1431
|
* @param target - The destination ImageData to write to.
|
|
1432
1432
|
* @param source - The source ImageData to read from.
|
|
1433
1433
|
* @param x - The x-coordinate in the target where drawing starts.
|
|
1434
1434
|
* @param y - The y-coordinate in the target where drawing starts.
|
|
1435
1435
|
*/
|
|
1436
|
-
declare function writeImageData(target: ImageData, source: ImageData, x
|
|
1436
|
+
declare function writeImageData(target: ImageData, source: ImageData, x?: number, y?: number): void;
|
|
1437
1437
|
|
|
1438
1438
|
/**
|
|
1439
1439
|
* Copies a pixel buffer into a specific region of an {@link ImageData} object.
|
|
@@ -1939,6 +1939,15 @@ declare function writePixelDataBuffer(target: PixelData32, data: Uint32Array, x:
|
|
|
1939
1939
|
*/
|
|
1940
1940
|
declare function writePaintBufferToPixelData(target: PixelData, paintBuffer: ColorPaintBuffer, writePixelDataBufferFn?: typeof writePixelDataBuffer): void;
|
|
1941
1941
|
|
|
1942
|
+
/**
|
|
1943
|
+
* Writes PixelData from a source to a target.
|
|
1944
|
+
* @param target - The destination to write to.
|
|
1945
|
+
* @param source - The source to read from.
|
|
1946
|
+
* @param x - The x-coordinate in the target where drawing starts.
|
|
1947
|
+
* @param y - The y-coordinate in the target where drawing starts.
|
|
1948
|
+
*/
|
|
1949
|
+
declare function writePixelData(target: PixelData32, source: PixelData32, x?: number, y?: number): void;
|
|
1950
|
+
|
|
1942
1951
|
declare function getRectsBounds<T extends Rect>(rects: T[]): T;
|
|
1943
1952
|
|
|
1944
1953
|
/**
|
|
@@ -1964,4 +1973,4 @@ declare const makeBinaryMaskTile: TileFactory<BinaryMaskTile>;
|
|
|
1964
1973
|
|
|
1965
1974
|
declare function makePixelTile(id: number, tx: number, ty: number, tileSize: number, tileArea: number): PixelTile;
|
|
1966
1975
|
|
|
1967
|
-
export { type AlphaMask, AlphaMaskPaintBuffer, type AlphaMaskPaintBufferCanvasRenderer, type AlphaMaskPaintBufferManager, type AlphaMaskRect, type AlphaMaskTile, type ApplyMaskToPixelDataOptions, BASE_FAST_BLEND_MODE_FUNCTIONS, BASE_PERFECT_BLEND_MODE_FUNCTIONS, type Base64EncodedUInt8Array, BaseBlendMode, type BaseBlendModes, type BaseMask, type BasePixelBlendOptions, type BatchedQueue, type BatchedQueueFn, type BinaryMask, BinaryMaskPaintBuffer, type BinaryMaskPaintBufferCanvasRenderer, type BinaryMaskPaintBufferManager, type BinaryMaskRect, type BinaryMaskTile, type BlendColor32, type BlendModeRegistry, CANVAS_COMPOSITE_MAP, type CanvasBlendModeIndex, type CanvasCompositeOperation, type CanvasContext, type CanvasFrameRenderer, type CanvasObjectFactory, type CanvasPixelDataRenderer, type Color32, type ColorBlendMaskOptions, type ColorBlendOptions, ColorPaintBuffer, type ColorPaintBufferCanvasRenderer, type ColorPaintBufferManager, type DidChangeFn, type DrawPixelLayer, type DrawScreenLayer, _errors as ERRORS, type FloodFillResult, type HistoryAction, type HistoryActionFactory, HistoryManager, type HistoryMutator, type ImageDataLike, type IndexedImage, type InvertMask, type Mask, type MaskOffset, type MaskRect, MaskType, type MergeAlphaMasksOptions, type MutableAlphaMask, type MutableBinaryMask, type MutableMask, type MutablePixelData32, type NullableBinaryMaskRect, type NullableMaskRect, type PaintAlphaMask, type PaintBinaryMask, type PaintCursorRenderer, type PaintMask, PaintMaskOutline, PixelAccumulator, type PixelBlendMaskOptions, type PixelBlendOptions, type PixelCanvas, type PixelData, type PixelData32, PixelEngineConfig, type PixelMutateOptions, type PixelPatchTiles, type PixelRect, type PixelTile, PixelWriter, type PixelWriterOptions, type RGBA, type Rect, type RequiredBlendModes, type ReusableCanvas, type ReusableCanvasFactory, type ReusableImageData, type ReusablePixelData, type SerializedImageData, type Tile, type TileFactory, TilePool, TileType, UnsupportedFormatError, _macro_imageDataToUint32Array, applyAlphaMaskToPixelData, applyBinaryMaskToAlphaMask, applyBinaryMaskToPixelData, applyMaskToPixelData, applyPatchTiles, base64DecodeArrayBuffer, base64EncodeArrayBuffer, blendColorPixelData, blendColorPixelDataAlphaMask, blendColorPixelDataBinaryMask, blendColorPixelDataMask, blendColorPixelDataPaintAlphaMask, blendColorPixelDataPaintBinaryMask, blendColorPixelDataPaintMask, blendPixel, blendPixelData, blendPixelDataAlphaMask, blendPixelDataBinaryMask, blendPixelDataMask, blendPixelDataPaintBuffer, clearPixelDataFast, color32ToCssRGBA, color32ToHex, colorBurnFast, colorBurnPerfect, colorDistance, colorDodgeFast, colorDodgePerfect, commitColorPaintBuffer, commitMaskPaintBuffer, copyImageData, copyImageDataLike, copyMask, copyPixelData, darkenFast, darkenPerfect, darkerFast, darkerPerfect, deserializeImageData, deserializeNullableImageData, deserializeRawImageData, destinationAtopFast, destinationAtopPerfect, destinationInFast, destinationInPerfect, destinationOutFast, destinationOutPerfect, destinationOverFast, destinationOverPerfect, differenceFast, differencePerfect, divideFast, dividePerfect, eachTileInBounds, exclusionFast, exclusionPerfect, extractImageData, extractImageDataBuffer, extractMask, extractMaskBuffer, extractPixelData, extractPixelDataBuffer, fileInputChangeToImageData, fileToImageData, fillPixelData, fillPixelDataBinaryMask, fillPixelDataFast, floodFillSelection, forEachLinePoint, getImageDataFromClipboard, getIndexedImageColor, getIndexedImageColorCounts, getRectsBounds, getSupportedPixelFormats, hardLightFast, hardLightPerfect, hardMixFast, hardMixPerfect, imageDataToAlphaMaskBuffer, imageDataToDataUrl, imageDataToImgBlob, imageDataToUint32Array, imgBlobToImageData, indexedImageToAverageColor, indexedImageToImageData, invertAlphaMask, invertBinaryMask, invertImageData, invertPixelData, lerpColor32, lerpColor32Fast, lightenFast, lightenPerfect, lighterFast, lighterPerfect, linearBurnFast, linearBurnPerfect, linearDodgeFast, linearDodgePerfect, linearLightFast, linearLightPerfect, makeAlphaMask, makeAlphaMaskPaintBufferCanvasRenderer, makeAlphaMaskPaintBufferCommitter, makeAlphaMaskPaintBufferManager, makeAlphaMaskTile, makeBatchedQueue, makeBinaryMask, makeBinaryMaskFromAlphaMask, makeBinaryMaskOutline, makeBinaryMaskPaintBufferCanvasRenderer, makeBinaryMaskPaintBufferCommitter, makeBinaryMaskPaintBufferManager, makeBinaryMaskTile, makeBlendModeRegistry, makeCanvasFrameRenderer, makeCanvasPixelDataRenderer, makeCircleBinaryMaskOutline, makeCirclePaintAlphaMask, makeCirclePaintBinaryMask, makeColorPaintBufferCanvasRenderer, makeColorPaintBufferCommitter, makeColorPaintBufferManager, makeFastBlendModeRegistry, makeFullPixelMutator, makeHistoryAction, makeImageDataLike, makeIndexedImage, makeIndexedImageFromImageData, makeIndexedImageFromImageDataRaw, makePaintAlphaMask, makePaintBinaryMask, makePaintCursorRenderer, makePerfectBlendModeRegistry, makePixelCanvas, makePixelData, makePixelTile, makeRectBinaryMaskOutline, makeRectFalloffPaintAlphaMask, makeRenderQueue, makeReusableCanvas, makeReusableImageData, makeReusableOffscreenCanvas, makeReusablePixelData, merge2BinaryMaskRects, mergeAlphaMasks, mergeBinaryMaskRects, mergeBinaryMasks, multiplyFast, multiplyPerfect, mutatorApplyAlphaMask, mutatorApplyBinaryMask, mutatorApplyMask, mutatorBlendAlphaMask, mutatorBlendBinaryMask, mutatorBlendColor, mutatorBlendColorPaintAlphaMask, mutatorBlendColorPaintBinaryMask, mutatorBlendColorPaintMask, mutatorBlendColorPaintRect, mutatorBlendMask, mutatorBlendPixel, mutatorBlendPixelData, mutatorClear, mutatorFill, mutatorFillBinaryMask, mutatorFillRect, mutatorInvert, overlayFast, overlayPerfect, overwriteBase, overwriteFast, overwritePerfect, packColor, packRGBA, pinLightFast, pinLightPerfect, pixelDataToAlphaMask, reflectPixelDataHorizontal, reflectPixelDataVertical, resampleImageData, resampleIndexedImage, resamplePixelData, resamplePixelDataInPlace, resampleUint32Array, resizeImageData, resizePixelData, rotatePixelData, screenFast, screenPerfect, serializeImageData, serializeNullableImageData, setMaskData, setPixelData, softLightFast, softLightPerfect, sourceAtopFast, sourceAtopPerfect, sourceInFast, sourceInPerfect, sourceOutFast, sourceOutPerfect, sourceOverFast, sourceOverPerfect, subtractBinaryMaskRects, subtractFast, subtractPerfect, toBlendModeIndexAndName, trimMaskRectBounds, trimRectBounds, uInt32ArrayToImageData, uInt32ArrayToImageDataLike, uInt32ArrayToPixelData, unpackAlpha, unpackBlue, unpackColor, unpackColorTo, unpackGreen, unpackRed, vividLightFast, vividLightPerfect, writeImageData, writeImageDataBuffer, writeImageDataToClipboard, writeImgBlobToClipboard, writePaintBufferToPixelData, writePixelDataBuffer, xorFast, xorPerfect };
|
|
1976
|
+
export { type AlphaMask, AlphaMaskPaintBuffer, type AlphaMaskPaintBufferCanvasRenderer, type AlphaMaskPaintBufferManager, type AlphaMaskRect, type AlphaMaskTile, type ApplyMaskToPixelDataOptions, BASE_FAST_BLEND_MODE_FUNCTIONS, BASE_PERFECT_BLEND_MODE_FUNCTIONS, type Base64EncodedUInt8Array, BaseBlendMode, type BaseBlendModes, type BaseMask, type BasePixelBlendOptions, type BatchedQueue, type BatchedQueueFn, type BinaryMask, BinaryMaskPaintBuffer, type BinaryMaskPaintBufferCanvasRenderer, type BinaryMaskPaintBufferManager, type BinaryMaskRect, type BinaryMaskTile, type BlendColor32, type BlendModeRegistry, CANVAS_COMPOSITE_MAP, type CanvasBlendModeIndex, type CanvasCompositeOperation, type CanvasContext, type CanvasFrameRenderer, type CanvasObjectFactory, type CanvasPixelDataRenderer, type Color32, type ColorBlendMaskOptions, type ColorBlendOptions, ColorPaintBuffer, type ColorPaintBufferCanvasRenderer, type ColorPaintBufferManager, type DidChangeFn, type DrawPixelLayer, type DrawScreenLayer, _errors as ERRORS, type FloodFillResult, type HistoryAction, type HistoryActionFactory, HistoryManager, type HistoryMutator, type ImageDataLike, type IndexedImage, type InvertMask, type Mask, type MaskOffset, type MaskRect, MaskType, type MergeAlphaMasksOptions, type MutableAlphaMask, type MutableBinaryMask, type MutableMask, type MutablePixelData32, type NullableBinaryMaskRect, type NullableMaskRect, type PaintAlphaMask, type PaintBinaryMask, type PaintCursorRenderer, type PaintMask, PaintMaskOutline, PixelAccumulator, type PixelBlendMaskOptions, type PixelBlendOptions, type PixelCanvas, type PixelData, type PixelData32, PixelEngineConfig, type PixelMutateOptions, type PixelPatchTiles, type PixelRect, type PixelTile, PixelWriter, type PixelWriterOptions, type RGBA, type Rect, type RequiredBlendModes, type ReusableCanvas, type ReusableCanvasFactory, type ReusableImageData, type ReusablePixelData, type SerializedImageData, type Tile, type TileFactory, TilePool, TileType, UnsupportedFormatError, _macro_imageDataToUint32Array, applyAlphaMaskToPixelData, applyBinaryMaskToAlphaMask, applyBinaryMaskToPixelData, applyMaskToPixelData, applyPatchTiles, base64DecodeArrayBuffer, base64EncodeArrayBuffer, blendColorPixelData, blendColorPixelDataAlphaMask, blendColorPixelDataBinaryMask, blendColorPixelDataMask, blendColorPixelDataPaintAlphaMask, blendColorPixelDataPaintBinaryMask, blendColorPixelDataPaintMask, blendPixel, blendPixelData, blendPixelDataAlphaMask, blendPixelDataBinaryMask, blendPixelDataMask, blendPixelDataPaintBuffer, clearPixelDataFast, color32ToCssRGBA, color32ToHex, colorBurnFast, colorBurnPerfect, colorDistance, colorDodgeFast, colorDodgePerfect, commitColorPaintBuffer, commitMaskPaintBuffer, copyImageData, copyImageDataLike, copyMask, copyPixelData, darkenFast, darkenPerfect, darkerFast, darkerPerfect, deserializeImageData, deserializeNullableImageData, deserializeRawImageData, destinationAtopFast, destinationAtopPerfect, destinationInFast, destinationInPerfect, destinationOutFast, destinationOutPerfect, destinationOverFast, destinationOverPerfect, differenceFast, differencePerfect, divideFast, dividePerfect, eachTileInBounds, exclusionFast, exclusionPerfect, extractImageData, extractImageDataBuffer, extractMask, extractMaskBuffer, extractPixelData, extractPixelDataBuffer, fileInputChangeToImageData, fileToImageData, fillPixelData, fillPixelDataBinaryMask, fillPixelDataFast, floodFillSelection, forEachLinePoint, getImageDataFromClipboard, getIndexedImageColor, getIndexedImageColorCounts, getRectsBounds, getSupportedPixelFormats, hardLightFast, hardLightPerfect, hardMixFast, hardMixPerfect, imageDataToAlphaMaskBuffer, imageDataToDataUrl, imageDataToImgBlob, imageDataToUint32Array, imgBlobToImageData, indexedImageToAverageColor, indexedImageToImageData, invertAlphaMask, invertBinaryMask, invertImageData, invertPixelData, lerpColor32, lerpColor32Fast, lightenFast, lightenPerfect, lighterFast, lighterPerfect, linearBurnFast, linearBurnPerfect, linearDodgeFast, linearDodgePerfect, linearLightFast, linearLightPerfect, makeAlphaMask, makeAlphaMaskPaintBufferCanvasRenderer, makeAlphaMaskPaintBufferCommitter, makeAlphaMaskPaintBufferManager, makeAlphaMaskTile, makeBatchedQueue, makeBinaryMask, makeBinaryMaskFromAlphaMask, makeBinaryMaskOutline, makeBinaryMaskPaintBufferCanvasRenderer, makeBinaryMaskPaintBufferCommitter, makeBinaryMaskPaintBufferManager, makeBinaryMaskTile, makeBlendModeRegistry, makeCanvasFrameRenderer, makeCanvasPixelDataRenderer, makeCircleBinaryMaskOutline, makeCirclePaintAlphaMask, makeCirclePaintBinaryMask, makeColorPaintBufferCanvasRenderer, makeColorPaintBufferCommitter, makeColorPaintBufferManager, makeFastBlendModeRegistry, makeFullPixelMutator, makeHistoryAction, makeImageDataLike, makeIndexedImage, makeIndexedImageFromImageData, makeIndexedImageFromImageDataRaw, makePaintAlphaMask, makePaintBinaryMask, makePaintCursorRenderer, makePerfectBlendModeRegistry, makePixelCanvas, makePixelData, makePixelTile, makeRectBinaryMaskOutline, makeRectFalloffPaintAlphaMask, makeRenderQueue, makeReusableCanvas, makeReusableImageData, makeReusableOffscreenCanvas, makeReusablePixelData, merge2BinaryMaskRects, mergeAlphaMasks, mergeBinaryMaskRects, mergeBinaryMasks, multiplyFast, multiplyPerfect, mutatorApplyAlphaMask, mutatorApplyBinaryMask, mutatorApplyMask, mutatorBlendAlphaMask, mutatorBlendBinaryMask, mutatorBlendColor, mutatorBlendColorPaintAlphaMask, mutatorBlendColorPaintBinaryMask, mutatorBlendColorPaintMask, mutatorBlendColorPaintRect, mutatorBlendMask, mutatorBlendPixel, mutatorBlendPixelData, mutatorClear, mutatorFill, mutatorFillBinaryMask, mutatorFillRect, mutatorInvert, overlayFast, overlayPerfect, overwriteBase, overwriteFast, overwritePerfect, packColor, packRGBA, pinLightFast, pinLightPerfect, pixelDataToAlphaMask, reflectPixelDataHorizontal, reflectPixelDataVertical, resampleImageData, resampleIndexedImage, resamplePixelData, resamplePixelDataInPlace, resampleUint32Array, resizeImageData, resizePixelData, rotatePixelData, screenFast, screenPerfect, serializeImageData, serializeNullableImageData, setMaskData, setPixelData, softLightFast, softLightPerfect, sourceAtopFast, sourceAtopPerfect, sourceInFast, sourceInPerfect, sourceOutFast, sourceOutPerfect, sourceOverFast, sourceOverPerfect, subtractBinaryMaskRects, subtractFast, subtractPerfect, toBlendModeIndexAndName, trimMaskRectBounds, trimRectBounds, uInt32ArrayToImageData, uInt32ArrayToImageDataLike, uInt32ArrayToPixelData, unpackAlpha, unpackBlue, unpackColor, unpackColorTo, unpackGreen, unpackRed, vividLightFast, vividLightPerfect, writeImageData, writeImageDataBuffer, writeImageDataToClipboard, writeImgBlobToClipboard, writePaintBufferToPixelData, writePixelData, writePixelDataBuffer, xorFast, xorPerfect };
|
package/dist/index.prod.js
CHANGED
|
@@ -99,8 +99,7 @@ function extractImageDataBuffer(imageData, _x, _y, _w, _h) {
|
|
|
99
99
|
w: _w,
|
|
100
100
|
h: _h
|
|
101
101
|
};
|
|
102
|
-
if (w <= 0) return new Uint8ClampedArray(0);
|
|
103
|
-
if (h <= 0) return new Uint8ClampedArray(0);
|
|
102
|
+
if (w <= 0 || h <= 0) return new Uint8ClampedArray(0);
|
|
104
103
|
const srcW = imageData.width;
|
|
105
104
|
const srcH = imageData.height;
|
|
106
105
|
const src = imageData.data;
|
|
@@ -124,8 +123,7 @@ function extractImageDataBuffer(imageData, _x, _y, _w, _h) {
|
|
|
124
123
|
}
|
|
125
124
|
copyW = Math.min(copyW, srcW - srcX);
|
|
126
125
|
copyH = Math.min(copyH, srcH - srcY);
|
|
127
|
-
if (copyW <= 0) return out;
|
|
128
|
-
if (copyH <= 0) return out;
|
|
126
|
+
if (copyW <= 0 || copyH <= 0) return out;
|
|
129
127
|
const isAligned = src.byteOffset % 4 === 0;
|
|
130
128
|
if (isAligned) {
|
|
131
129
|
const srcLen32 = src.byteLength / 4;
|
|
@@ -3622,8 +3620,7 @@ function fillPixelData(dst, color, _x, _y, _w, _h) {
|
|
|
3622
3620
|
}
|
|
3623
3621
|
fillW = Math.min(fillW, dstW - dstX);
|
|
3624
3622
|
fillH = Math.min(fillH, dstH - dstY);
|
|
3625
|
-
if (fillW <= 0) return false;
|
|
3626
|
-
if (fillH <= 0) return false;
|
|
3623
|
+
if (fillW <= 0 || fillH <= 0) return false;
|
|
3627
3624
|
const dst32 = dst.data;
|
|
3628
3625
|
let hasChanged = false;
|
|
3629
3626
|
if (dstX === 0 && fillW === dstW) {
|
|
@@ -3874,12 +3871,9 @@ function makeFullPixelMutator(writer) {
|
|
|
3874
3871
|
}
|
|
3875
3872
|
|
|
3876
3873
|
// src/ImageData/copyImageData.ts
|
|
3877
|
-
function copyImageData({
|
|
3878
|
-
data
|
|
3879
|
-
width,
|
|
3880
|
-
height
|
|
3881
|
-
}) {
|
|
3882
|
-
return new ImageData(data.slice(), width, height);
|
|
3874
|
+
function copyImageData(source) {
|
|
3875
|
+
const dataCopy = new Uint8ClampedArray(source.data);
|
|
3876
|
+
return new ImageData(dataCopy, source.width, source.height);
|
|
3883
3877
|
}
|
|
3884
3878
|
function copyImageDataLike({
|
|
3885
3879
|
data,
|
|
@@ -3906,8 +3900,7 @@ function extractImageData(imageData, _x, _y, _w, _h) {
|
|
|
3906
3900
|
w: _w,
|
|
3907
3901
|
h: _h
|
|
3908
3902
|
};
|
|
3909
|
-
if (w <= 0) return null;
|
|
3910
|
-
if (h <= 0) return null;
|
|
3903
|
+
if (w <= 0 || h <= 0) return null;
|
|
3911
3904
|
const result = new ImageData(w, h);
|
|
3912
3905
|
const buffer = extractImageDataBuffer(imageData, x, y, w, h);
|
|
3913
3906
|
result.data.set(buffer);
|
|
@@ -4064,7 +4057,7 @@ function uInt32ArrayToImageDataLike(data, width, height) {
|
|
|
4064
4057
|
}
|
|
4065
4058
|
|
|
4066
4059
|
// src/ImageData/writeImageData.ts
|
|
4067
|
-
function writeImageData(target, source, x, y) {
|
|
4060
|
+
function writeImageData(target, source, x = 0, y = 0) {
|
|
4068
4061
|
const dstW = target.width;
|
|
4069
4062
|
const dstH = target.height;
|
|
4070
4063
|
const dst = target.data;
|
|
@@ -4089,8 +4082,7 @@ function writeImageData(target, source, x, y) {
|
|
|
4089
4082
|
}
|
|
4090
4083
|
copyW = Math.min(copyW, dstW - dstX);
|
|
4091
4084
|
copyH = Math.min(copyH, dstH - dstY);
|
|
4092
|
-
if (copyW <= 0) return;
|
|
4093
|
-
if (copyH <= 0) return;
|
|
4085
|
+
if (copyW <= 0 || copyH <= 0) return;
|
|
4094
4086
|
const isDstAligned = dst.byteOffset % 4 === 0;
|
|
4095
4087
|
const isSrcAligned = src.byteOffset % 4 === 0;
|
|
4096
4088
|
if (isDstAligned && isSrcAligned) {
|
|
@@ -4132,8 +4124,7 @@ function writeImageDataBuffer(target, data, _x, _y, _w, _h) {
|
|
|
4132
4124
|
w = _w;
|
|
4133
4125
|
h = _h;
|
|
4134
4126
|
}
|
|
4135
|
-
if (w <= 0) return;
|
|
4136
|
-
if (h <= 0) return;
|
|
4127
|
+
if (w <= 0 || h <= 0) return;
|
|
4137
4128
|
const dstW = target.width;
|
|
4138
4129
|
const dstH = target.height;
|
|
4139
4130
|
const dst = target.data;
|
|
@@ -4155,8 +4146,7 @@ function writeImageDataBuffer(target, data, _x, _y, _w, _h) {
|
|
|
4155
4146
|
}
|
|
4156
4147
|
copyW = Math.min(copyW, dstW - dstX);
|
|
4157
4148
|
copyH = Math.min(copyH, dstH - dstY);
|
|
4158
|
-
if (copyW <= 0) return;
|
|
4159
|
-
if (copyH <= 0) return;
|
|
4149
|
+
if (copyW <= 0 || copyH <= 0) return;
|
|
4160
4150
|
const isDstAligned = dst.byteOffset % 4 === 0;
|
|
4161
4151
|
const isSrcAligned = data.byteOffset % 4 === 0;
|
|
4162
4152
|
if (isDstAligned && isSrcAligned) {
|
|
@@ -6147,8 +6137,7 @@ function fillPixelDataFast(dst, color, _x, _y, _w, _h) {
|
|
|
6147
6137
|
}
|
|
6148
6138
|
fillW = Math.min(fillW, dstW - dstX);
|
|
6149
6139
|
fillH = Math.min(fillH, dstH - dstY);
|
|
6150
|
-
if (fillW <= 0) return;
|
|
6151
|
-
if (fillH <= 0) return;
|
|
6140
|
+
if (fillW <= 0 || fillH <= 0) return;
|
|
6152
6141
|
const dst32 = dst.data;
|
|
6153
6142
|
const dw = dst.w;
|
|
6154
6143
|
if (fillW === dw && fillH === dst.h && dstX === 0 && dstY === 0) {
|
|
@@ -6194,8 +6183,7 @@ function extractPixelDataBuffer(source, _x, _y, _w, _h) {
|
|
|
6194
6183
|
const srcW = source.w;
|
|
6195
6184
|
const srcH = source.h;
|
|
6196
6185
|
const srcData = source.data;
|
|
6197
|
-
if (w <= 0) return new Uint32Array(0);
|
|
6198
|
-
if (h <= 0) return new Uint32Array(0);
|
|
6186
|
+
if (w <= 0 || h <= 0) return new Uint32Array(0);
|
|
6199
6187
|
const dstData = new Uint32Array(w * h);
|
|
6200
6188
|
let srcX = x;
|
|
6201
6189
|
let srcY = y;
|
|
@@ -6215,8 +6203,7 @@ function extractPixelDataBuffer(source, _x, _y, _w, _h) {
|
|
|
6215
6203
|
}
|
|
6216
6204
|
copyW = Math.min(copyW, srcW - srcX);
|
|
6217
6205
|
copyH = Math.min(copyH, srcH - srcY);
|
|
6218
|
-
if (copyW <= 0) return dstData;
|
|
6219
|
-
if (copyH <= 0) return dstData;
|
|
6206
|
+
if (copyW <= 0 || copyH <= 0) return dstData;
|
|
6220
6207
|
for (let row = 0; row < copyH; row++) {
|
|
6221
6208
|
const srcStart = (srcY + row) * srcW + srcX;
|
|
6222
6209
|
const dstStart = (dstY + row) * w + dstX;
|
|
@@ -6462,6 +6449,41 @@ function writePaintBufferToPixelData(target, paintBuffer, writePixelDataBufferFn
|
|
|
6462
6449
|
}
|
|
6463
6450
|
}
|
|
6464
6451
|
}
|
|
6452
|
+
|
|
6453
|
+
// src/PixelData/writePixelData.ts
|
|
6454
|
+
function writePixelData(target, source, x = 0, y = 0) {
|
|
6455
|
+
const dstW = target.w;
|
|
6456
|
+
const dstH = target.h;
|
|
6457
|
+
const dst = target.data;
|
|
6458
|
+
const srcW = source.w;
|
|
6459
|
+
const srcH = source.h;
|
|
6460
|
+
const src = source.data;
|
|
6461
|
+
let dstX = x;
|
|
6462
|
+
let dstY = y;
|
|
6463
|
+
let srcX = 0;
|
|
6464
|
+
let srcY = 0;
|
|
6465
|
+
let copyW = srcW;
|
|
6466
|
+
let copyH = srcH;
|
|
6467
|
+
if (dstX < 0) {
|
|
6468
|
+
srcX = -dstX;
|
|
6469
|
+
copyW += dstX;
|
|
6470
|
+
dstX = 0;
|
|
6471
|
+
}
|
|
6472
|
+
if (dstY < 0) {
|
|
6473
|
+
srcY = -dstY;
|
|
6474
|
+
copyH += dstY;
|
|
6475
|
+
dstY = 0;
|
|
6476
|
+
}
|
|
6477
|
+
copyW = Math.min(copyW, dstW - dstX);
|
|
6478
|
+
copyH = Math.min(copyH, dstH - dstY);
|
|
6479
|
+
if (copyW <= 0 || copyH <= 0) return;
|
|
6480
|
+
for (let row = 0; row < copyH; row++) {
|
|
6481
|
+
const dstStart = (dstY + row) * dstW + dstX;
|
|
6482
|
+
const srcStart = (srcY + row) * srcW + srcX;
|
|
6483
|
+
const chunk = src.subarray(srcStart, srcStart + copyW);
|
|
6484
|
+
dst.set(chunk, dstStart);
|
|
6485
|
+
}
|
|
6486
|
+
}
|
|
6465
6487
|
export {
|
|
6466
6488
|
AlphaMaskPaintBuffer,
|
|
6467
6489
|
BASE_FAST_BLEND_MODE_FUNCTIONS,
|
|
@@ -6706,6 +6728,7 @@ export {
|
|
|
6706
6728
|
writeImageDataToClipboard,
|
|
6707
6729
|
writeImgBlobToClipboard,
|
|
6708
6730
|
writePaintBufferToPixelData,
|
|
6731
|
+
writePixelData,
|
|
6709
6732
|
writePixelDataBuffer,
|
|
6710
6733
|
xorFast,
|
|
6711
6734
|
xorPerfect
|