我已经创建了一个Shape的子类,它包含配对的GraphicsPath和GraphicsStroke对象。该类有一个用于检索形状的公共方法,该方法以位图的形式传递到Pixelbender内核--该方法如下:
public function GetBitmap():Bitmap{
var bmpData:BitmapData = new BitmapData(this.width, this.height, true, 0x00FFFFFF);
bmpData.draw(this);
return new Bitmap(bmpData);
}要测试这些代码,我有以下代码:
var v:Vector.<Number> = new <Number>[10,10,50,10,50,50]; //defines GraphicsPath.data to be used
var wave:CustomWave = new CustomWave(v,0xff0000); //constructor for the subclass
wave.Refresh(); //clears the Shape and redraws the GraphicsPath
//adds as shape
addChild(wave);
//adds as bitmap
var bmp:Bitmap = wave.GetBitmap()
addChild(bmp);这两种产品的视觉输出:

知道是什么导致了这种差异吗?
发布于 2014-03-08 21:06:07
这是一个很长的故事,如何使用width和height,如果您不想遇到任何问题,可以从(0,0)绘制路径,或者修改您的函数:
public function GetBitmap():Bitmap {
var bounds: Rectangle = getBounds(this);
var bmpData:BitmapData = new BitmapData(bounds.width, bounds.height, true, 0);
bmpData.draw(this, new Matrix(1, 0, 0, 1, -bounds.x, -bounds.y));
return new Bitmap(bmpData);
}发布于 2014-03-08 19:57:06
这可能与您要绘制到Shape中的Bitmap的注册点有关。你有没有可能在0,0坐标的上方或左边画一些东西?然后,您必须向draw调用中添加一些参数(可能是转换矩阵),以获得正确的偏移量等等。
https://stackoverflow.com/questions/22273825
复制相似问题