Do not blit rasters into separate canvas when they have opacity set.

Closes #166.
This commit is contained in:
Jürg Lehni 2013-02-14 12:28:11 -08:00
parent 66c491a8fd
commit 366ba2897b
2 changed files with 8 additions and 2 deletions

View file

@ -2563,8 +2563,10 @@ var Item = this.Item = Base.extend(Callback, {
// and strokeColor also need to be drawn on a temporary canvas
// first, since otherwise their stroke is drawn half transparent
// over their fill.
// Exclude Raster items since they never draw a stroke and handle
// opacity by themselves (they also don't call _setStyles)
if (item._blendMode !== 'normal' || item._opacity < 1
&& (item._type !== 'path'
&& item._type !== 'raster' && (item._type !== 'path'
|| item.getFillColor() && item.getStrokeColor())) {
var bounds = item.getStrokeBounds();
if (!bounds.width || !bounds.height)

View file

@ -475,9 +475,13 @@ var Raster = this.Raster = PlacedItem.extend(/** @lends Raster# */{
draw: function(ctx, param) {
var element = this.getElement();
if (element)
if (element) {
// Handle opacity for Rasters separately from the rest, since
// Rasters never draw a stroke. See Item.draw().
ctx.globalAlpha = this._opacity;
ctx.drawImage(element,
-this._size.width / 2, -this._size.height / 2);
}
},
drawSelected: function(ctx, matrix) {