Home > DeveloperSection > Forums > Android bitmap with border
Pravesh Singh
Pravesh Singh

Total Post:101

Posted on    May-29-2013 11:46 PM

 Android Android 

 1 Reply(s)
 2965  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.



Total Post:604

Posted on    May-30-2013 5:33 AM

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. 

Don't want to miss updates? Please click the below button!

Follow MindStick