From 88d496a5628d1cb84666d496fd25b997c3465767 Mon Sep 17 00:00:00 2001 From: hanthomas Date: Mon, 26 Jan 2015 15:45:21 -0500 Subject: [PATCH] Improve performance in iOS + Phonegap The old way to creating the byte array was causing the iOS + Phonegap implementation of Javascript to run really slow. This change improved performance by orders of magnitude (4x faster for some images). --- dist/jspdf.debug.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dist/jspdf.debug.js b/dist/jspdf.debug.js index 7131a13db..d8d8f6437 100644 --- a/dist/jspdf.debug.js +++ b/dist/jspdf.debug.js @@ -4476,8 +4476,7 @@ var jsPDF = (function(global) { */ if(img.bits === 8) { - var pixelsArrayType = window['Uint' + img.pixelBitlength + 'Array'], - pixels = new pixelsArrayType(img.decodePixels().buffer), + var pixels = img.pixelBitlength == 32 ? new Uint32Array(img.decodePixels().buffer) : img.pixelBitlength == 16 ? new Uint16Array(img.decodePixels().buffer) : new Uint8Array(img.decodePixels().buffer), len = pixels.length, imgData = new Uint8Array(len * img.colors), alphaData = new Uint8Array(len),