Helper class to for storing Nine-Patch images.
A Nine Patch is a smart way of scaling up bitmaps without the usual quality losses by subdividing the source image into nine sections and blitting the border sections unstretched, while only stretching the center section. This is particularly useful for mostly rectangular images in use-cases such as a scaled button, a progressbar or a scrollbar knob.
The Nine Patch is defined by the width/height of its top, bottom, left and right borders. These are given in pixels and relative to the image's top/left, and bottom/right corners. Typically, you will wish to set these values so that they encapsulate the areas of your source-image which shall remain in their original size, such as the edges or drop shadows of a button. The following image illustrates this concept.
These examples show how the original image appears when being stretched, with regard to different Nine Patch borders. You can clearly see how much the appearance of the stretched button has improved.
Please note that this comes at a slight performance cost, since a total of 9 blit operations has to be performed. Therefore, if you wish to avoid this, either blit the source image in its original size, or set all border widths to zero, which will result in one simple stretch-blit for the entire image.
Supplying the Nine Patch with illegal values, such as border sizes which exceed the original image's dimensions, will result in a visual output as shown in the two examples at the bottom. Also, make sure, that you leave a center section of at least 1 pixel, so that the center area will be filled and not remain empty.