From 044b612d6ed91ec39d28749085a41ec9be11e451 Mon Sep 17 00:00:00 2001 From: Obexer Christoph Date: Fri, 18 Nov 2011 11:53:26 +0100 Subject: [PATCH] clear canvas before rendering to allow jpeg export * normally when exporting jpeg any pixel that was transparent becomes black, make them white * check for window.console.log before use (avoid crash) * html2canvas.Parse: fix missing call to html2canvas.Util.Extend for the given options --- src/Core.js | 2 +- src/Parse.js | 3 ++- src/Renderer.js | 9 +++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Core.js b/src/Core.js index 1e8478a..0e45d0e 100644 --- a/src/Core.js +++ b/src/Core.js @@ -11,7 +11,7 @@ var html2canvas = {}; html2canvas.logging = true; html2canvas.log = function (a) { - if (html2canvas.logging) { + if (html2canvas.logging && window.console && window.console.log) { window.console.log(a); } }; diff --git a/src/Parse.js b/src/Parse.js index 63c6831..42d23fe 100644 --- a/src/Parse.js +++ b/src/Parse.js @@ -47,6 +47,7 @@ html2canvas.Parse = function (element, images, opts) { children, childrenLen; + options = html2canvas.Util.Extend(opts, options); images = images || []; @@ -1254,4 +1255,4 @@ html2canvas.zContext = function(zindex) { zindex: zindex, children: [] }; -}; \ No newline at end of file +}; diff --git a/src/Renderer.js b/src/Renderer.js index e6e6092..0431ef5 100644 --- a/src/Renderer.js +++ b/src/Renderer.js @@ -78,12 +78,17 @@ html2canvas.Renderer = function(parseQueue, opts){ queueLen, a, storageLen, - renderItem; + renderItem, + fstyle; canvas.width = options.width || zStack.ctx.width; canvas.height = options.height || zStack.ctx.height; - + fstyle = ctx.fillStyle; + ctx.fillStyle = "#fff"; + ctx.fillRect(0, 0, canvas.width, canvas.height); + ctx.fillStyle = fstyle; + for (i = 0, queueLen = queue.length; i < queueLen; i+=1){ storageContext = queue.splice(0, 1)[0];