Drawing a 9-patch image on a canvas with drawBitmap
<p>What is the proper way to use a 9-patch image resource on a custom view?</p>

<p>I'm doing this:</p>

<pre><code>background = BitmapFactory.decodeResource(getResources(), R.drawable.fundo_bookshelf);
canvas.drawBitmap(background, null, new Rect(0, y, width, y+backgroundHeight), null);
</code></pre>

<p>fundo_bookshelf is a proper 9-patch image, saved as fundo_bookshelf.9.png, seen below:</p>

<p><img src="http://i.stack.imgur.com/BPcGr.png" alt="fundo_bookshelf"></p>

<p>But when using the drawBitmap, the whole image is stretched, instead of only the part with the black pixel on the top, as shown on this screenshot:
<img src="http://i.stack.imgur.com/nAjP8.png" alt="strechted image"></p>
