Skip to content

Commit

Permalink
Merge branch 'master' into ghp-491
Browse files Browse the repository at this point in the history
  • Loading branch information
PavelMor25 committed Apr 9, 2024
2 parents d781ebf + 934b73e commit 171e9d5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/screenshots/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
export const MARK_BYTES_PER_PIXEL = 4;
export const MARK_LENGTH = 32;
export const MARK_HEIGHT = 10;
export const MARK_RIGHT_MARGIN = 10;
export const MARK_RIGHT_MARGIN = 25;
31 changes: 17 additions & 14 deletions test/server/crop-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
const expect = require('chai').expect;
const expect = require('chai').expect;

const {
MARK_LENGTH,
MARK_BYTES_PER_PIXEL,
MARK_RIGHT_MARGIN,
} = require('../../lib/screenshots/constants');

const {
getClipInfoByCropDimensions,
Expand All @@ -7,23 +13,20 @@ const {
calculateClipInfo,
} = require('../../lib/screenshots/crop');

const markSeed = [
0, 0, 0, 255,
255, 255, 255, 255,
0, 0, 0, 255,
255, 255, 255, 255,
0, 0, 0, 255,
255, 255, 255, 255,
];
const markSeed = Array(MARK_LENGTH).fill().flatMap((_, i) => i % 2 ? [255, 255, 255, 255] : [0, 0, 0, 255]);

function getPngMock (mark = markSeed) {
const markSeedIndex = 6944952;
const width = 1820;
const height = 954;
const width = 1820;
const height = 954;
const length = width * height * MARK_BYTES_PER_PIXEL;
const markSeedOffset = (MARK_LENGTH + MARK_RIGHT_MARGIN) * MARK_BYTES_PER_PIXEL;
const markSeedIndex = length - markSeedOffset;

let data = '-'.repeat(markSeedIndex);
const dataHeader = Buffer.from('-'.repeat(markSeedIndex));
const dataMark = Buffer.from(mark);
const dataTrailer = Buffer.from('-'.repeat(MARK_RIGHT_MARGIN * MARK_BYTES_PER_PIXEL));

data = Buffer.concat([Buffer.from(data), Buffer.from(mark), Buffer.from(data)]);
const data = Buffer.concat([dataHeader, dataMark, dataTrailer]);

return { width, height, data };
}
Expand Down

0 comments on commit 171e9d5

Please sign in to comment.