From 2893d7681dac01730568723b7b4859e4e51caa6f Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Mon, 8 Jan 2018 07:08:24 +0000 Subject: [PATCH] Graphic.load() now accepts an optional 'offset' parameter, so you can skip some data to find the graphic you want to 'load'. Also, limit the read() size (of BIN files) to the width x height x 2. --- exec/load/graphic.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/exec/load/graphic.js b/exec/load/graphic.js index fc8a526f89..5e0cf6941f 100644 --- a/exec/load/graphic.js +++ b/exec/load/graphic.js @@ -507,7 +507,7 @@ Graphic.prototype.drawfx = function(xpos,ypos,width,height,xoff,yoff) * Loads a ANS or BIN file. * TODO: The ASC load is pretty much guaranteed to be broken. */ -Graphic.prototype.load = function(filename) +Graphic.prototype.load = function(filename, offset) { var file_type=file_getext(filename).substr(1); var f=new File(filename); @@ -525,7 +525,9 @@ Graphic.prototype.load = function(filename) case "BIN": if(!(f.open("rb",true))) return(false); - this.BIN = f.read(); + if(offset) + f.position = offset * this.height * this.width * 2; + this.BIN = f.read(this.height * this.width * 2); f.close(); break; case "ASC": -- GitLab