Search code examples
androidimageviewscalingantialiasing

How to disable anti-aliasing when scaling up an imageview in android?


I have a pixel art that I want to scale up. The problem is when I scale it up, it gets all blurred cause of the antialiasing. Is there a way to disable antialiasing directly from xml?


Solution

  • i hope its useful

    Bitmap bmpSource = BitmapFactory.decodeResource(getResources(), SourceFileId);
    //100 is dimension to resizing image size
    //Passing filter = false will result in a blocky, pixellated image.
    //Passing filter = true will give you smoother edges
    Bitmap bmpScaled = Bitmap.createScaledBitmap(bmpSource, 100, 100, false); 
    
    
    ImageView img = (ImageView) findViewById(Your imageView Control Id);
    img.setImageBitmap(bmpScaled);
    

    is this what u want!?