diff --git a/lib/ComicBook.js b/lib/ComicBook.js index f09f810..077992a 100644 --- a/lib/ComicBook.js +++ b/lib/ComicBook.js @@ -243,10 +243,12 @@ function ComicBook(id, srcs, opts) { page = tmpPage2; page2 = tmpPage; } - + // draw the page(s) context.drawImage(page, offsetW, offsetH, page_width, page_height); if (options.displayMode === "double" && typeof page2 === "object") { context.drawImage(page2, page_width + offsetW, offsetH, page_width, page_height); } + + Pixastic.process(canvas, "desaturate", {average : false}); }; /** diff --git a/lib/Effects/desaturate.js b/lib/Effects/desaturate.js new file mode 100644 index 0000000..0fe1c24 --- /dev/null +++ b/lib/Effects/desaturate.js @@ -0,0 +1,37 @@ +/* + * Pixastic Lib - Desaturation filter - v0.1.1 + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ + * License: [http://www.pixastic.com/lib/license.txt] + */ + +Pixastic.Actions.desaturate = { + + process : function(params) { + var useAverage = !!(params.options.average && params.options.average != "false"); + + if (Pixastic.Client.hasCanvasImageData()) { + var data = Pixastic.prepareData(params); + var rect = params.options.rect; + var w = rect.width; + var h = rect.height; + + var p = w*h; + var pix = p*4, pix1, pix2; + + if (useAverage) { + while (p--) + data[pix-=4] = data[pix1=pix+1] = data[pix2=pix+2] = (data[pix]+data[pix1]+data[pix2])/3 + } else { + while (p--) + data[pix-=4] = data[pix1=pix+1] = data[pix2=pix+2] = (data[pix]*0.3 + data[pix1]*0.59 + data[pix2]*0.11); + } + return true; + } else if (Pixastic.Client.isIE()) { + params.image.style.filter += " gray"; + return true; + } + }, + checkSupport : function() { + return (Pixastic.Client.hasCanvasImageData() || Pixastic.Client.isIE()); + } +} \ No newline at end of file diff --git a/reader.html b/reader.html index b6f129f..1c8e9fb 100644 --- a/reader.html +++ b/reader.html @@ -11,6 +11,7 @@ +