UNPKG

image-js

Version:

Image processing and manipulation in JavaScript

29 lines (28 loc) 712 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = getRow; var _checks = require("../internal/checks"); /** * @memberof Image * @instance * @param {number} row * @param {number} [channel=0] * @return {number[]} */ function getRow(row, channel = 0) { this.checkProcessable('getRow', { bitDepth: [8, 16] }); (0, _checks.checkRow)(this, row); (0, _checks.checkChannel)(this, channel); let array = new Array(this.width); let ptr = 0; let begin = row * this.width * this.channels + channel; let end = begin + this.width * this.channels; for (let j = begin; j < end; j += this.channels) { array[ptr++] = this.data[j]; } return array; }