Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Beta Versions
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Beta Versions This forum is the place to discuss issues regarding Basic4ppc beta versions.

AutoScale compilation mode and external libraries

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-24-2009, 08:05 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 13,162
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default AutoScale compilation mode and external libraries

The new version includes an important new compilation mode: AutoScale.
Some explanation about this mode:
When the program starts it checks the device's screen dpi.
It saves these two values in two variables: screenX and screenY.
QVGA screens will return 1 for screenX and screenY.
VGA screens will return 2 for screenX and screenY.
Other values are also possible.
There are another two relevant variables: fixX and fixY.
In the regular compilation mode these variables are constants and equal 1.
In AutoScale compilation these variables are equal to screenX/Y variables.

When a control is created its location and size values will be multiplied with these values.
For example:
Button1.Width = 70 will be translated to Button1.Width = 70 * fixX.
Button1.Left = 20 will be translated to Button1.Height = 20 * fixY.

So the result is that the QVGA layout will appear identical on high resolution screens as well.

External controls libraries should also deal with the different dpis.
Simple solution (this is how ControlsEx.dll deals with it):
Mark your library by adding:
Code:
C#: public static object B4P_AutoScale = null;
VB .Net: Public Shared B4P_AutoScale 
As Object
Now all parameters that are named (case insensitive) width, height, left or top will automatically be converted as required.

For more complex libraries that need to deal with the different values you can access these 4 values with:
Code:
double scaleX = (double)(Thread.GetData(Thread.GetNamedDataSlot("scaleX")));
double scaleY = (double)(Thread.GetData(Thread.GetNamedDataSlot("scaleY")));
double fixX = (double)(Thread.GetData(Thread.GetNamedDataSlot("fixX")));
double fixY = (double)(Thread.GetData(Thread.GetNamedDataSlot("fixY")));
For example the TreeView controls has this code in the constructor which sets the default size of the images to look the same on VGA and QVGA:
Code:
double scaleX = (double)(Thread.GetData(Thread.GetNamedDataSlot("scaleX")));
double scaleY = (double)(Thread.GetData(Thread.GetNamedDataSlot("scaleY")));
il.ImageSize = new Size((
int)(il.ImageSize.Width * scaleX), (int)(il.ImageSize.Height * scaleY));
Note that the boolean value cPPC can also be fetched in the same way.
__________________
Basic4android documentation
Reply With Quote
  #2 (permalink)  
Old 04-28-2009, 01:28 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

I've started to look at this for my ControlsExDevice library and after being somewhat confused by the behaviour established the following.

When a library object has the field B4P_AutoScale defined then the compiler applies a fix to values in certain program statements as follows.

1) Values for parameters named Left, Top, Height & Width in library object constructors are fixed.

2) Values for assignment to properties named Left, Top, Height &, Width are fixed.

3) Values read back from properties named Left, Top, Height & Width are fixed.

Are there any other properties or type of statements that are fixed or are these the only circumstances where the fix is applied?
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #3 (permalink)  
Old 04-28-2009, 04:20 PM
Senior Member
 
Join Date: Apr 2007
Location: Canari Islan
Posts: 102
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hi Erel

Does the compilation works well with "WVGA" 480 x 800?

Best Regards
Reply With Quote
  #4 (permalink)  
Old 04-28-2009, 04:57 PM
Senior Member
 
Join Date: Apr 2007
Location: Canari Islan
Posts: 102
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hi Erel

One suggestion. Basic4ppc to work with different screen sizes The application may perform the calculation of the values of screenx and screeny as follows:

screenx = form1.width/240
screenY = form1.Height/320


-google traductor-
Reply With Quote
  #5 (permalink)  
Old 04-28-2009, 06:41 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 3,827
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

I can confirm that AutoSize compilation works also for 480*800 sceens with following restriction:
- ScreenScale = 2 for both sizes 480*640 and 480*800

Then it depends on what you want to do:
- do you want to stretch vertically the controls, in that case ScreenScale should be equal to 2.5 ?
- do you want to make profit of the supplementary surface of the screen ?

At the moment I am programming for my htc Touch HD and set the screen height in the FormDesigner to 400, this works well.

Best regards.
__________________
Klaus
Switzerland
Reply With Quote
  #6 (permalink)  
Old 04-28-2009, 07:36 PM
Senior Member
 
Join Date: Apr 2007
Location: Canari Islan
Posts: 102
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hi Klaus

exactly what I want is to optimize the display 800.

Best regards.
Reply With Quote
  #7 (permalink)  
Old 04-28-2009, 08:50 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 3,827
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Hi manu,

To program for the 480*800 screen size you have 2 options.

In the FormDesigner:

- set the screen size to 240*400 and compile with AutoSize
advantage: the screen on the desktop looks similar to what you will se on the PPC
disadvantage: the images in controls are stretched

- set the screen size to 480*800 and compile with Device Exe
advantage: you take full advantage of the screen resolution and pixel size
disadvatage: on the desktop the screen looks somewhat different than on the PPC, the size is big but the font size in controls remains small.

If, in the program, you draw onto the device you take advatage of the screen resolution in both cases.

Both options work.

Best regards.
__________________
Klaus
Switzerland
Reply With Quote
  #8 (permalink)  
Old 04-29-2009, 12:19 AM
Senior Member
 
Join Date: Apr 2007
Location: Canari Islan
Posts: 102
Awards Showcase
Beta Tester 
Total Awards: 1
Default

thanks Klaus.
Reply With Quote
  #9 (permalink)  
Old 04-29-2009, 09:41 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 13,162
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Quote:
Originally Posted by agraham View Post
I've started to look at this for my ControlsExDevice library and after being somewhat confused by the behaviour established the following.

When a library object has the field B4P_AutoScale defined then the compiler applies a fix to values in certain program statements as follows.

1) Values for parameters named Left, Top, Height & Width in library object constructors are fixed.

2) Values for assignment to properties named Left, Top, Height &, Width are fixed.

3) Values read back from properties named Left, Top, Height & Width are fixed.

Are there any other properties or type of statements that are fixed or are these the only circumstances where the fix is applied?
These are the exact places that B4P_AutoScale fixes.
In all other cases you will need to use FixX/Y and ScaleX/Y.
__________________
Basic4android documentation
Reply With Quote
  #10 (permalink)  
Old 04-29-2009, 12:24 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

I got HTMLPanel working with AutoScale and because it relies heavily entirely on pixel level working if I can get that working I can get anything working!

However as the Basic4ppc Form drawing functions are AutoScale aware how much should ImageLib and ImageLibEx also be made AutoScale aware? I note that ImageLib is partially aware in that the Drawer.Refresh methods use fixX/Y but none of the other Drawer methods or other ImageLib objects do. This seems a bit odd as if a Rectangle, say, is drawn under AutoScale on a VGA device and Refresh called on the same Rectangle it will invalidate an area four times that required! To use ImageLib as it presently stands a program, even when AutoScaled, needs to compensate for ScreenScaleX/Y itself when drawing so why not also Refresh
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
questions about testing in run mode hlo Questions (Windows Mobile) 4 03-31-2009 12:20 AM
Ringer volume and vibrate mode ikaplan Questions (Windows Mobile) 1 08-27-2008 05:45 AM
SD-Card in sleep mode berndgoedecke Questions (Windows Mobile) 0 07-17-2008 07:02 PM
FTP passive mode vinians Questions (Windows Mobile) 0 08-31-2007 02:43 PM
debug mode stuck.. belotrei Bug Reports 2 06-05-2007 05:17 PM


All times are GMT. The time now is 05:02 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0