Android creating BitmapDescriptor exception

前端 未结 4 1641
孤街浪徒
孤街浪徒 2021-01-06 03:01

I\'m writing an application that works alot with google map and markers on it. My task is to create and display some amount of markers on google map. Markers have custom ima

4条回答
  •  执笔经年
    2021-01-06 03:40

    I had same problem. With Kuva's answer I make a new class like this:

    public class MapBmpContainter
    {
        private int mBmpSize;
        public BitmapDescriptor mBmpDescriptor;
    
        public MapBmpContainter(Bitmap bmp)
        {
            mBmpSize=bmp.getByteCount()/1014;
            mBmpDescriptor= BitmapDescriptorFactory.fromBitmap(bmp);
        }
    
        public int getSize()
        {
            return mBmpSize;
        }
    }
    

    I cache new class object in LruCache instead of Bitmap. Same with Kuva I think Bitmap and BitmapDescriptor almost same size. And It worked

提交回复
热议问题