2012-07-18 37 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); 
     } 

    }