2012-07-18 40 views
0

我正在开发一个有趣的android应用程序。其中我需要捕获图像,然后在保存之前,我需要在捕获的图像上添加一些文本。 是否有可能在android中运行时编辑捕获的图像请给我建议。 Thaanxx提前..!将文字置于Android中的捕获图像上?

+0

此[链接](http://stackoverflow.com/questions/9678377/overlaying-text-or-edittext-on-captured-image)可以帮助你 – 2012-07-18 09:26:49

+0

参考http://stackoverflow.com/问题/ 6159186 /我怎么写文字在图片在Android和保存它 – Shalini 2012-07-18 09:28:13

+0

是文本是默认的? – Manikandan 2012-07-18 09:37:25

回答

2

如果您使用默认意图捕获图像,请使用以下代码。无论你触摸图像,文字都会被放置。 cp,imageview应该在你的布局中。 RelativeLayout rl是你的布局的id。

ImageView cp = (ImageView) findViewById(R.id.img_cp); 
       Intent cameraIntent = new Intent(
         android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
       startActivityForResult(cameraIntent, CAMERA_REQUEST); 


     cp.setOnTouchListener(new OnTouchListener() { 
      @Override 
      public boolean onTouch(View v, MotionEvent event) { 
       // TODO Auto-generated method stub 
       Log.v("touched x val of cap img >>", event.getX() + ""); 
       Log.v("touched y val of cap img >>", event.getY() + ""); 
       x = (int) event.getX(); 
       y = (int) event.getY(); 
       RelativeLayout rl = (RelativeLayout) findViewById(R.id.lay_lin); 
       TextView iv = new TextView(Capture_Image.this); 
       iv.setText("checking......"); 
       RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
         RelativeLayout.LayoutParams.WRAP_CONTENT, 
         RelativeLayout.LayoutParams.WRAP_CONTENT); 
       params.leftMargin = x; 
       params.topMargin = y; 
       rl.addView(iv, params); 
       return false; 
      } 
     }); 
    } 

    protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
     if (requestCode == CAMERA_REQUEST) { 
      photo = (Bitmap) data.getExtras().get("data"); 
      cp.setImageBitmap(photo); 
     } 

    }