earl cabanig earl cabanig - 1 month ago 21
Android Question

Android Blurry image

I have an image saved in my database which is perfectly fine I am able to retrieve it, but the problem is that the image quality definitely has been lowered.

This is my code

String server_url = "http://192.168.8.100/jmiappphp/fetchImage.php?id="+user_id;

ImageRequest imageRequest = new ImageRequest(server_url,
new Response.Listener<Bitmap>() {
@Override
public void onResponse(Bitmap response) {
profile_image.setImageBitmap(response);
}
}, 50, 50, ImageView.ScaleType.CENTER_CROP, null, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(User_nav.this,"Something went wrong", Toast.LENGTH_SHORT).show();
error.printStackTrace();

}
});
UserImageSingleton.getInstance(User_nav.this).addToRequestQue(imageRequest);


UserImageSingleton

private static UserImageSingleton mInstance;
private RequestQueue requestQueue;
private static Context mCtx;
private UserImageSingleton(Context context){
mCtx = context;
requestQueue = getRequestQueue();

}

public RequestQueue getRequestQueue(){
if(requestQueue==null){
requestQueue = Volley.newRequestQueue(mCtx.getApplicationContext());
}
return requestQueue;
}
public static synchronized UserImageSingleton getInstance(Context context){
if(mInstance==null){
mInstance = new UserImageSingleton(context);
}
return mInstance;
}
public <T> void addToRequestQue(Request<T> request){
requestQueue.add(request);
}


This is the activity with the imageView

Answer

I think the problem could be, that your max size is set to 50.

}, 50, 50, ImageView.ScaleType.CENTER_CROP, null, new Response.ErrorListener() {

You could use a higher value for the size. If you set those two values to zero there will be no scaling. I hope that solves the problem.