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.

inside custom component

Native Development

Reply
Developer
Developer
lew
Posts: 174
Registered: ‎03-05-2009
My Device: Dev Alpha
My Carrier: -
Accepted Solution

scaling image

Hi, 

 

i've been having some issues trying to scale an image....used the code below but no scaling happens :smileysad: anyone got a clue what i am doing wrong ?

 

QImage qImage = QImage::fromData(reply->readAll()).scaled(302,170,Qt::KeepAspectRatio);
		qDebug() << "QImage size width=" << qImage.width() << " height=" << qImage.height();
		bb::ImageData imageData(bb::PixelFormat::RGBA_Premultiplied, qImage.width(), qImage.height());

		unsigned char *dstLine = imageData.pixels();
		for (int y = 0; y < imageData.height(); y++)
		{
			unsigned char * dst = dstLine;
			for (int x = 0; x < imageData.width(); x++)
			{
				QRgb srcPixel = qImage.pixel(x, y);
				*dst++ = qRed(srcPixel);
				*dst++ = qGreen(srcPixel);
				*dst++ = qBlue(srcPixel);
				*dst++ = qAlpha(srcPixel);
			}
			dstLine += imageData.bytesPerLine();
		}

		Image image = Image(imageData);

 NOTE:

- replay variable is the data retrieved from a server

- the raw image retrieved from the server is 16x9 

- have tried different aspect ratios but all gave the same result (no scaling observed)

 

Result:

no scaling at all when image is displayed. but when i ask the size of the scaled QImage, it properly prints 302x170.

 

 

Please use plain text.
Developer
Developer
lew
Posts: 174
Registered: ‎03-05-2009
My Device: Dev Alpha
My Carrier: -

Re: scaling image

nevermind that....big ooops on my part...in one of my QML files, the preferredHeight was set to 100 and this was automatically scaling the image in QML again :smileysad:

Please use plain text.
New Member
jimmy123
Posts: 1
Registered: ‎10-28-2013
My Device: NONE
My Carrier: NONE

Re: scaling image

If you are looking for a way to resize image proportionally, please try this VB.NET image scaling control. Using this control, developers can adjust the image size without changing the ratio between image width & height. To put it in another way, this VB.NET image scaling control toolkit allows developers to zoom in or zoom out source image file in a programming way.

 

Please use plain text.