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
Highlighted
Developer
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi

Using ImageConverter

 

Trying to use the imageConverter class.

 

bb::utility::imageConverter().encode("JPEG",qImage);

 

What would the proper syntax to do this be?

_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis
Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: Using ImageConverter

What data are you trying to encode? You would need an ImageData that has a pixel buffer of some known format it it. Then when you do encode, you specify the mime type, like "image/jpeg".

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Developer
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi

Re: Using ImageConverter

I'm just using which ever image file is chosen by a user through the file picker.

 

FilePicker {
            id: picker
            type: FileType.Picture
            filter: [ "*.jpeg"] // , "*.jpg", "*.png" 
            onFileSelected: {
                app.savePicture(selectedFiles[0],app.getTempPath()+"/temp.jpeg")
            }
        }

 The c++ functin savePicture()

bool ApplicationUI::savePicture(const QString &fromPath,
		const QString &toPath) {
	QImage qImage;
	if (qImage.load(fromPath)) {
		qImage = checkRotation(qImage, fromPath);
		QFile outFile(toPath);
		if (outFile.open(QIODevice::WriteOnly)) {
			qImage.save(&outFile, "JPEG");
			outFile.close();

			return true;
		} else {
			qDebug() << "Saving Failed";
			return false;
		}
	} else {
		qDebug() << "Can't find image";
		return false;
	}
}

 

_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis
Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: Using ImageConverter

Ah, yes, if you are using QImage you don't need to use our imageconverter class as QImage has it built in. I believe QImage also just takes a type like you have ("JPG"). Also, I believe you can save directly to a file name rather than opening and closing the file yourself.

 

Your code looks reasonable at first glance though. What sort of problem are you having?

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker