由网友(刁蛮是我最自豪的表情)分享简介:我有1的ImageView中,我要画一条线。我已经做了如下:I've one ImageView in which I want to draw a Line. I've done the follow:mImagenCampo = (ImageView) findViewById(R.id.imagen_camp...
我有1的ImageView中,我要画一条线。我已经做了如下:
I've one ImageView in which I want to draw a Line. I've done the follow:
mImagenCampo = (ImageView) findViewById(R.id.imagen_campo);
crearPunto(mArea9M,mPaloIzq,v.getWidth(),mPaloIzq,Color.WHITE);
crearPunto(mArea9M, mPaloIzq,v.getWidth(), mPaloIzq,Color.WHITE);
和作用是:
private void crearPunto(float x, float y, float xend, float yend, int color) {
BitmapDrawable bmpDraw = (BitmapDrawable) mImagenCampo.getDrawable();
Bitmap bmp = bmpDraw.getBitmap().copy(Config.RGB_565, true);
Canvas c = new Canvas(bmp);
Paint p = new Paint();
p.setColor(color);
c.drawLine(x, y, xend, yend, p);
mImagenCampo.setImageBitmap(bmp);
}
我的问题是绘制的线,但它没有得到权利的坐标。它被绘制小于它应该是
My problem is that the line is drawn but It doesn't get the rights coordinates. It is drawn smaller than It should be.
感谢
编辑:我忘了说的 mImagenCampo 的是一个ImageView的
I forgot to say that mImagenCampo is an ImageView
推荐答案
试试这个:
private void crearPunto(float x, float y, float xend, float yend, int color) {
bmp = Bitmap.createBitmap(mImagenCampo.getWidth(), mImagenCampo.getHeight(), Config.ARGB_8888);
c = new Canvas(bmp);
mImagenCampo.draw(c);
Paint p = new Paint();
p.setColor(color);
c.drawLine(x, y, xend, yend, p);
mImagenCampo.setImageBitmap(bmp);
}
相关推荐
最新文章