Take the 2-minute tour ×

In Android development I found nine patch images very useful to draw images that have a fixed border. When the image is scaled the inner part scales, but the border stays at a fixed size.

I was looking for something similar in DirectX. Does anyone have information/pointers to nine patch images in DirectX?

share|improve this question

1 Answer 1

Well, to do 9-Patch drawing, you would find the coordinates of the individual regions and then convert those to UV coords (percentage of image size). You would then draw those to quads.

The corners quads would be the size of the region of the image and the middle sections would be whatever dimensions you want (where the edges only manipulate the edge direction).

You would also set your projection matrix to an orthographic view if you wanted to draw in 2D to get accurate pixel representation.

share|improve this answer
thanks, for your answer, are you aware of any existing implementations? I am aware that it is not particularly hard, I just thought I can't be the first one needing this :P –  pivotnig Jan 6 '13 at 19:31
Typically its used in a GUI so maybe some GUI library would have one, but I don't know of anything personally. It's easy enough to make. –  CobaltHex Jan 6 '13 at 19:55
alright, thanks –  pivotnig Jan 6 '13 at 21:04

Your Answer


