2016-04-13 6 views

Antwort

0

Dies ist der Code, den ich Bitmaps verwenden für die Skalierung, die wantedWidth und wantedHeight die Breite und die Höhe Ihrer Ansicht wäre.

public static Bitmap scaleBitmap(Bitmap bitmap, int wantedWidth, int wantedHeight) { 
    Bitmap output = Bitmap.createBitmap(wantedWidth, wantedHeight, Config.ARGB_8888); 
    Canvas canvas = new Canvas(output); 
    Matrix m = new Matrix(); 
    m.setScale((float) wantedWidth/bitmap.getWidth(), (float) wantedHeight/bitmap.getHeight()); 
    canvas.drawBitmap(bitmap, m, new Paint()); 
    return output; 
} 
Verwandte Themen