I need scale my bitmap to screenSizeAverage / 3. When I do it like this, I have sometimes OutOfMemory error.
screenWidth = size.x;
screenHeight = size.y;
screenSizeAverage = (screenWidth + screenHeight) / 2;
Bitmap b2 = BitmapFactory.decodeResource(getResources(), R.drawable.logoqrtz);
logoqrtz = Bitmap.createScaledBitmap(b2, screenSizeAverage / 3,screenSizeAverage / 3, true);
protected void onDraw(Canvas canvas) {
canvas.drawBitmap(logoqrtz, (int) (screenWidth / 2, (int) (screenHeight /2), p);
}
What is the best way to do this without OutOfMemory error?
From developer.android.com
Modified for your case.