@@ -41,6 +41,12 @@ public class AKClusterElementBuilder extends ClusterElementBuilder {
4141    public  interface  Interface  {
4242        VectorElement  buildClusterElement (MapPos  pos , VectorElementVector  nElements );
4343    }
44+ 
45+     public  AKClusterElementBuilder (float  screenScale ) {
46+         super ();
47+         this .screenScale  = screenScale ;
48+     }
49+     private  float  screenScale ;
4450    Interface  inter  = null ;
4551    public  void  setInterface (Interface  inter ) {
4652        this .inter  = inter ;
@@ -140,24 +146,25 @@ public VectorElement nativeBuildClusterElement(MapPos pos, VectorElementVector e
140146            StyleBuilder  styleBuilder  = null ;
141147            Bitmap  cBitmap  = null ;
142148            if  (markerBitmap  != null  || textColor  != null ) {
143-                  android .graphics .Bitmap  canvasBitmap ;
144-                 if  (markerBitmap  != null ) {
145-                     canvasBitmap  = markerBitmap .copy (android .graphics .Bitmap .Config .ARGB_8888 , true );
146-                 } else  {
147-                     canvasBitmap  = android .graphics .Bitmap .createBitmap (markerSize , markerSize , android .graphics .Bitmap .Config .ARGB_8888 );
148-                 }
149+                 int  size  = int )(markerSize  * scale );
150+                 android .graphics .Bitmap  canvasBitmap  = android .graphics .Bitmap .createBitmap (size , size , android .graphics .Bitmap .Config .ARGB_8888 );
149151                android .graphics .Canvas  canvas  = new  android .graphics .Canvas (canvasBitmap );
150- 
152+                  canvas . scale ( screenScale ,  screenScale ); 
151153                Paint  paint  = AKClusterElementBuilder .paint ;
154+                 Rect  bounds  = AKClusterElementBuilder .tempRect ;
155+                 if  (markerBitmap  != null ) {
156+                     bounds .set (0 ,0 , markerBitmap .getWidth (), markerBitmap .getHeight ());
157+                     Rect  dst  = AKClusterElementBuilder .tempRect2 ;
158+                     dst .set (0 ,0 , markerSize , markerSize );
159+                     canvas .drawBitmap (markerBitmap , bounds , dst , paint );
160+                 }
152161
153162                paint .setTextAlign (Paint .Align .CENTER );
154163                paint .setTextSize (textSize );
155164                if  (typeface  != null ) {
156165                    paint .setTypeface (typeface );
157166                }
158-                 Typeface  typeface  = paint .getTypeface ();
159167                String  text  = Integer .toString (nbElements );
160-                 Rect  bounds  = AKClusterElementBuilder .tempRect ;
161168                paint .getTextBounds (text , 0 , text .length (), bounds );
162169
163170                if  (textColor  != null ) {
@@ -166,8 +173,8 @@ public VectorElement nativeBuildClusterElement(MapPos pos, VectorElementVector e
166173                    paint .setColor (Color .WHITE );
167174                }
168175
169-                 float  x  = canvasBitmap . getWidth ()  / 2 ;
170-                 float  y  = canvasBitmap . getHeight ()  / 2  + bounds .height ()/2 ;
176+                 float  x  = markerSize  / 2 ;
177+                 float  y  = markerSize  / 2  + bounds .height ()/2 ;
171178
172179                canvas .drawText (text , x , y , paint );
173180                cBitmap  = BitmapUtils .createBitmapFromAndroidBitmap (canvasBitmap );
0 commit comments