Hi fellow developers!
Today i'm posting one of my classes which i wrote for my company to get some feedback.
This class allows you dynamic resizing of Buttons without making it look bad.
The basic idea is based on google android's Draw9Patch file format.
I implemented this because i needed button backgrounds in different sizes for the use in canvas controls.
But it would have been hell of a work to have each of the button backgrounds in all sizes from 26x26 up to 256x256.
(http://developer.android.com/guide/deve ... patch.html
Currently i only implemented the resizing part, the "content" part is in work, but not included in the demo.Usage:
The image to be resized/stretched must be declared in the constructor
dim img as new C9Patch(img_to_be_resized)
.stretch delivers a better image, the class itself outputs the unstretched image
dim betterImg as Picture = img.stretch(100,100)
dim originalImage as Picture = img
Setting the cache:
Size -1 disables the cache, size 0 sets the cache to unlimited and size X saves the last x pictures that have been requested in the cache.
Size 0 may result in a huge memory footprint if you generate many different sized images.
img.cacheSize = x
The example project includes the class and one example image that will be resized.
If you want to build your own image, feel free to use the given tool from the android SDK or paint it by yourself.
In case you want to make it with photoshop or GIMP, the image has to have a transparent border where the parts that will be stretched are marked with black pixels on the top and left side.
The marks on the right and bottom indicate the "content" area which is currently not implemented.
If you want to, try it out and/or use it.
Since this class was made for a business application, it will be encrypted until my boss decides to open it up.
And since this class is in a early alpha status, it may have multiple errors if you load a wrong image.http://dl.dropbox.com/u/9857661/9Patch.zip
Have fun with it!