Image blur in android
<p>I have taken thumbnail image from gallery  which is smaller in size and resized into 300*300 size.</p>

<p>By doing that the image looking so blurred.</p>

<p><strong>getting image from gallery</strong></p>

<pre><code> @Override
    protected void onActivityResult(int requestCode, int resultCode,
            Intent imageReturnedIntent) {
        super.onActivityResult(requestCode, resultCode, imageReturnedIntent);

        switch (requestCode) {
        case 0:
            if (resultCode == RESULT_OK) {
                try {
                    flag = 1;
                    Uri selectedImage = imageReturnedIntent.getData();
                    String[] filePathColumn = { MediaStore.Images.Media.DATA };

                    Cursor cursor = getContentResolver().query(selectedImage,
                            filePathColumn, null, null, null);
                    cursor.moveToFirst();

                    int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
                    String filePath = cursor.getString(columnIndex); // file
                    // path
                    // of
                    // selected
                    // image
                    cursor.close();

                    // Convert file path into bitmap image using below line.

                    yourSelectedImage = download.getResizedBitmap(
                        image.decodeImage(filePath),270,228);

                    // put bitmapimage in your imageview
                    profile_image.setImageBitmap(
                            yourSelectedImage);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
</code></pre>

<p><strong>Image resizing</strong></p>

<pre><code>public  Bitmap getResizedBitmap(Bitmap bm, int newHeight, int newWidth) 
    {
        try
        {
            if(bm!=null)
            {
            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
            resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, true); 


            }
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }

        return resizedBitmap;
    } 
</code></pre>
