From 3b5b5a23d1889741106116310f39f16904b7c7bd Mon Sep 17 00:00:00 2001 From: hanthomas Date: Mon, 26 Jan 2015 15:40:40 -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). --- jspdf.plugin.png_support.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/jspdf.plugin.png_support.js b/jspdf.plugin.png_support.js index 45b4eb9ec..f065e3382 100755 --- a/jspdf.plugin.png_support.js +++ b/jspdf.plugin.png_support.js @@ -383,8 +383,7 @@ */ 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),