Apache flex 如何使用beginBitmapFill?

Apache flex 如何使用beginBitmapFill?,apache-flex,Apache Flex,我试图在flex中绘制位图,原始位图是 但是,实际上,它在应用程序中显示出来 代码如下: this.component.graphics.beginBitmapFill(leakBitmapData); this.component.graphics.drawRect(leakPoint.x-halfWidth,leakPoint.y-halfHeight,leakBitmapData.width,leakBitmapData.height); this.component.graphics

我试图在flex中绘制位图,原始位图是

但是,实际上,它在应用程序中显示出来

代码如下:

this.component.graphics.beginBitmapFill(leakBitmapData);
this.component.graphics.drawRect(leakPoint.x-halfWidth,leakPoint.y-halfHeight,leakBitmapData.width,leakBitmapData.height);
this.component.graphics.endFill();
只有当我在(0,0)处绘制矩形时,它看起来才正确。 为什么?

我假设“leakBitmapData”是由代码生成或加载到应用程序中的bitmapdata

this.component.graphics.beginBitmapFill(leakBitmapData, null, true, false);
this.component.graphics.drawRect(0,0, leakBitmapData.width, leakBitmapData.height);
this.component.graphics.endFill();

this.component.x = -(leakBitmapData.width/2);
this.component.y = -(leakBitmapData.height/2);
我假设“leakBitmapData”是由代码生成或加载到应用程序中的bitmapdata

this.component.graphics.beginBitmapFill(leakBitmapData, null, true, false);
this.component.graphics.drawRect(0,0, leakBitmapData.width, leakBitmapData.height);
this.component.graphics.endFill();

this.component.x = -(leakBitmapData.width/2);
this.component.y = -(leakBitmapData.height/2);

如果要在原点之外绘制对象,则需要对BitmapData执行矩阵转换。大概是这样的:

var px:int = leakPoint.x - halfWidth;
var py:int = leakPoint.y - halfHeight;
var translationMatrix:Matrix = new Matrix;
translationMatrix.tx = px;
translationMatrix.ty = py;

this.component.graphics.beginBitmapFill(leakBitmapData, translationMatrix);
this.component.graphics.drawRect(px, py, leakBitmapData.width, leakBitmapData.height);
this.component.graphics.endFill();

如果要在原点之外绘制对象,则需要对BitmapData执行矩阵转换。大概是这样的:

var px:int = leakPoint.x - halfWidth;
var py:int = leakPoint.y - halfHeight;
var translationMatrix:Matrix = new Matrix;
translationMatrix.tx = px;
translationMatrix.ty = py;

this.component.graphics.beginBitmapFill(leakBitmapData, translationMatrix);
this.component.graphics.drawRect(px, py, leakBitmapData.width, leakBitmapData.height);
this.component.graphics.endFill();

我已经解决了这个问题,我需要做一个矩阵变换。但是仍然谢谢你。我已经解决了这个问题,我需要做一个矩阵变换。但是仍然谢谢你。我只是自己解决了这个问题。但是你是对的!这是正确的答案。我从没注意到你已经明白了。嗯,仅供参考。我只是自己解决了这个问题。但你是对的!这是正确的答案。我从没注意到你已经明白了。好吧,我想仅供参考。