Drawable.createFromStream and getResources().getDrawable, why their outputs are different?
<p>I've an image of 32x32, which I have put in drawable folder and the same image application downloads from server. But downloaded one looks bigger(more like 48x48) and pixelated.</p>

<p>Server Code ( C# )</p>

<pre><code>        MemoryStream tms = new MemoryStream();
        image.Save(tms, System.Drawing.Imaging.ImageFormat.Png);
        byte[] imageData = tms.ToArray();
        //send data to phone
</code></pre>

<p>Application Code ( Java )</p>

<pre><code>    ByteArrayInputStream memStream = new ByteArrayInputStream(imageData);
    Drawable image = Drawable.createFromStream(memStream, ""); //big image and pixelated
    memStream.close();
</code></pre>

<p>but if I load same file from Resource, its always smaller</p>

<pre><code>Drawable image = getResources().getDrawable(R.drawable.image);
</code></pre>

<p>ImageView xml</p>

<pre><code>&lt;ImageView
    android:id="@+id/image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    android:focusable="false"
    android:scaleType="center" /&gt;
</code></pre>

<p>Edit :</p>

<p>Finally, setting the TargetDensity of BitmapDrawable worked!</p>

<pre><code>Bitmap bmp = BitmapFactory.decodeByteArray(imageData, 0,
        imageData.length);
BitmapDrawable image = new BitmapDrawable(bmp);
image.setTargetDensity(bmp.getDensity());
</code></pre>
