11-15-2012 12:25 PM - edited 11-15-2012 08:09 PM
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"
source="/accounts/1000/shared/photos/IMG_00000011.
// source = "images/IMG_00000003.jpg" // works fine
QDir app;
QString abspath = app.relativeFilePath(source);
qDebug() << abspath;
return QVariant::fromValue(source);
}
Thoughts?
11-15-2012 08:11 PM
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?
11-15-2012 10:38 PM
ImageView is limited to images with a resolution of 2048x2048 or less.
There are a few threads related to this.
Cheers,
Sean
11-16-2012 12:01 AM
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;
}
11-16-2012 09:09 AM
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.