【发布时间】:2013-01-05 23:25:52
【问题描述】:
首先我想说,我确实读了很多书,但我并没有发现这个问题……
目前我的代码运行良好。我有一个位图,然后我剪下我的位图的一部分并绘制它。
this.card = new ImageView(this); //this is my ImageView
//and my bitmap...
this.bmCards = BitmapFactory.decodeResource(getResources(), R.drawable.cardgame);
//and here I set the bitmap as Image of this ImageView
this.card.setImageBitmap(getCard(Stapel.getCard()));
调用的方法如下:
private Bitmap getCard(Card c) {
//some arithmetic to calculate the size...
Bitmap result = Bitmap.createBitmap(cardW, cardH, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(result);
canvas.drawBitmap(bmCards, new Rect(x, y, x + cardW + toleranzW, y + cardH + toleranzH),
new Rect(0, 0, cardW, cardH), new Paint());
return result;
}
到目前为止它可以工作.. 但是我如何调整此图像的大小? 我的意思是在画布上绘制位图的右侧部分,但我想稍微缩放这部分,因为它太小了……可能是实际 H * 1,5 和实际 W * 1,5 之类的。
【问题讨论】:
标签: android bitmap textview android-canvas