If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

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
Dredvard
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"
Please use plain text.
Developer
Dredvard
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"
Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 665
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

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

Please use plain text.
Developer
Dredvard
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"
Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 665
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

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.

Please use plain text.