From ae645b941cdffa9e1228a458723e475aba94ad94 Mon Sep 17 00:00:00 2001 From: petitssoldats Date: Thu, 3 Apr 2014 11:38:09 +0200 Subject: [PATCH] allow arguments of getPixel() equal to bound and ensure that arguments x & y are rounded --- PNG.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/PNG.js b/PNG.js index 3862760..7dd38c6 100644 --- a/PNG.js +++ b/PNG.js @@ -138,9 +138,11 @@ PNG.prototype.getPalette = function(){ */ PNG.prototype.getPixel = function(x, y){ if (!this.pixels) throw new Error("pixel data is empty"); - if (x >= this.width || y >= this.height){ + if (x > this.width || y > this.height){ throw new Error("x,y position out of bound"); } + x = Math.round(x); + y = Math.round(y); var i = this.colors * this.bitDepth / 8 * (y * this.width + x); var pixels = this.pixels;