2

I have tried to implement the image overlay on the live video using native camera. The code is as follows:

if (bmp != null) 
{ 
    Canvas canvas = mHolder.lockCanvas(); 
    if (canvas != null)
    {
        canvas.drawBitmap(bmp, (canvas.getWidth() - bmp.getWidth()) / 2,(canvas.getHeight() - bmp.getHeight()) / 2, null); 
        canvas.drawBitmap(drawable,0,0, null); 
        mFps.draw(canvas, (canvas.getWidth() - bmp.getWidth()) / 2, 0); 
        mHolder.unlockCanvasAndPost(canvas); 
    } 
    bmp.recycle(); 
}

But when I run the program it says force close. The image size I'm using is 751 x 500. Any suggestions, please? (Or any alternative approach?)

Thanks in advance for the input.

Dirk Jäckel
  • 2,979
  • 3
  • 29
  • 47
skool girl
  • 51
  • 3
  • Post the code related to drawable. Also post the specific error present in android logcat. Otherwise it will be hard to help. One possible guess is that maybe 'drawable' size is bigger than bmp size. – Rui Marques Jun 13 '12 at 20:09
  • >public static Bitmap overlay(Bitmap bmp1, Bitmap bmp2) { > Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), >bmp1.getHeight(), bmp1.getConfig()); > Canvas canvas = new Canvas(bmOverlay); > canvas.drawBitmap(bmp1, 0, 0, null); >canvas.drawBitmap(bmp2, 0, 0, null); >return bmOverlay; > } >public void run() { >Log.i(TAG, "Starting processing thread"); > mFps.init(); > while (true) { > Bitmap bmp = null; > Bitmap bmpz; > bmp = processFrame(mCamera); > bmpz=overlay(bmp, drawable) } – skool girl Jun 14 '12 at 15:56
  • You were supposed to place that code by editing your question. Don't worry I did it for you now. – Rui Marques Jun 14 '12 at 16:38

0 Answers0