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

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

Code Samples & Tips Share your recent discoveries and ideas with other users.

ForceQVGA without pixel doubling and QVGA icon!

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-21-2008, 08:27 PM
Senior Member
 
Join Date: Sep 2008
Posts: 161
Default ForceQVGA without pixel doubling and QVGA icon!

So here's the problem: You want your items to show exactly the same way on VGA and QVGA screens but Force QVGA just stretches controls on VGA screens and make images pixelated. However drawing every control based on screen resolution is a waste of time and reduces the speed of your application:
Code:
<font color="Red">'WRONG</font>
If <i>(the screen is QVGA)</i> then
 AddButton(
"Form1","Button1",5,5,100,25,"Click me")
Else If (the screen is VGA) Then
 AddButton(
"Form1","Button1",10,10,200,50,"Click me")
End If
How can you double your control sizes without requiring "If Then Else" statements for everything you draw? Erel has already proposed a solution but it doesn't work when drawing stuff at runtime (AddButton, DrawImage, Drawstring...). Here's how I did it for Gecko after much thinking and some swearing:

1-Get the screen resolution
There are many ways to do this. It doesn't matter to know the exact resolution, since all you want to know is whether you will double controls size or not. If Form.Height is bigger than 400, it's VGA. You can also use the Display control from ControlsExDevice or the dzHW library to get more detailed information.

Once this is done, you need to add the following code in your application:
Code:
Sub Globals
VGA=
1

Sub App_Start
 SetControlSize
 
'Do your stuff
End Sub

Sub SetControlSize
 
If Form1.Height>400 Then
  VGA=
2 '(yes, 2)
 Else
  VGA=
1
 
End If
End Sub
2-Add compatibility to the controls you want to resize by changing from:
Code:
Button.Width=20
AddTable(
"Form1","Table1",0,0,10,10)
to
Code:
Button.Width=20*VGA
AddTable(
"Form1","Table1",0*VGA,0*VGA,10*VGA,10*VGA)
Voilà!

If VGA=2, control sizes will be doubled. Otherwise, they'll stay the same size. It only requires a few extra lines and avoids the pixel doubling of ForceQVGA

Notes:
If you get the full screen size (and not form.height) to check if it's VGA, be careful! Some libraries will return the full screen size on the desktop version so go to Designer>(any form)>Tools>Screen size and type in a VGA resolution. The font sizes will still look small, but on the device they are the same size as with Force QVGA
__________________

Last edited by N1c0_ds : 12-21-2008 at 08:52 PM.
Reply With Quote
  #2 (permalink)  
Old 12-21-2008, 08:51 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Not putting you down, but your solution is just about the same as EREL's proposal or mine, with the AutoAdjust module...
It all works around a "Scale" factor, you just implemented it in a diferent way...
But it is a nice way of thinking...And all solution can be merged into one, to rearrange both designer created as well as runtime created controls...
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!
Reply With Quote
  #3 (permalink)  
Old 12-21-2008, 09:11 PM
Senior Member
 
Join Date: Sep 2008
Posts: 161
Default

Quote:
Originally Posted by Cableguy View Post
Not putting you down, but your solution is just about the same as EREL's proposal or mine, with the AutoAdjust module...
It all works around a "Scale" factor, you just implemented it in a diferent way...
But it is a nice way of thinking...And all solution can be merged into one, to rearrange both designer created as well as runtime created controls...
AutoAdjust? I had not seen this.

My app has around 3 controls created at the beginning and between 50 and 100 controls and strings created at runtime so I really needed an efficient solution! By creating stuff at runtime I can show a "Loading..." screen early and resize them to fit the screen size right at the begining.

Also, I could easily "turn off" VGA resizing by adding a VGAFonts variable and multiplying the fontsize property by it:

Code:
If VGA=2 'If it's VGA and I want to force high resolution
 VGAFonts= 1/VGA 'Either 1 or 0.5
 VGA=1 'Display tiny controls
End If

Button1.Fontsize=
Int(9*VGAFont) 'Tiny fonts

I love programming!
__________________
Reply With Quote
  #4 (permalink)  
Old 12-21-2008, 09:17 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Quote:
Originally Posted by N1c0_ds View Post
AutoAdjust? I had not seen this.

I love programming!
working-vga-screens
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!
Reply With Quote
  #5 (permalink)  
Old 12-21-2008, 10:13 PM
Senior Member
 
Join Date: Sep 2008
Posts: 161
Default

Quote:
Originally Posted by Cableguy View Post
Great idea, but not good for my application. There is a top and bottom bar that is the same height on 240x240 and 320x320. Proportions would not work for this.
__________________
Reply With Quote
  #6 (permalink)  
Old 12-22-2008, 05:10 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,726
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Thank you for sharing this
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
Programm in VGA + QVGA ? Paulsche German Forum 0 09-11-2008 02:09 PM
VGA and QVGA alfcen Basic4ppc Wishlist 4 02-05-2008 06:37 PM
ploting just one pixel colin9876 Questions (Windows Mobile) 1 11-30-2007 06:38 PM
Fastest way to get pixel colour value? DavidN Questions (Windows Mobile) 6 09-02-2007 06:40 AM
2 pixel displacement specci48 Questions (Windows Mobile) 2 08-29-2007 06:04 PM


All times are GMT. The time now is 10:19 PM.


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