Skip to content

Commit 3b5b5a2

Browse files
committed
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).
1 parent 8c90c83 commit 3b5b5a2

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

jspdf.plugin.png_support.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,7 @@
383383
*/
384384
if(img.bits === 8) {
385385

386-
var pixelsArrayType = window['Uint' + img.pixelBitlength + 'Array'],
387-
pixels = new pixelsArrayType(img.decodePixels().buffer),
386+
var pixels = img.pixelBitlength == 32 ? new Uint32Array(img.decodePixels().buffer) : img.pixelBitlength == 16 ? new Uint16Array(img.decodePixels().buffer) : new Uint8Array(img.decodePixels().buffer),
388387
len = pixels.length,
389388
imgData = new Uint8Array(len * img.colors),
390389
alphaData = new Uint8Array(len),

0 commit comments

Comments
 (0)