ANDROID BITMAP WITH BORDER

Pravesh Singh

Total Post:101

Points:709
Posted by  Pravesh Singh
 3878  View(s)
Ratings:
Rate this:
Hi Guys,

I have this function, with this function I can show an image with a little rotation. I'm trying to display a white border arround the bitmap.

Matrix m = new Matrix();
        m.postRotate( rotation, center.x, center.y );
        m.postTranslate( ( position.x - center.x ) - xOffset , position.y - ( center.x ) );

        //  set the current position to the updated position
        positionMatrix.set( m );            
        renderAnimation();          
        c.drawBitmap( this.bitmap , positionMatrix, paint );

I'm trying to add the white border with this function: reference: stackoverflow border

    RectF targetRect = new RectF(left+10, top+10, left + scaledWidth, top + scaledHeight);
    Bitmap dest = Bitmap.createBitmap(this.bitmap.getWith() +20, this.bitmap.getHeight() +20, this.bitmap.getConfig());
    Canvas canvas = new Canvas(dest);
    canvas.drawColor(Color.WHITE);
    canvas.drawBitmap(this.bitmap, null, targetRect, null);
c.drawBitmap( this.bitmap , positionMatrix, paint );
But, not works, can some help me.

Thanks 
  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: Android bitmap with border

    Hi Pravesh!


    Try this, maybe you made a mistake when calculating the side:

    c.drawBitmap( this.bitmap , positionMatrix, paint );
    canvas.drawBitmap(this.bitmap, null, targetRect, null);

    I hope this code might be resolve your problem. 

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!