Skip to content

Commit

Permalink
Handle 0 byte maps + Logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Hypfer committed Jul 21, 2018
1 parent 9c71207 commit b2ba411
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -668,14 +668,20 @@
while (left < right && columnBlank(imageData, width, left, top, bottom))++left;
while (right - 1 > left && columnBlank(imageData, width, right - 1, top, bottom))--right;

var trimmed = ctx.getImageData(left, top, right - left, bottom - top);
var copy = canvas.ownerDocument.createElement("canvas");
var copyCtx = copy.getContext("2d");
copy.width = trimmed.width;
copy.height = trimmed.height;
copyCtx.putImageData(trimmed, 0, 0);

return copy;
try {
var trimmed = ctx.getImageData(left, top, right - left, bottom - top);
var copy = canvas.ownerDocument.createElement("canvas");
var copyCtx = copy.getContext("2d");
copy.width = trimmed.width;
copy.height = trimmed.height;
copyCtx.putImageData(trimmed, 0, 0);

return copy;
} catch (e) {
console.warn("Failed to trim image data", e);

return canvas;
}
};
})();

Expand Down

0 comments on commit b2ba411

Please sign in to comment.