0
我正在处理图像编辑应用程序并卡在这里。在缩放中绘制路径的行为不一致Android
public void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
// int width=this.getDrawable().getIntrinsicWidth();
// int height=this.getDrawable().getIntrinsicHeight();
// float sw=((float)getBitmapRect().width())/width;
// float sh=((float)getBitmapRect().height())/height;
matrix = new Matrix();
// matrix.postScale(sw, sh);
canvas.setMatrix(getDisplayMatrix());
canvas.concat(matrix);
canvas.save();
if (MainActivity.checkBtnOn == MainActivity.BSS_ONE) {
for (Pair<Path, Float> p : foregroundPaths) {
mPaint.setStrokeWidth(p.second);
canvas.drawPath(p.first, mPaint);
}
} else if (MainActivity.checkBtnOn == MainActivity.BSS_TWO) {
for (Pair<Path, Float> p : foregroundPaths) {
mPaint.setStrokeWidth(p.second);
canvas.drawPath(p.first, mPaint);
}
} else {
for (Pair<Path, Float> p : foregroundPaths) {
mPaint.setStrokeWidth(p.second);
canvas.drawPath(p.first, mPaint);
}
}
// matrix.postScale(getScale(), getScale());
rect = canvas.getClipBounds();
displayRectF = new RectF(rect.left, rect.top, rect.right, rect.bottom);
// rect =drawable.getBounds();
canvas.restore();
}
我的问题是 “什么,我做错了,导致我绘制的路径不一致的行为。”意味着它在缩放时的位置变化(对于我正在使用sephiroth库的缩放)。我附加了两个图像链接。第一张图像适合屏幕和第二张缩放。
请帮助我或任何建议,将不胜感激。 感谢
无需setMatrix到画布上。 – 2013-05-08 08:52:18