2
\$\begingroup\$

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?

\$\endgroup\$
2
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ 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 \$\endgroup\$ – thumbmunkeys Jan 6 '13 at 19:31
  • \$\begingroup\$ 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. \$\endgroup\$ – CobaltHex Jan 6 '13 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.