Usage of PrepareToDraw() of Bitmap class

Problems with Canvas, OpenGL, etc...

Usage of PrepareToDraw() of Bitmap class

Postby sukanyaparthiban » Tue Jun 22, 2010 6:39 am

I would like to know the exact usage of PrepareToDraw() in Bitmap class. Actually my understanding is, if the bitmap is recycled and if draw() is called after prepareToDraw(), it should be drawn without throwing exception(Since bimap will be rebuilt). Here is the code snippet.

BitmapFactory.Options mOptions = new BitmapFactory.Options();
mOptions.inPurgeable = true;
mOptions.inInputShareable = true;
InputStream is = getResources().openRawResource(R.drawable.test5);
b=BitmapFactory.decodeStream(is,new Rect(1, 1, 1, 1),mOptions);
b.recycle();
try{
canvas.drawBitmap(b,0, 150, mPaint);
}
catch(Exception e)
{
canvas.drawText(e.toString(), 0, 200, mPaint);
}
b.prepareToDraw();
try{
canvas.drawBitmap(b,0, 220, mPaint);
}
catch(Exception e)
{
canvas.drawText(e.toString(), 0, 220, mPaint);
}

But, RuntimeException: Canvas: trying to use a recycle bitmap was the output for both drawBitmap() function call. So i couldnt get the complete understanding of prepareToDraw().
It will be helpful, if anybody could help me out in this.

Thankyou,
Sukan
sukanyaparthiban
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Jun 22, 2010 6:11 am

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 1 guest