SSISO Community

시소당

canvas에 그림 그려서 imageview에 붙이기

출처: http://joerg-richter.fuyosoft.com/?p=120



 Bitmap  bitmap2 = BitmapFactory.decodeResource(getResources(), R.drawable.close);
		            	
  	
		            	  
⁄⁄Create a new image bitmap and attach a brand new canvas to it
Bitmap tempBitmap = Bitmap.createBitmap(bitmap2.getWidth(), bitmap2.getHeight(), Bitmap.Config.RGB_565);
            	  
Canvas canvas = new Canvas(tempBitmap);
            	  
⁄⁄Draw the image bitmap into the cavas
canvas.drawBitmap(bitmap2, 0, 0, null);

 ⁄⁄Draw everything else you want into the canvas, in this example a rectangle with rounded edges
  Paint paint = new Paint();
  paint.setTextSize(100);
  paint.setColor(0xFFFF0000);
  canvas.drawText("hhhhhhhhhhhhhhhhhhi", 300, 300, paint);
		            	  
 ⁄⁄Attach the canvas to the ImageView
  image.setImageDrawable(new BitmapDrawable(getResources(), tempBitmap));

653 view

4.0 stars