Paper.js `getImageData/putImageData` 与 alpha 通道

问题描述 投票:0回答:0

我使用 Paper.js 画布作为源,使用简单的画布作为目标。基本上通过

getImageData
复制可见图像的一部分并使用
putImageData
将其粘贴到目标画布中。

粘贴的图像没有alpha通道。例如,当复制区域仅包含对象的一部分而其余部分应为空时。我尝试为这两个功能添加

{ colorSpace: 'display-p3' }
,但我看到颜色空间保持
srgb
并且仍然没有alpha通道。

是否可以通过

getImageData
复制/粘贴图像数据并使用 Paper.js 保留 alpha 通道?

这是复制/粘贴代码。

const rasterTemp = RasterObject.rasterize() // This to reset all the transformations.

const subRasterTemp = rasterTemp.getSubRaster(new data.$paper.Rectangle({
  point: [0, 0], // These and other coordinates are just for the sake of demonstration
  size: [100, 100],
}))

const imageData = subRasterTemp.getImageData(new data.$paper.Rectangle({
  point: [0, 0],
  size: [100, 100],
}), { colorSpace: 'display-p3' })

canvasTargetContext.putImageData(imageData, 0, 0)
javascript canvas paperjs
© www.soinside.com 2019 - 2024. All rights reserved.