Screen off in android

is it possible to draw on the screen in android, like a context image in a C. object, if he kindly tells me the link or some hint.

Many thanks.

+2
source share
3 answers

I believe you are looking for a Canvas object . This does not have to be on the screen when drawing (lines, shapes, bitmaps, etc.).

First you want to create a bitmap for drawing.

+1
source

Check out the app FingerPaintinApiDemos/Graphics

0
source

Ii , , , :

Canvas c = new Canvas();
Bitmap bmp = BitmapFactory.decodeResource(this, R.drawable.mybasebmp); // this is NOT MUTABLE!!
Bitmap bmpm = bmp.copy(bmp.getConfig(), true); // create a MUTABLE copy to draw on it
Bitmap bmpt = BitmapFactory.decodeResource(this, R.drawable.mytilebmp); // this is my tile
c.setBitmap(bmp);
Rect r = Rect(100,100,149, 149); // scaled to 50x50 pix to draw at position 100,100 in mybasebmp
c.drawBitmap(bmpt, null, r, null); // put a tile at 100,100
r.set(150,170, 150+50-1, 170+50-1); 
c.drawBitmap(bmpt, null,r, null); // put a tile at 150,170

// assign my drawn bitmap to an imageview to show it
ImageView iv = (ImageView) findViewById(R.id.myimageview);
iv.setImageBitmap(bmpm);

We use the canvas to complete the entire drawing in a mutable BMP, and then we put that BMP in a visible container, like an image.

Hope this helps someone, I could not find a suitable tutorial for this.

0
source

All Articles