UNPKG

image-js

Version:

Image processing and manipulation in JavaScript

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