Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | 6x 3x 3x 3x 3x 3x 3x 3x 200x 180x 38400x 38400x 36000x 36000x 36000x 36000x 36000x 3x 2x 12x 9x 3x 3x 3x | import type { ImageData } from "./types"; function createExpandedData(originalImage: ImageData, width: number, height: number) { if (originalImage.width === width && originalImage.height === height) { return originalImage.data; } const origWidth = originalImage.width; const origHeight = originalImage.height; const origData = originalImage.data; const newData = new Uint8Array(width * height * 4); let idx = 0; for (let j = 0; j < height; j++) { if (j < origHeight) { for (let i = 0; i < width; i++) { idx = (j * width + i) << 2; if (i < origWidth) { const origIdx = (j * origWidth + i) << 2; newData[idx] = origData[origIdx]; newData[idx + 1] = origData[origIdx + 1]; newData[idx + 2] = origData[origIdx + 2]; newData[idx + 3] = origData[origIdx + 3]; } } } } return newData; } export default function expand(img1: ImageData, img2: ImageData) { if (img1.width === img2.width && img1.height === img2.height) { return { dataList: [img1.data, img2.data], width: img1.width, height: img1.height, }; } const width = Math.max(img1.width, img2.width); const height = Math.max(img1.height, img2.height); return { width, height, dataList: [createExpandedData(img1, width, height), createExpandedData(img2, width, height)], }; } |