Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Native Development

Reply
Developer
rakesh86shankar
Posts: 916
Registered: ‎05-22-2009
Accepted Solution

How to size of ImageView using scaling property

Hi,

 

I am using Imageview to display the images which are in assets,i want to resize them,i tried using resize image using scaling method in c++.I am not able to do it,How do it?

 

Is there any way apart from scaling method?

 

Regards

Rakesh Shankar.P

Please use plain text.
Developer
mstawick
Posts: 48
Registered: ‎06-24-2010
My Carrier: Orange

Re: How to size of ImageView using scaling property

a) You can use generic method, VisualNode::setScale(), and scale whole control, but this is probably not recommended

b) You can use ImageView::setScalingMethod() and set preferredWidth and preferredHeight - your image will be scaled using selected method to preferred sizes.

 

If you want for ex. to double size of the image, you can use ImageTracker to load image, read it's width and height, and then set loaded image to your image view with calculated preferred sizes. 

 

hope it helps

Please use plain text.
Developer
rakesh86shankar
Posts: 916
Registered: ‎05-22-2009

Re: How to size of ImageView using scaling property

[ Edited ]

How do i scale using Image Scaling

	ImageView *imageView = new ImageView();
	Image imageAsset = Image(QUrl("asset:///images/background.png"));
	imageView->setImage(imageAsset);

 When i use imageView->setScalingMethod(),

 

How do i set the property?

 

i dont know how to se the scalingMethod,There is no sample reference for this in API to set the scaling property,can you help me on this

Please use plain text.
Developer
mstawick
Posts: 48
Registered: ‎06-24-2010
My Carrier: Orange

Re: How to size of ImageView using scaling property

Quick and dirty example:

 

ImageView * iv = new ImageView();
iv->setImageSource(QUrl("asset:///fooo.png"));
iv->setScalingMethod(ScalingMethod::AspectFill);
iv->setPreferredSize(768, 1024);

 In practice you'll want to load image using ImageTracker, wait for signal that it's loaded, and then set Image on imageview. From ImageTracker you can also read dimensions of Image. 

Please use plain text.