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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
Developer
Posts: 160
Registered: ‎01-27-2012
My Device: Playbook
My Carrier: Rogers

Imageview Rendering issue

[ Edited ]

I'm having issues with Imageviews not rendering .jpgs from a shared directory.  Filepicker sample renders the files fine.  Here's the code:

 

In qml:

function setimages(){

imageviewid.imageSource =_slideshow.getImageSource();

}

 

in C++

void Slideshow::getImageSource(){

QString source;

//    source="/accounts/1000/shared/photos/outimage.png";     // this renders fine

source="/accounts/1000/shared/photos/IMG_00000011.jpg";   // renders image black

// source = "images/IMG_00000003.jpg"  // works fine

    QDir app;
    QString abspath = app.relativeFilePath(source);
    qDebug() << abspath;
    return QVariant::fromValue(source);

}

 

Thoughts?

---
If you find my post helpful please "like" it and "accept as a solution"
Developer
Posts: 160
Registered: ‎01-27-2012
My Device: Playbook
My Carrier: Rogers

Re: Imageview Rendering issue

It appears the difference between the files is the size.  One is >900,000,KB while the other is only 60,000KB.  So is there a limit on the sizes that Cascades will load into an imageview?  How do you get around this?

---
If you find my post helpful please "like" it and "accept as a solution"
BlackBerry Development Advisor
Posts: 683
Registered: ‎11-29-2011
My Device: PRIV
My Carrier: Rogers

Re: Imageview Rendering issue

ImageView is limited to images with a resolution of 2048x2048 or less.

There are a few threads related to this.

 

Cheers,

Sean

Developer
Posts: 160
Registered: ‎01-27-2012
My Device: Playbook
My Carrier: Rogers

Re: Imageview Rendering issue

Thanks.  I had actually done a bunch of searches, but I never located anything referencing this.

 

To get around this issue, I'm trying to implement an imagescaler in a seprate thread, however bb:ImageData does not seem to be thread safe ( I get the error message ApplicationPrivate::context: ERROR called from non-UI thread QThread)  .  What is the correct method to scale in a seperate thread?

 

I've tried to implement the code snippet docoumented 

static bb::ImageData fromQImage(const QImage &qImage) {
	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();
	}

	return imageData;
}

 

---
If you find my post helpful please "like" it and "accept as a solution"
BlackBerry Development Advisor
Posts: 683
Registered: ‎11-29-2011
My Device: PRIV
My Carrier: Rogers

Re: Imageview Rendering issue

If I had to guess, I'd wager that the problem is that you are instantiating bb::ImageData imageData() on the stack in this function and then returning it.

Maybe this thread should take ImageData& or ImageData* as an argument, and supply the instance from your UI thread.