diff --git a/src/item/Raster.js b/src/item/Raster.js index fc7e0ca3..4f759331 100644 --- a/src/item/Raster.js +++ b/src/item/Raster.js @@ -446,10 +446,11 @@ var Raster = this.Raster = Item.extend(/** @lends Raster# */{ getPixel: function(point) { point = Point.read(arguments); var pixels = this.getContext().getImageData(point.x, point.y, 1, 1).data, - components = [0, 0, 0, 0]; - for (var i = 0; i < 4; i++) + components = [0, 0, 0]; + for (var i = 0; i < 3; i++) components[i] = pixels[i] / 255; - return new Color('rgb', components); + // Alpha is separate now: + return new Color('rgb', components, pixels[3] / 255); }, /** @@ -474,10 +475,11 @@ var Raster = this.Raster = Item.extend(/** @lends Raster# */{ _color = Color.read(arguments); var ctx = this.getContext(true), imageData = ctx.createImageData(1, 1), + components = _color._convert('rgb'), alpha = _color.getAlpha(); - imageData.data[0] = _color.getRed() * 255; - imageData.data[1] = _color.getGreen() * 255; - imageData.data[2] = _color.getBlue() * 255; + imageData.data[0] = components[0] * 255; + imageData.data[1] = components[1] * 255; + imageData.data[2] = components[2] * 255; imageData.data[3] = alpha != null ? alpha * 255 : 255; ctx.putImageData(imageData, _point.x, _point.y); }, diff --git a/src/style/Color.js b/src/style/Color.js index d699aa50..999cee77 100644 --- a/src/style/Color.js +++ b/src/style/Color.js @@ -609,7 +609,7 @@ var Color = this.Color = Base.extend(new function() { */ _convert: function(type) { var converter; - return this._type == type + return this._type === type ? this._components.slice() : (converter = converters[this._type + '-' + type]) ? converter.apply(this, this._components)