2017-12-06 6 views
1

Ich möchte ein Bild auf ein kleineres Bild wie ein Miniaturbild skalieren. Ich habe folgende OptionenSo skalieren Sie das Bild, ohne den Bildinhalt zu verlieren

Bitmap imageBitmap = Bitmap.createScaledBitmap(mBitmap, 200, 700, false); 

und

ThumbnailUtils.extractThumbnail() 

geschnitten Teile von Bildern Beide Optionen verwendet. Sie sehen also nicht gut aus. Ich möchte nur die Bildmaße reduzieren und den Bildinhalt nicht verlieren.

+1

Mögliche Duplikat zu versuchen, von [Wie ein Bitmap eficiently und mit heraus verlieren Qualität in Android, um die Größe] (https://stackoverflow.com/questions/8327846/how-to-resize-a-bitmap-eficienty-und-ohne-verlust-qualität-in-android) – Redman

+0

https://stackoverflow.com/questions/47627727/cropping-image-by- Einstellung-Höhe-dynamisch/47627812 # 47627812 –

+0

Mögliches Duplikat von [Bild verkleinern Größe, ohne seine Qualität in Android zu verlieren] (https://stackoverflow.com/questions/28424942/decrease-image-size-without-losing-its-quality-in-android) – ADM

Antwort

0

Wenn Sie die Größe eines Bildes ändern möchten, ohne Qualität zu verlieren und die Bilder von drawable/mipmap sind, sollten Sie pngquant ausprobieren.

https://pngquant.org/

+0

Er möchte programmatisch tun – Redman

1

Sie haben ähnliche

public Bitmap getResizedBitmap(Bitmap bm, int newHeight, int newWidth) 
{ 
    int width = bm.getWidth(); 
    int height = bm.getHeight(); 
    float scaleWidth = ((float) newWidth)/width; 
    float scaleHeight = ((float) newHeight)/height; 
    // create a matrix for the manipulation 
    Matrix matrix = new Matrix(); 
    // resize the bit map 
    matrix.postScale(scaleWidth, scaleHeight); 
    // recreate the new Bitmap 
    Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false); 
    return resizedBitmap; 
} 
1
BitmapFactory.Options bmOptions = new BitmapFactory.Options(); 
    Bitmap bitmap = BitmapFactory.decodeFile(filepath,bmOptions); 

    //Part 1 :withcompression Sacle image 200 pixels x 700 pixels this size you can customize as per your requirement 

    Bitmap withCompressed = Bitmap.createScaledBitmap(bitmap,200,700,true); 
Verwandte Themen