Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid: quality of the images resized in runtime
    primarykey
    data
    text
    <p>I want to show images using drawBitmap() method. But before I want to resize it according screen dimensions. I have a problem with quality of result image. You can see screenshots and test code below. How can I resize images in runtime with a good quality?</p> <p>Thank you for solutions.</p> <p>Original image: <a href="http://dl.dropbox.com/u/709109/gradient.png">alt text http://dl.dropbox.com/u/709109/gradient.png</a></p> <p>Result screenshot on device: <a href="http://dl.dropbox.com/u/709109/device.png">alt text http://dl.dropbox.com/u/709109/device.png</a></p> <pre><code>import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Rect; import android.os.Bundle; import android.view.View; import android.widget.LinearLayout; import java.io.IOException; import java.io.InputStream; public class MyActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); LinearLayout container = (LinearLayout) findViewById(R.id.container); container.addView(new View(this) { @Override protected void onDraw(Canvas canvas) { Bitmap unscaledBitmap; try { InputStream in = getAssets().open("images/gradient.png"); unscaledBitmap = BitmapFactory.decodeStream(in); in.close(); canvas.drawBitmap(unscaledBitmap, null, new Rect(0, 0, 320, 480), null); } catch (IOException e) { e.printStackTrace(); } } }); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload