BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 03-13-2010, 11:07 PM   #1 (permalink)
New Member
 
Join Date: Mar 2010
Model: 9550
PIN: N/A
Carrier: telus
Posts: 11
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default different looks on differnt models

Please Login to Remove!

Everthing I am doing looks good when I run the simulator for 9550(Storm) but when I run the simulator for 9700 everything is smaller and does not fill the screen
Have I missed something or is it because the 9700 is a newer model?

Cheers!!!
Offline  
Old 03-14-2010, 06:32 AM   #2 (permalink)
CrackBerry Addict
 
Sytner's Avatar
 
Join Date: Jul 2008
Location: UK
Model: 9800
OS: 6.0.0.337
PIN: S = Ouch
Carrier: Orange UK
Posts: 717
Post Thanks: 3
Thanked 42 Times in 38 Posts
Default

Wirelessly posted (8520 (5.0.0.411))

The 9500 and 9700 are completely different models. You would have to write the app specifically for each device.
__________________
How To Create Wallpapers
VistaBB - Vista Aero Style
^ Not bad for a 15 year old?
9800 / 6.0.0.337
If someone posts something useful, click thanks!
Offline  
Old 03-14-2010, 10:04 AM   #3 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

The 9550 and 9700 have very different display sizes. The 9700 has a much smaller display (in terms of physical measurements) with a higher resolution than the 9550 - this is why your screens look different.

The correct way to do this is make sure that your fields and your layouts adapt to the display size, resolution, and orientation. Hard-coding screen coordinates will not work, unless you want to (as Sytner suggested) have a different build for every device (not a good idea, IMHO).
Offline  
Old 03-14-2010, 01:21 PM   #4 (permalink)
Knows Where the Search Button Is
 
Join Date: Mar 2010
Model: N/A
PIN: N/A
Carrier: Fledge
Posts: 43
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you need to scale images or bitmaps, the class I've pasted below can be very helpful.

ScaleImage.toSize() scales an image vertically and horizontally to the size you specify (ignoring current proportions);
ScaleImage.toWidth() scales an image to the specified width constraining proportions;
ScaleImage.toHeight() scales an image to the specified width constraining proportions;
scaleToFactor is a helper method that the other methods use.

Code:
import net.rim.device.api.math.Fixed32;
import net.rim.device.api.system.EncodedImage;

public class ScaleImage {
	public static EncodedImage toSize(EncodedImage encoded, int newWidth, int newHeight) {
		int curWidth = encoded.getWidth();
		int curHeight = encoded.getHeight();
		int xnumerator = Fixed32.toFP(curWidth);
		int xdenominator = Fixed32.toFP(newWidth);
		int xscale = Fixed32.div(xnumerator, xdenominator);
		int ynumerator = Fixed32.toFP(curHeight);
		int ydenominator = Fixed32.toFP(newHeight);
		int yscale = Fixed32.div(ynumerator, ydenominator);
		return encoded.scaleImage32(xscale, yscale);
	}
	
	public static EncodedImage toWidth(EncodedImage encoded, int newWidth) {
		return scaleToFactor(encoded, encoded.getWidth(), newWidth);
	}
	
	public static EncodedImage toHeight(EncodedImage encoded, int newHeight) {
		return scaleToFactor(encoded, encoded.getHeight(), newHeight);
	}
	
	public static EncodedImage scaleToFactor(EncodedImage encoded, int curSize, int newSize) {
		int numerator = Fixed32.toFP(curSize);
		int denominator = Fixed32.toFP(newSize);
		int scale = Fixed32.div(numerator, denominator);

		return encoded.scaleImage32(scale, scale);
	}	
}
Offline  
Old 03-15-2010, 06:36 AM   #5 (permalink)
New Member
 
Join Date: Mar 2010
Model: 9550
PIN: N/A
Carrier: telus
Posts: 11
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

If I create a new class with this Image code do I pull it to each screen or is there somewhere I can pull it to for all screens?
Or am I way off?

cheers!!!
Offline  
Old 03-15-2010, 10:04 AM   #6 (permalink)
Knows Where the Search Button Is
 
Join Date: Mar 2010
Model: N/A
PIN: N/A
Carrier: Fledge
Posts: 43
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

The methods are public and static, meaning you don't need to instantiate the class in order to use the methods. So if you the class called "ScaleImage" you can directly use "ScaleImage.toWidth()" in any class that has imported ScaleImage.

Scaling the image does use some cpu and resources, so if you are going to reuse a scaled image, it is a good idea to save the image to a Bitmap and use it again.

For example, in the constructor of one of your MainScreens you could do the following:

Code:
public class MyScreen extends MainScreen {
    Bitmap myBitmap;
    public MainScreen() {
        EncodedImage encodedImage = EncodedImage.getEncodedImageResource("myImage.png");
        encodedImage = ScaleImage.toSize(encodedImage, Config.getThumbnailSize(), Config.getThumbnailSize());
        myBitmap = encodedImage.getBitmap();	
        add(new BitmapField(myBitmap));
    }
}
Offline  
Closed Thread


Thread Tools

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 On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.