• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

Android - Bitmap issue with device memory

Search This thread

Ramyakrishna

New member
Sep 21, 2021
1
0
I am using a bitmap to draw more than one drawing on the same canvas. Say, I am drawing lines, circles with different radii to the same canvas. My requirement is to add 2000 such canvas to my MapView. The image looks pixelated if I use 256x256 as bitmap resolution.

So I am using 1024x1024 as bitmap resolution for better quality. Now when I run this on Android devices with low memory, my app freezes and crashes.


Problem statement :
1. Bitmap size - 1024*1024 = works fine in devices having more memory like one plus devices but freezes on the low storage[less than 4 GB]

2. Bitmap size - 256 * 256 = works fine in both Android devices.


Here is the code Snippet Currently using to draw on canvas by using a bitmap.

Bitmap bitmap = Bitmap.createBitmap(1024, 1024, Bitmap.Config.ARGB_8888);

Canvas canvas = new Canvas(bitmap);

// drawing circle

canvas.drawCircle(width/2, height/2, 2, paint);

// drawing line

canvas.drawLine(cx, cy, x2, y2, paint);

// Same canvas with different radius

canvas.drawArc(endgunRect, startAngle - 90, endSweep, false, paint);


Solution expected :
I need to load around 2000 devices on the map view of the app in all types of Android devices irrespective of devices storage capacity?


Could anyone advise is there any other approach we have than Bitmap on the canvas?