I will create a simple floor map guide. I have different FLOORS and the corresponding MAPS. FLOORS are buttons and MAPS are png files stored in the sdcard. When I click 1F and corresponding 1Fmap will be displayed and so with other floors.
I am thinking of the following:
Here are my technical/design problems:
UPDATE: additional, I am targeting maximum of 20 floors (it means 20 512x512 png files...i am thinking also to adjust it to 256x256 as others suggested).
The recycle() method allows an app to reclaim memory as soon as possible. Caution: You should use recycle() only when you are sure that the bitmap is no longer being used. If you call recycle() and later attempt to draw the bitmap, you will get the error: "Canvas: trying to use a recycled bitmap" .
You can do a check when you want to return the BitMap look to see if the ArrayList of Paths is bigger than 0 and return the BitMap if so, or else return null.
To create a bitmap from a resource, you use the BitmapFactory method decodeResource(): Bitmap bitmap = BitmapFactory. decodeResource(getResources(), R. drawable.
A bitmap is simply a rectangle of pixels. Each pixel can be set to a given color but exactly what color depends on the type of the pixel. The first two parameters give the width and the height in pixels. The third parameter specifies the type of pixel you want to use.
This answer helped me:
https://stackoverflow.com/a/17068594/1373248
The code is the following:
Bitmap bmp1 = BitmapFactory.decodeResource(cont.getResources(), R.drawable.image); //then create a copy of bitmap bmp1 into bmp2 Bitmap bmp2 = bmp1.copy(bmp1.getConfig(), true);
Depending on situation you can use:
Bitmap src = ...; Bitmap dst = src.copy(src.getConfig(), src.isMutable);
The code below creates a copy. That means it copies the pixels from source bitmap and makes completely new Bitmap object. The reason why I am pointing it out because on internet you can find many examples where they use Bitmap.createBitmap() which does not guarantee if the new bitmap will be an object or a reference to older one. And depending on situation you can have problematic behaviour.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With