@applitools/screenshoter
Advanced tools
Comparing version 3.0.4 to 3.0.5
@@ -7,3 +7,3 @@ { | ||
"version": "file:../dry-run.tgz", | ||
"integrity": "sha512-dmNTgIrBnWDiuPE610fBmVK4RIVgEBOo3ed5F3/1hb4BZ2TiVrXLzjjrcnbbO9h5qcYBiS9d2hfpwS2Ky6z+Hw==", | ||
"integrity": "sha512-Kz3VBkXYFmKE3HUmgCQOI/2Gp3x+MBmzrKVt/dziREOb8QRU/nazPmNPdaV5OFnEmD9JPBxvTigq/oj4OkF+jg==", | ||
"requires": { | ||
@@ -10,0 +10,0 @@ "@applitools/utils": "1.0.1", |
@@ -7,2 +7,6 @@ | ||
## 3.0.5 - 2021/2/18 | ||
- fix bug with wrong stitching due to fractional offset | ||
## 3.0.4 - 2021/2/15 | ||
@@ -9,0 +13,0 @@ |
{ | ||
"name": "@applitools/screenshoter", | ||
"version": "3.0.4", | ||
"version": "3.0.5", | ||
"description": "Applitools universal screenshoter for web and native applications", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -204,27 +204,30 @@ const fs = require('fs') | ||
async function copy(image1, image2, offset) { | ||
async function copy(dstImage, srcImage, offset) { | ||
const offsetX = Math.round(offset.x) | ||
const offsetY = Math.round(offset.y) | ||
// Fix the problem when src image was out of dst image and pixels was copied to wrong position in dst image. | ||
const maxHeight = | ||
offset.y + image2.height <= image1.height ? image2.height : image1.height - offset.y | ||
const maxWidth = offset.x + image2.width <= image1.width ? image2.width : image1.width - offset.x | ||
for (let y = 0; y < maxHeight; y += 1) { | ||
const dstY = offset.y + y | ||
const srcY = y | ||
offsetY + srcImage.height <= dstImage.height ? srcImage.height : dstImage.height - offsetY | ||
const maxWidth = | ||
offsetX + srcImage.width <= dstImage.width ? srcImage.width : dstImage.width - offsetX | ||
for (let x = 0; x < maxWidth; x += 1) { | ||
const dstX = offset.x + x | ||
const srcX = x | ||
for (let srcY = 0; srcY < maxHeight; srcY += 1) { | ||
const dstY = offsetY + srcY | ||
for (let srcX = 0; srcX < maxWidth; srcX += 1) { | ||
const dstX = offsetX + srcX | ||
// Since each pixel is composed of 4 values (RGBA) we multiply each index by 4. | ||
const dstIndex = (dstY * image1.width + dstX) * 4 | ||
const srcIndex = (srcY * image2.width + srcX) * 4 | ||
const dstIndex = (dstY * dstImage.width + dstX) * 4 | ||
const srcIndex = (srcY * srcImage.width + srcX) * 4 | ||
image1.data[dstIndex] = image2.data[srcIndex] | ||
image1.data[dstIndex + 1] = image2.data[srcIndex + 1] | ||
image1.data[dstIndex + 2] = image2.data[srcIndex + 2] | ||
image1.data[dstIndex + 3] = image2.data[srcIndex + 3] | ||
dstImage.data[dstIndex] = srcImage.data[srcIndex] | ||
dstImage.data[dstIndex + 1] = srcImage.data[srcIndex + 1] | ||
dstImage.data[dstIndex + 2] = srcImage.data[srcIndex + 2] | ||
dstImage.data[dstIndex + 3] = srcImage.data[srcIndex + 3] | ||
} | ||
} | ||
return image1 | ||
return dstImage | ||
} | ||
@@ -231,0 +234,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10456689
1612