Android bitmap with border

Total Post:101


 4617  View(s)
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 );            
        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.drawBitmap(this.bitmap, null, targetRect, null);
c.drawBitmap( this.bitmap , positionMatrix, paint );
But, not works, can some help me.

  1. 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. 


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.