Add support for blend modes.

This commit is contained in:
Brendan Dahl 2013-03-11 10:23:47 -07:00
parent c11a8a6e42
commit 523aa9c152
4 changed files with 24 additions and 5 deletions

View File

@ -561,6 +561,22 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.current.fillAlpha = state[1];
this.ctx.globalAlpha = state[1];
break;
case 'BM':
if (value && value.name && (value.name !== 'Normal')) {
var mode = value.name.replace(/([A-Z])/g,
function(c) {
return '-' + c.toLowerCase();
}
).substring(1);
this.ctx.globalCompositeOperation = mode;
if (this.ctx.globalCompositeOperation !== mode) {
warn('globalCompositeOperation "' + mode +
'" is not supported');
}
} else {
this.ctx.globalCompositeOperation = 'source-over';
}
break;
}
}
},

View File

@ -497,6 +497,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
case 'FL':
case 'CA':
case 'ca':
case 'BM':
gsStateObj.push([key, value]);
break;
case 'Font':
@ -506,11 +507,6 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
value[1]
]);
break;
case 'BM':
// We support the default so don't trigger the TODO.
if (!isName(value) || value.name != 'Normal')
TODO('graphic state operator ' + key);
break;
case 'SMask':
// We support the default so don't trigger the TODO.
if (!isName(value) || value.name != 'None')

BIN
test/pdfs/blendmode.pdf Normal file

Binary file not shown.

View File

@ -838,6 +838,13 @@
"rounds": 1,
"type": "eq"
},
{ "id": "blendmode",
"file": "pdfs/blendmode.pdf",
"md5": "374800cf78ce4b4abd02cd10a856b57f",
"rounds": 1,
"type": "eq",
"about": "Every blend mode that PDF supports."
},
{ "id": "issue2462",
"file": "pdfs/issue2462.pdf",
"md5": "d4e3dddfdd35464c71cf0310bff29b42",