Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun Oct 22, 2017 10:35 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Draw9Patch Class
PostPosted: Thu Mar 01, 2012 4:57 am 
Offline

Joined: Tue Feb 14, 2012 5:39 am
Posts: 99
Location: Austria
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)

Image

Currently i only implemented the resizing part, the "content" part is in work, but not included in the demo.

Usage:
Declare:
The image to be resized/stretched must be declared in the constructor
dim img as new C9Patch(img_to_be_resized)

Getting images:
.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!


Top
 Profile  
Reply with quote  
 Post subject: Re: Draw9Patch Class
PostPosted: Thu Mar 01, 2012 7:58 am 
Offline

Joined: Mon Nov 03, 2008 6:36 am
Posts: 477
Location: Italia > Milano > Solaro
Error component C9Patch.Costructor :-(

windows 7 pro

arthofer wrote:
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)

Image

Currently i only implemented the resizing part, the "content" part is in work, but not included in the demo.

Usage:
Declare:
The image to be resized/stretched must be declared in the constructor
dim img as new C9Patch(img_to_be_resized)

Getting images:
.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!

_________________
REALStudio
Custom controls and classes for RealStudio ( no plugin )
http://www.ivanomonti.eu


Top
 Profile  
Reply with quote  
 Post subject: Re: Draw9Patch Class
PostPosted: Thu Mar 01, 2012 9:57 am 
Offline

Joined: Tue Feb 14, 2012 5:39 am
Posts: 99
Location: Austria
Whats the code you used?
What picture did you use?
I cant figure out what went wrong at your project, and the example project is working on my windows 7 prof. machine.

For example, in the current state, you may not use
dim img as new C9Patch
because you must use the Constructor(Picture) method.


Top
 Profile  
Reply with quote  
 Post subject: Re: Draw9Patch Class
PostPosted: Thu Mar 01, 2012 10:08 am 
Offline

Joined: Mon Nov 03, 2008 6:36 am
Posts: 477
Location: Italia > Milano > Solaro
link = http://dl.dropbox.com/u/9857661/9Patch.zip
RB = 2011 r3
Windows 7 Pro - 3.10 Ghz - i5-2400 - 64 bit

error rb run

File: Office
Component: C9Patch.Costructor
Codice:

Error string: This method requires fewer parameters than previous....

_________________
REALStudio
Custom controls and classes for RealStudio ( no plugin )
http://www.ivanomonti.eu


Top
 Profile  
Reply with quote  
 Post subject: Re: Draw9Patch Class
PostPosted: Fri Mar 02, 2012 3:13 am 
Offline

Joined: Tue Feb 14, 2012 5:39 am
Posts: 99
Location: Austria
It compiles nice on my my machine.
And since it relies on pictures with alpha channels, i think the problem is your outdated RealStudio version.

Copy&Paste from the language reference:
Quote:
Beginning with version 2011r4, Picture objects support alpha channels (transparency) directly, without the need for a mask. Support for the alpha channel is now built into the color functions: RGB, HSV, CMY, and &c. These functions have an optional fourth parameter that specifies the degree of transparency of the color.


So it wont work on any RS < 2011r4 ... sorry


Top
 Profile  
Reply with quote  
 Post subject: Re: Draw9Patch Class
PostPosted: Fri Mar 02, 2012 3:27 am 
Offline

Joined: Mon Nov 03, 2008 6:36 am
Posts: 477
Location: Italia > Milano > Solaro
mmm update code msgbox error ... examples

dim s as string = Str(RBVersion)
dim value() as String = s.Split(".")

if value(0).Val < 2011 then
MsgBox "Versione not valid... This class for RealStudio 2011r4 or later"
exit
elseif value(1).Val < 04 then
MsgBox "Versione not valid... This class for RealStudio 2011r4 or later"
exit
end if

Thanck :-)

arthofer wrote:
It compiles nice on my my machine.
And since it relies on pictures with alpha channels, i think the problem is your outdated RealStudio version.

Copy&Paste from the language reference:
Quote:
Beginning with version 2011r4, Picture objects support alpha channels (transparency) directly, without the need for a mask. Support for the alpha channel is now built into the color functions: RGB, HSV, CMY, and &c. These functions have an optional fourth parameter that specifies the degree of transparency of the color.


So it wont work on any RS < 2011r4 ... sorry

_________________
REALStudio
Custom controls and classes for RealStudio ( no plugin )
http://www.ivanomonti.eu


Top
 Profile  
Reply with quote  
 Post subject: Re: Draw9Patch Class
PostPosted: Fri Mar 02, 2012 4:01 am 
Offline

Joined: Tue Feb 14, 2012 5:39 am
Posts: 99
Location: Austria
Thank you for your feedback!

The update has been added to the original post!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group